Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Check for --undefined-version support #491

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/build/+meson_bump.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raised minimal meson version requirement to 0.58.
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`.
25 changes: 13 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(
'warning_level=2',
'b_lundef=true',
],
meson_version : '>= 0.52.0',
meson_version : '>= 0.58.0', # Released on May 2021
)
pkgconfig = import('pkgconfig')
cc = meson.get_compiler('c')
Expand Down 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
wismill marked this conversation as resolved.
Show resolved Hide resolved
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 Expand Up @@ -270,9 +277,7 @@ dep_libxkbcommon = declare_dependency(
link_with: libxkbcommon,
include_directories: include_directories('include'),
)
if meson.version().version_compare('>= 0.54.0')
meson.override_dependency('xkbcommon', dep_libxkbcommon)
endif
meson.override_dependency('xkbcommon', dep_libxkbcommon)
pkgconfig.generate(
libxkbcommon,
name: 'xkbcommon',
Expand Down Expand Up @@ -341,9 +346,7 @@ You can disable X11 support with -Denable-x11=false.''')
link_with: libxkbcommon_x11,
include_directories: include_directories('include'),
)
if meson.version().version_compare('>= 0.54.0')
meson.override_dependency('xkbcommon-x11', dep_libxkbcommon_x11)
endif
meson.override_dependency('xkbcommon-x11', dep_libxkbcommon_x11)
pkgconfig.generate(
libxkbcommon_x11,
name: 'xkbcommon-x11',
Expand Down Expand Up @@ -409,9 +412,7 @@ if get_option('enable-xkbregistry')
link_with: libxkbregistry,
include_directories: include_directories('include'),
)
if meson.version().version_compare('>= 0.54.0')
meson.override_dependency('xkbregistry', dep_libxkbregistry)
endif
meson.override_dependency('xkbregistry', dep_libxkbregistry)
endif

man_pages = []
Expand Down
Loading