macos exported symbols list not used for loadable modules

Started by Peter Eisentraut7 months ago3 messages
#1Peter Eisentraut
peter@eisentraut.org
2 attachment(s)

On macOS, when building with the make system, the exported symbols list
(SHLIB_EXPORTS) is ignored. I don't think that is intentional. It was
probably just forgotten, since that combination has never actually been
used until now (for libpq-oauth).

(Alternatively: Am I missing something? Is this combination not useful?
Was it not supported in older versions at some point? I couldn't
think of anything.)

The meson build system handles this correctly.

I suggest that we fix this. I attach patch 0001 with a minimal fix,
patch 0002 is a bit more refactoring to make the code match the layout
for other platforms.

Attachments:

0001-Use-exported-symbols-list-on-macOS-for-loadable-modu.patchtext/plain; charset=UTF-8; name=0001-Use-exported-symbols-list-on-macOS-for-loadable-modu.patchDownload
From 9122943d8e15497254f2f40c55b38ebbbf13241f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 3 Jun 2025 09:41:51 +0200
Subject: [PATCH 1/2] Use exported symbols list on macOS for loadable modules
 as well

---
 src/Makefile.shlib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index fa81f6ffdd6..ff616beeb95 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -117,7 +117,7 @@ ifeq ($(PORTNAME), darwin)
     shlib_major		= lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
   else
     # loadable module
-    LINK.shared		= $(COMPILER) -bundle
+    LINK.shared		= $(COMPILER) -bundle $(exported_symbols_list)
   endif
   BUILD.exports		= $(AWK) '/^[^\#]/ {printf "_%s\n",$$1}' $< >$@
   exports_file		= $(SHLIB_EXPORTS:%.txt=%.list)
-- 
2.49.0

0002-Refactor-export-symbols-list-handling-on-macOS-a-bit.patchtext/plain; charset=UTF-8; name=0002-Refactor-export-symbols-list-handling-on-macOS-a-bit.patchDownload
From 2080a21880c616a76251085d1cd9f6a47728b19e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 3 Jun 2025 09:43:56 +0200
Subject: [PATCH 2/2] Refactor export symbols list handling on macOS a bit

---
 src/Makefile.shlib | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index ff616beeb95..3825af5b228 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -112,17 +112,17 @@ ifeq ($(PORTNAME), darwin)
     ifneq ($(SO_MAJOR_VERSION), 0)
       version_link	= -compatibility_version $(SO_MAJOR_VERSION) -current_version $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
     endif
-    LINK.shared		= $(COMPILER) -dynamiclib -install_name '$(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)' $(version_link) $(exported_symbols_list)
+    LINK.shared		= $(COMPILER) -dynamiclib -install_name '$(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)' $(version_link)
     shlib		= lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
     shlib_major		= lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
   else
     # loadable module
-    LINK.shared		= $(COMPILER) -bundle $(exported_symbols_list)
+    LINK.shared		= $(COMPILER) -bundle
   endif
   BUILD.exports		= $(AWK) '/^[^\#]/ {printf "_%s\n",$$1}' $< >$@
   exports_file		= $(SHLIB_EXPORTS:%.txt=%.list)
   ifneq (,$(exports_file))
-    exported_symbols_list = -exported_symbols_list $(exports_file)
+    LINK.shared		+= -exported_symbols_list $(exports_file)
   endif
 endif
 
-- 
2.49.0

#2Jacob Champion
jacob.champion@enterprisedb.com
In reply to: Peter Eisentraut (#1)
Re: macos exported symbols list not used for loadable modules

On Tue, Jun 3, 2025 at 12:48 AM Peter Eisentraut <peter@eisentraut.org> wrote:

On macOS, when building with the make system, the exported symbols list
(SHLIB_EXPORTS) is ignored. I don't think that is intentional. It was
probably just forgotten, since that combination has never actually been
used until now (for libpq-oauth).

Oops, thank you for noticing that.

(Alternatively: Am I missing something? Is this combination not useful?
Was it not supported in older versions at some point? I couldn't
think of anything.)

The meson build system handles this correctly.

I suggest that we fix this. I attach patch 0001 with a minimal fix,
patch 0002 is a bit more refactoring to make the code match the layout
for other platforms.

LGTM, and works on my machine. Unfortunately I don't have any insight
into the history.

Thanks!
--Jacob

#3Peter Eisentraut
peter@eisentraut.org
In reply to: Jacob Champion (#2)
Re: macos exported symbols list not used for loadable modules

On 05.06.25 19:28, Jacob Champion wrote:

On Tue, Jun 3, 2025 at 12:48 AM Peter Eisentraut <peter@eisentraut.org> wrote:

On macOS, when building with the make system, the exported symbols list
(SHLIB_EXPORTS) is ignored. I don't think that is intentional. It was
probably just forgotten, since that combination has never actually been
used until now (for libpq-oauth).

Oops, thank you for noticing that.

(Alternatively: Am I missing something? Is this combination not useful?
Was it not supported in older versions at some point? I couldn't
think of anything.)

The meson build system handles this correctly.

I suggest that we fix this. I attach patch 0001 with a minimal fix,
patch 0002 is a bit more refactoring to make the code match the layout
for other platforms.

LGTM, and works on my machine. Unfortunately I don't have any insight
into the history.

Ok, fix committed.