testsuite, gm2: Use -B option for libstdc++ where required.
Commit Message
TL;DR without this change we get circa 2500 new fails in the gm2 testsuite
when PR119172 is fixed.
Recent increases in security constraints on macOS14+ (resulting in PR119172)
mean that the system will not fall back to using alternate shared libs than
the ones actually linked (when we fix 119172).
Most of the testsuite is already clean w.r.t to this - since we already made
the change below. From that point of view this patch is borderline obvious.
tested on x86_64/aarch64 Darwin 17,21,22,23,24 and x86_64-linux,
OK for trunk (and relevant backports)?
thanks
Iain
--- 8< ---
We need to add testsuite options to locate gm2 libs and libstdc++.
Usually '-L' options are added to point to the relevant directories for
the uninstalled libraries.
In cases where libraries are available as both shared and convenience some
additional checks are made.
For some targets -static-xxxx options are handled by specs substitution and
need a '-B' option rather than '-L'. For Darwin, when embedded runpaths are
in use (the default for all versions after macOS 10.11), '-B' is also needed
to provide the runpath.
When '-B' is used, this results in a '-L' for each path that exists (so that
appending a '-L' as well is a needless duplicate). There are also cases
where tools warn for duplicates, leading to spurious fails.
Therefore the objective of the code here is to add just one '-L' or '-B' for
each of the libraries.
Currently, we are forcing the full paths to each of the gm2 convenience libs
onto the link line and therefore the B/L logic is not needed there. It would
need to be added if/when gm2 is tested with shared libraries
gcc/testsuite/ChangeLog:
* lib/gm2.exp: Arrange for a '-B' option to be added for the
libstdc++ paths on targets that need it.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
gcc/testsuite/lib/gm2.exp | 46 ++++++++++++++++++++++++++++++---------
1 file changed, 36 insertions(+), 10 deletions(-)
Comments
Iain Sandoe <iains.gcc@gmail.com> writes:
> TL;DR without this change we get circa 2500 new fails in the gm2 testsuite
> when PR119172 is fixed.
>
> Recent increases in security constraints on macOS14+ (resulting in PR119172)
> mean that the system will not fall back to using alternate shared libs than
> the ones actually linked (when we fix 119172).
>
> Most of the testsuite is already clean w.r.t to this - since we already made
> the change below. From that point of view this patch is borderline obvious.
>
> tested on x86_64/aarch64 Darwin 17,21,22,23,24 and x86_64-linux,
> OK for trunk (and relevant backports)?
> thanks
> Iain
>
> --- 8< ---
>
> We need to add testsuite options to locate gm2 libs and libstdc++.
>
> Usually '-L' options are added to point to the relevant directories for
> the uninstalled libraries.
>
> In cases where libraries are available as both shared and convenience some
> additional checks are made.
>
> For some targets -static-xxxx options are handled by specs substitution and
> need a '-B' option rather than '-L'. For Darwin, when embedded runpaths are
> in use (the default for all versions after macOS 10.11), '-B' is also needed
> to provide the runpath.
>
> When '-B' is used, this results in a '-L' for each path that exists (so that
> appending a '-L' as well is a needless duplicate). There are also cases
> where tools warn for duplicates, leading to spurious fails.
>
> Therefore the objective of the code here is to add just one '-L' or '-B' for
> each of the libraries.
>
> Currently, we are forcing the full paths to each of the gm2 convenience libs
> onto the link line and therefore the B/L logic is not needed there. It would
> need to be added if/when gm2 is tested with shared libraries
>
> gcc/testsuite/ChangeLog:
>
> * lib/gm2.exp: Arrange for a '-B' option to be added for the
> libstdc++ paths on targets that need it.
>
Many thanks for the patch, yes lgtm, please apply,
regards,
Gaius
@@ -254,12 +254,35 @@ proc gm2_link_flags { paths } {
if [istarget "powerpc-*-*"] {
lappend flags "-mabi=ieeelongdouble"
}
+
+ # We need to add options to locate gm2 libs and libstdc++
+ # Usually '-L' options are added to point to the relevant directories for
+ # the uninstalled libraries.
+
+ # In cases where libraries are available as both shared and convenience
+ # some additional checks are made.
+
+ # For some targets -static-xxxx options are handled by specs substitution
+ # and need a '-B' option rather than '-L'. For Darwin, when embedded
+ # runpaths are in use (the default for all versions after macOS 10.11),
+ # '-B' is also needed to provide the runpath.
+ # When '-B' is used, this results in a '-L' for each path that exists (so
+ # that appending a '-L' as well is a needless duplicate). There are also
+ # cases where tools warn for duplicates, leading to spurious fails.
+ # Therefore the objective of the code below is to add just one '-L' or
+ # '-B' for each of the libraries.
+
+ set target_wants_B_option 0
+ if { [istarget *-*-darwin9* ] || [istarget *-*-darwin\[12\]* ] } {
+ set target_wants_B_option 1
+ }
+
if { $gccpath == "" } {
global tool_root_dir
set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]
if { $libstdcpp != "" } {
- append flags "-L${libstdcpp} "
+ append flags " -L${libstdcpp} "
append ld_library_path ":${libstdcpp}"
}
} else {
@@ -267,19 +290,22 @@ proc gm2_link_flags { paths } {
append ld_library_path ":${gccpath}/lib"
}
if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
- append flags "-L${gccpath}/libstdc++ "
+ append flags " -L${gccpath}/libstdc++ "
append ld_library_path ":${gccpath}/libstdc++"
}
- if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
- append flags " -L${gccpath}/libstdc++-v3/src/.libs "
- append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
- }
- # Look for libstdc++.${shlib_ext}.
- if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
- append flags " -L${gccpath}/libstdc++-v3/src/.libs "
+ # Look for libstdc++.<a,${shlib_ext}>.
+ if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
+ || [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
+ if { $target_wants_B_option } {
+ append flags " -B${gccpath}/libstdc++-v3/src/.libs "
+ } else {
+ append flags " -L${gccpath}/libstdc++-v3/src/.libs "
+ }
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
}
+ # Here we are forcing the static libraries, with complete paths so
+ # there's no -L/-B logic needed
# puts stderr "${gm2_link_libraries} before foreach"
foreach d [list {*}${gm2_link_libraries}] {
# puts stderr "${d} XXXX"
@@ -288,7 +314,7 @@ proc gm2_link_flags { paths } {
if [file exists "${gccpath}/libgm2/lib${d}/.libs/lib${d}.a"] {
send_log "good found ${gccpath}/libgm2/lib${d}/.libs/lib${d}.a\n"
# append flags " -L${gccpath}/libgm2/lib${d}/.libs -l${d}"
- append flags " ${gccpath}/libgm2/lib${d}/.libs/lib${d}.a"
+ append flags " ${gccpath}/libgm2/lib${d}/.libs/lib${d}.a "
append ld_library_path ":${gccpath}/libgm2/lib${d}/.libs"
}
send_log "ld_library_path is ${ld_library_path}\n"