diff --git a/.pick_status.json b/.pick_status.json index 0a61fbae0b5..c25c2e5b399 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2218,7 +2218,7 @@ "description": "meson: combine checks for linker --gc-sections support", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "f51ce21e4e0bf7efabe58afb4a2cd6b9f98d9505" }, diff --git a/meson.build b/meson.build index 172c64a7c70..392f85be7f4 100644 --- a/meson.build +++ b/meson.build @@ -1119,6 +1119,7 @@ endif c_msvc_compat_args = [] no_override_init_args = [] cpp_msvc_compat_args = [] +ld_args_gc_sections = [] if cc.get_argument_syntax() == 'msvc' _trial = [ '/wd4018', # signed/unsigned mismatch @@ -1195,7 +1196,9 @@ else # own sections and GC the sections after linking. This lets drivers # drop shared code unused by that specific driver (particularly # relevant for Vulkan drivers). - if cc.has_link_argument('-Wl,--gc-sections') + if cc.links('static char unused() { return 5; } int main() { return 0; }', + args : '-Wl,--gc-sections', name : 'gc-sections') + ld_args_gc_sections += '-Wl,--gc-sections' _trial_c += ['-ffunction-sections', '-fdata-sections'] _trial_cpp += ['-ffunction-sections', '-fdata-sections'] endif @@ -1528,11 +1531,6 @@ ld_args_bsymbolic = [] if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic') ld_args_bsymbolic += '-Wl,-Bsymbolic' endif -ld_args_gc_sections = [] -if cc.links('static char unused() { return 5; } int main() { return 0; }', - args : '-Wl,--gc-sections', name : 'gc-sections') - ld_args_gc_sections += '-Wl,--gc-sections' -endif with_ld_version_script = false if cc.links('int main() { return 0; }', args : '-Wl,--version-script=@0@'.format(