compiler wrapper: parse Wl and Xlinker properly (#35912)

Two fixes:

1. `-Wl,a,b,c,d` is a comma separated list of linker arguments, we
   incorrectly assume key/value pairs, which runs into issues with for
   example `-Wl,--enable-new-dtags,-rpath,/x`
2. `-Xlinker,xxx` is not a think, so it shouldn't be parsed.
This commit is contained in:
Harmen Stoppels
2023-03-08 09:03:31 +01:00
committed by GitHub
parent ec73157a34
commit c37d6f97dc
3 changed files with 57 additions and 50 deletions

View File

@@ -127,13 +127,13 @@ def test_static_to_shared_library(build_environment):
"linux": (
"/bin/mycc -shared"
" -Wl,--disable-new-dtags"
" -Wl,-soname,{2} -Wl,--whole-archive {0}"
" -Wl,-soname -Wl,{2} -Wl,--whole-archive {0}"
" -Wl,--no-whole-archive -o {1}"
),
"darwin": (
"/bin/mycc -dynamiclib"
" -Wl,--disable-new-dtags"
" -install_name {1} -Wl,-force_load,{0} -o {1}"
" -install_name {1} -Wl,-force_load -Wl,{0} -o {1}"
),
}

View File

@@ -342,6 +342,16 @@ def test_fc_flags(wrapper_environment, wrapper_flags):
)
def test_Wl_parsing(wrapper_environment):
check_args(
cc,
["-Wl,-rpath,/a,--enable-new-dtags,-rpath=/b,--rpath", "-Wl,/c"],
[real_cc]
+ target_args
+ ["-Wl,--disable-new-dtags", "-Wl,-rpath,/a", "-Wl,-rpath,/b", "-Wl,-rpath,/c"],
)
def test_dep_rpath(wrapper_environment):
"""Ensure RPATHs for root package are added."""
check_args(cc, test_args, [real_cc] + target_args + common_compile_args)