Skip to content

Commit

Permalink
build: Check for --undefined-version support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wismill committed Jul 16, 2024
1 parent 621e310 commit 1d8a25d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changes/build/481.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Gated the use of `--undefined-version` in the linker because it breaks on older
GNU `ld`.
11 changes: 9 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,17 @@ configh_data.set('_CRT_NONSTDC_NO_DEPRECATE', 1)
# Reduce unnecessary includes on MSVC.
configh_data.set('WIN32_LEAN_AND_MEAN', 1)

xkbcommon_map = meson.current_source_dir() / 'xkbcommon.map'

# 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: f'-Wl,--version-script=@xkbcommon_map@@extra_linker_args@',
name: '-Wl,--version-script',
)

Expand Down Expand Up @@ -235,7 +242,7 @@ libxkbcommon_sources = [
libxkbcommon_link_args = []
libxkbcommon_link_deps = []
if have_version_script
libxkbcommon_link_args += '-Wl,--version-script=' + meson.current_source_dir()/'xkbcommon.map'
libxkbcommon_link_args += f'-Wl,--version-script=@xkbcommon_map@'
libxkbcommon_link_deps += 'xkbcommon.map'
elif cc.get_argument_syntax() == 'msvc'
libxkbcommon_def = custom_target('xkbcommon.def',
Expand Down

0 comments on commit 1d8a25d

Please sign in to comment.