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: f51ce21e ("meson: Drop adding -Wl,--gc-sections to project c/cpp arguments.")