mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-01-22 05:33:55 +08: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>
This commit is contained in:
parent
7f98a9ba2b
commit
fd9b50aa1c
10
meson.build
10
meson.build
@ -965,6 +965,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
|
||||
@ -1044,7 +1045,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
|
||||
@ -1380,11 +1383,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…
Reference in New Issue
Block a user