diff options
author | Andres Freund <andres@anarazel.de> | 2024-03-13 01:40:53 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2024-03-13 01:40:53 -0700 |
commit | a3da95deee38ee067b0bead639c830eacbe894d5 (patch) | |
tree | 8f67db39a7c9724f8bb9d15331e7682958102aff | |
parent | 6612185883c6a43979693358423ee647421ff621 (diff) | |
download | postgresql-a3da95deee38ee067b0bead639c830eacbe894d5.tar.gz postgresql-a3da95deee38ee067b0bead639c830eacbe894d5.zip |
meson: macos: Avoid warnings on Sonoma
Starting with the Sonoma toolchain macos' linker emits warnings when the same
library is linked to twice. That's ill considered, as the same library can be
used by multiple subsidiary libraries. Luckily there's a flag to suppress that
warning.
On Ventura meson's default of -Wl,-undefined,dynamic_lookup caused warnings,
which we suppressed with -Wl,-undefined,error. Unfortunately that causes a
warning on Sonoma, which is absurd, as it's documented linker default. To
avoid that warning, only add -Wl,-undefined,error if it does not trigger
warnings. Luckily dynamic_lookup doesn't trigger a warning on Sonoma anymore.
Discussion: https://postgr.es/m/20231201040515.p5bshhhtfru7d3da@awork3.anarazel.de
Backpatch: 16-, where the meson build was added
-rw-r--r-- | meson.build | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/meson.build b/meson.build index 85788f9dd8f..c8fdfeb0ec3 100644 --- a/meson.build +++ b/meson.build @@ -222,10 +222,20 @@ elif host_system == 'darwin' cflags += ['-isysroot', pg_sysroot] ldflags += ['-isysroot', pg_sysroot] endif + # 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'] + # causes warnings in macOS Ventura. But using -Wl,-undefined,error causes a + # warning starting in Sonoma. So only add -Wl,-undefined,error if it does + # not cause a warning. + if cc.has_multi_link_arguments('-Wl,-undefined,error', '-Werror') + ldflags_mod += '-Wl,-undefined,error' + endif + + # Starting in Sonoma, the linker warns about the same library being + # linked twice. Which can easily happen when multiple dependencies + # depend on the same library. Quiesce the ill considered warning. + ldflags += cc.get_supported_link_arguments('-Wl,-no_warn_duplicate_libraries') elif host_system == 'freebsd' sema_kind = 'unnamed_posix' |