Re: Annoying build warnings from latest Apple toolchain

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Annoying build warnings from latest Apple toolchain
Date: 2023-11-21 04:37:07
Message-ID: 20231121043707.jvf5f5tj7jylj5nj@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-11-20 16:20:20 -0500, Tom Lane wrote:
> I'm generally still using autoconf, I only run meson builds when
> somebody complains about them ;-). But yeah, I see lots of
> "ld: warning: -undefined error is deprecated" when I do that.
> This seems to have been installed by Andres' 9a95a510a:
>
> ldflags += ['-isysroot', pg_sysroot]
> + # meson defaults to -Wl,-undefined,dynamic_lookup for modules, which we
> + # don't want because a) it's different from what we do for autoconf, b) it
> + # causes warnings starting in macOS Ventura
> + ldflags_mod += ['-Wl,-undefined,error']

That's not the sole issue, because meson automatically adds that for binaries
(due to some linker issue that existed in the past IIRC).

> The autoconf side seems to just be letting this option default.
> I'm not sure what the default choice is, but evidently it's not
> "-undefined error"? Or were they stupid enough to not allow you
> to explicitly select the default behavior?

I'm somewhat confused by what Apple did. I just was upgrading my m1 mac mini
to sonoma, and in one state I recall man ld documenting it below "Obsolete
Options". But then I also updated xcode, and now there's no mention whatsoever
of the option being deprecated in the man page at all. Perhaps my mind is
playing tricks on me.

And yes, it sure looks like everything other than 'dynamic_lookup' creates a
warning. Which seems absurd.

> Also, I *don't* see any complaints about duplicate libraries.
> What build options are you using?

I don't understand what Apple is thinking here. Getting the same library name
twice, e.g. icu once directly and once indirectly via xml2-config --libs or
such, seems very common. To avoid that portably, you basically need to do a
topographical sort of the libraries, to figure out an ordering that
deduplicates but doesn't move a library to before where it's used. With a
bunch of complexities due to -L, which could lead to finding different
libraries for the same library name, thrown in.

WRT Robert seeing those warnings and Tom not: There's something odd going
on. I couldn't immediately reproduce it. Then I realized it reproduces against
a homebrew install but not a macports one.

Robert, which are you using?

<a bunch later>

Meson actually *tries* to avoid this warning without resulting in incorrect
results due to ordering. But homebrew does something odd, with libxml-2.0,
zlib and a few others: Unless you do something to change that, brew has
/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/14/ in its search path, but
those libraries aren't from homebrew, they're referencing macos
frameworks. Apparently meson isn't able to understand which files those .pc
files link to and gives up on the deduplicating.

If I add to the pkg-config search path, e.g. via
meson configure -Dpkg_config_path=$OTHER_STUFF:/opt/homebrew/opt/zlib/lib/pkgconfig/:/opt/homebrew/opt/libxml2/lib/pkgconfig/

the warnings about duplicate libraries vanish.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2023-11-21 04:39:43 Re: Hide exposed impl detail of wchar.c
Previous Message Zhijie Hou (Fujitsu) 2023-11-21 04:31:58 RE: Synchronizing slots from primary to standby