meson: combine checks for linker --gc-sections support
authorDylan Baker <dylan.c.baker@intel.com>
Thu, 2 Feb 2023 21:05:33 +0000 (13:05 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Feb 2023 17:48:58 +0000 (17:48 +0000)
commitfd9b50aa1c07512c46ec981f19ea68fa4b8d7b4f
tree39c9ed70f7f2b4e17e537ccf803826ed279f0a8d
parent7f98a9ba2bd11b75129172885c145d032c0b69ac
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: f51ce21e4e0bf7efabe58afb4a2cd6b9f98d9505
       ("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>
meson.build