From 7d4649e37ccca8cb106922c1629c58c6fed0b4f4 Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Fri, 12 Jul 2024 11:10:46 +0200 Subject: [PATCH] build: Check for --undefined-version support Gate the use of `--undefined-version` in the linker because it breaks on older GNU `ld`: https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=58272. --- changes/build/481.bugfix.md | 2 ++ meson.build | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changes/build/481.bugfix.md diff --git a/changes/build/481.bugfix.md b/changes/build/481.bugfix.md new file mode 100644 index 000000000..e217c6e60 --- /dev/null +++ b/changes/build/481.bugfix.md @@ -0,0 +1,2 @@ +Gate the use of `--undefined-version` in the linker because it breaks on older +GNU `ld`. diff --git a/meson.build b/meson.build index 609540dbd..1ba005a41 100644 --- a/meson.build +++ b/meson.build @@ -143,9 +143,14 @@ configh_data.set('_CRT_NONSTDC_NO_DEPRECATE', 1) configh_data.set('WIN32_LEAN_AND_MEAN', 1) # Supports -Wl,--version-script? +if cc.has_link_argument('-Wl,--undefined-version') + extra_linker_args = ',--undefined-version' +else + extra_linker_args = '' +endif have_version_script = cc.links( 'int main(){}', - args: '-Wl,--undefined-version,--version-script=' + meson.current_source_dir()/'xkbcommon.map', + args: '-Wl,--version-script=' + meson.current_source_dir()/'xkbcommon.map' + extra_linker_args, name: '-Wl,--version-script', )