Re: Annoying build warnings from latest Apple toolchain - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Annoying build warnings from latest Apple toolchain
Date
Msg-id 20230929022027.sbxqugxw3kebvlml@alap3.anarazel.de
Whole thread Raw
In response to Re: Annoying build warnings from latest Apple toolchain  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Annoying build warnings from latest Apple toolchain
List pgsql-hackers
Hi,

On 2023-09-28 19:17:37 -0400, Tom Lane wrote:
> I wrote:
> > Andres Freund <andres@anarazel.de> writes:
> >> I think right now it doesn't work as-is on sonoma, because apple decided to
> >> change the option syntax, which is what causes the -e warning below, so the
> >> relevant option is just ignored.
> 
> > Hmm, we'd better fix that then.  Or is it their bug?  It looks to me like
> > clang's argument is -exported_symbols_list=/path/to/exports.list, so
> > it must be translating that to "-e".
> 
> Looking closer, the documented syntax is
> 
>     -exported_symbols_list filename
> 
> (two arguments, not one with an "=").  That is what our Makefiles
> use, and it still works fine with latest Xcode.  However, meson.build
> thinks it can get away with one argument containing "=", and evidently
> that doesn't work now (or maybe it never did?).

It does still work on Ventura.


> I tried
> 
>   export_fmt = '-exported_symbols_list @0@'

That would expand to a single argument with a space inbetween.


> and
> 
>   export_fmt = ['-exported_symbols_list', '@0@']

That would work in many places, but not here, export_fmt is used as a format
string... We could make the callsites do that for each array element, but
there's an easier solution that seems to work for both Ventura and Sonoma -
however I don't have anything older to test with.

TBH, I find it hard to understand what arguments go to the linker and which to
the compiler on macos. The argument is documented for the linker and not the
compiler, but so far we'd been passing it to the compiler, so there must be
some logic forwarding it.

Looking through the clang code, I see various llvm libraries using
-Wl,-exported_symbols_list and there are tests
(clang/test/Driver/darwin-ld.c) ensuring both syntaxes work.

Thus the easiest fix looks to be to use this:

diff --git a/meson.build b/meson.build
index 5422885b0a2..16a2b0f801e 100644
--- a/meson.build
+++ b/meson.build
@@ -224,7 +224,7 @@ elif host_system == 'darwin'
   library_path_var = 'DYLD_LIBRARY_PATH'
 
   export_file_format = 'darwin'
-  export_fmt = '-exported_symbols_list=@0@'
+  export_fmt = '-Wl,-exported_symbols_list,@0@'
 
   mod_link_args_fmt = ['-bundle_loader', '@0@']
   mod_link_with_dir = 'bindir'


I don't have anything older than Ventura to check though.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: [PGdocs] fix description for handling pf non-ASCII characters
Next
From: Michael Paquier
Date:
Subject: Re: The danger of deleting backup_label