* [PATCH] testsuite, Objective-C++: Update link flags [PR112863].
@ 2024-01-28 15:03 Iain Sandoe
2024-02-01 23:40 ` Mike Stump
0 siblings, 1 reply; 2+ messages in thread
From: Iain Sandoe @ 2024-01-28 15:03 UTC (permalink / raw)
To: gcc-patches; +Cc: ro
Tested on i686, x86_64, aarch64 Darwin, x86_64, aarch64 Linux,
OK for trunk?
thanks,
Iain
--- 8< ---
These regressions are caused by missing or duplicate runpaths which
now fire linker warnings.
We need to add options to locate libobjc (and on Darwin libobjc-gnu)
along with 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.
PR target/112863
gcc/testsuite/ChangeLog:
* lib/obj-c++.exp: Decide on whether to present -B or -L to
reference the paths to uninstalled libobjc/libobjc-gnu and
libstdc++ and use that to generate the link flags.
---
gcc/testsuite/lib/obj-c++.exp | 69 +++++++++++++++++++++--------------
1 file changed, 42 insertions(+), 27 deletions(-)
diff --git a/gcc/testsuite/lib/obj-c++.exp b/gcc/testsuite/lib/obj-c++.exp
index 397b70cb96a..854dc264f9d 100644
--- a/gcc/testsuite/lib/obj-c++.exp
+++ b/gcc/testsuite/lib/obj-c++.exp
@@ -110,34 +110,43 @@ proc obj-c++_link_flags { paths } {
set shlib_ext [get_shlib_extension]
verbose "shared lib extension: $shlib_ext"
+ # We need to add options to locate libobjc/libobjc-gnu 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 != "" } {
- if [file exists "${gccpath}/lib/libstdc++.a"] {
- append ld_library_path ":${gccpath}/lib"
- }
- if [file exists "${gccpath}/libg++/libg++.a"] {
- append flags " -L${gccpath}/libg++ "
- append ld_library_path ":${gccpath}/libg++"
- }
- if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
- append flags " -L${gccpath}/libstdc++ "
- append ld_library_path ":${gccpath}/libstdc++"
- }
- if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
- # Allow for %s spec substitutions
- append flags " -B${gccpath}/libstdc++-v3/src/.libs "
- 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}"] {
- # Allow for %s spec substitutions
- append flags " -B${gccpath}/libstdc++-v3/src/.libs "
- append flags " -L${gccpath}/libstdc++-v3/src/.libs "
- append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+ 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"
}
+
if [file exists "${gccpath}/libiberty/libiberty.a"] {
append flags " -L${gccpath}/libiberty "
}
+
if [file exists "${gccpath}/librx/librx.a"] {
append flags " -L${gccpath}/librx "
}
@@ -159,9 +168,11 @@ proc obj-c++_link_flags { paths } {
if { $libobjc_dir != "" } {
set libobjc_dir [file dirname ${libobjc_dir}]
- # Allow for %s spec substitutions
- append flags " -B${libobjc_dir} "
- append flags " -L${libobjc_dir} "
+ if { $target_wants_B_option } {
+ append flags "-B${libobjc_dir} "
+ } else {
+ append flags "-L${libobjc_dir} "
+ }
append ld_library_path ":${libobjc_dir}"
}
append ld_library_path \
@@ -176,7 +187,11 @@ proc obj-c++_link_flags { paths } {
}
set libstdcpp [lookfor_file ${tool_root_dir} libstdc++];
if { $libstdcpp != "" } {
- append flags "-L${libstdcpp} ";
+ if { $target_wants_B_option } {
+ append flags "-B${libstdcpp} "
+ } else {
+ append flags "-L${libstdcpp} "
+ }
append ld_library_path ":${libstdcpp}"
}
set libiberty [lookfor_file ${tool_root_dir} libiberty];
--
2.39.2 (Apple Git-143)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] testsuite, Objective-C++: Update link flags [PR112863].
2024-01-28 15:03 [PATCH] testsuite, Objective-C++: Update link flags [PR112863] Iain Sandoe
@ 2024-02-01 23:40 ` Mike Stump
0 siblings, 0 replies; 2+ messages in thread
From: Mike Stump @ 2024-02-01 23:40 UTC (permalink / raw)
To: Iain Sandoe; +Cc: gcc-patches, ro@cebitec.uni-bielefeld.de
On Jan 28, 2024, at 7:03 AM, Iain Sandoe <iains.gcc@gmail.com> wrote:
>
> Tested on i686, x86_64, aarch64 Darwin, x86_64, aarch64 Linux,
> OK for trunk?
Ok. If you discover needed updates, please feel free to drop them in.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-01 23:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-28 15:03 [PATCH] testsuite, Objective-C++: Update link flags [PR112863] Iain Sandoe
2024-02-01 23:40 ` Mike Stump
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).