mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
meson: combine checks for linker --gc-sections support
We first do an incomplete check for whether the linker supports --gc-sections, then potentially add C and C++ arguments assuming that it works, then later do a complete check to see if it actually works and use --gc-sections. This means we can end up putting functions and data in separate sections when we can't gc them. Combine the checks, do less work, and be more accurate. fixes:f51ce21e4e("meson: Drop adding -Wl,--gc-sections to project c/cpp arguments.") Reviewed-by: Eric Engestrom <eric@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21083> (cherry picked from commitfd9b50aa1c)
This commit is contained in:
parent
b742313eaf
commit
28e5823a68
2 changed files with 5 additions and 7 deletions
|
|
@ -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"
|
||||
},
|
||||
|
|
|
|||
10
meson.build
10
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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue