public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: remove unnecessary -Wl,-soname,NAME build flags
@ 2024-05-14 10:38 Andrew Burgess
  2024-05-14 13:30 ` [PATCH] gdb/testsuite: remove unnecessary -Wl, -soname, NAME " Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2024-05-14 10:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

While working on another patch I needed to pass -Wl,-soname,NAME as a
compiler flag.  I initially looked for other tests that did this, and
found a few examples, so I copied what they did.

But when I checked the gdb.log file I noticed that we were actually
getting -Wl,-soname passed twice.

I tracked the repeated option to 'proc gdb_compile_shlib_1' in
lib/gdb.exp.  It turns out that we always add -Wl,-soname when
compiling a shared library.

Here's an example of a build command from gdb.base/prelink.exp:

  builtin_spawn -ignore SIGHUP gcc -fno-stack-protector \
    /tmp/build/gdb/testsuite/outputs/gdb.base/prelink/prelink-lib.c.o \
    -fdiagnostics-color=never -shared -g \
    -Wl,-soname,prelink.so -Wl,-soname,prelink.so -lm \
    -o /tmp/build/gdb/testsuite/outputs/gdb.base/prelink/prelink.so

Notice that '-Wl,-soname,prelink.so' is repeated.

I believe that all of the places where tests add '-Wl,-soname,NAME' as
a build option, are unnecessary.

In this commit I propose we remove them all.

As part of this change I've switched from calling gdb_compile_shlib
directly, to instead call build_executable and adding the 'shlib'
flag.

I've tested with gcc and clang and see no changes in the test results
after this commit.  All the compile commands still have -Wl,-soname
added, but now it's only added once, from within lib/gdb.exp.

There should be no change in what is tested after this commit.
---
 gdb/testsuite/gdb.base/break-interp.exp    | 5 ++---
 gdb/testsuite/gdb.base/prelink.exp         | 6 ++----
 gdb/testsuite/gdb.base/solib-nodir.exp     | 3 ++-
 gdb/testsuite/gdb.threads/tls-sepdebug.exp | 8 ++------
 4 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index d7f84db4770..98f67eee227 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -29,9 +29,8 @@ set binfile_lib ${binprefix}.so
 set srcfile "${test}-main.c"
 set srcfile_lib "${test}-lib.c"
 
-# Use -soname so that the new library gets copied by build_executable_own_libs.
-
-if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug ldflags=-Wl,-soname,${test}.so]] != ""} {
+if {[build_executable "build library" ${binfile_lib} ${srcfile_lib} \
+	 {debug shlib}] == -1} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/prelink.exp b/gdb/testsuite/gdb.base/prelink.exp
index 50f7367d9d7..6b4790e6003 100644
--- a/gdb/testsuite/gdb.base/prelink.exp
+++ b/gdb/testsuite/gdb.base/prelink.exp
@@ -29,10 +29,8 @@ set testfile "prelink"
 set libsrcfile ${testfile}-lib.c
 set libfile [standard_output_file ${testfile}.so]
 
-# Use -soname so that the new library gets copied by build_executable_own_libs.
-
-if { [gdb_compile_shlib "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" [list debug "ldflags=-Wl,-soname,[file tail ${libfile}]"]] != ""} {
-    # If creating the shared library fails, maybe we don't have the right tools
+if {[build_executable "build library" ${libfile} ${libsrcfile} \
+	 {debug shlib}] == -1} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/solib-nodir.exp b/gdb/testsuite/gdb.base/solib-nodir.exp
index 625f06f3a9d..fe3439613df 100644
--- a/gdb/testsuite/gdb.base/solib-nodir.exp
+++ b/gdb/testsuite/gdb.base/solib-nodir.exp
@@ -36,7 +36,8 @@ set objfile [standard_output_file ${executable}.o]
 set binfile [standard_output_file ${executable}]
 
 # build the first test case
-if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" "${binlibfile}" [list debug ldflags=-Wl,-soname,${binlibfilebase}]] != ""
+if { [build_executable "build library" ${binlibfile} ${srclibfile} \
+	  {debug shlib}] == -1
      || [gdb_gnu_strip_debug $binlibfile]
      || [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != ""
      || [gdb_compile "${objfile} ${binlibfile}" "${binfile}" executable {}] != "" } {
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
index 182a3f289d3..14a0c45c7d9 100644
--- a/gdb/testsuite/gdb.threads/tls-sepdebug.exp
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
@@ -43,12 +43,8 @@ set binsharedfile      [standard_output_file ${binsharedbase}]
 # The compile flag -std=c11 is required because the test case uses
 # 'thread_local' to indicate thread local storage.  This is available
 # as a macro starting in C11 and became a C-language keyword in C23.
-if  { [gdb_compile_shlib \
-	"${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" \
-	[list debug \
-	      ldflags=-Wl,-soname=${binsharedbase} \
-	      additional_flags=-std=c11]] \
-       != "" } {
+if { [build_executable "build library" ${binsharedfile} ${srcsharedfile} \
+	  {debug shlib additional_flags=-std=c11}] == -1 } {
     untested "Couldn't compile test library"
     return -1
 }

base-commit: 83b972fc272db31ab48aa5cde84f47c98868d7c8
-- 
2.25.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/testsuite: remove unnecessary -Wl, -soname, NAME build flags
  2024-05-14 10:38 [PATCH] gdb/testsuite: remove unnecessary -Wl,-soname,NAME build flags Andrew Burgess
@ 2024-05-14 13:30 ` Tom Tromey
  2024-05-14 15:52   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2024-05-14 13:30 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

Andrew> I believe that all of the places where tests add '-Wl,-soname,NAME' as
Andrew> a build option, are unnecessary.

Andrew> In this commit I propose we remove them all.

Andrew> As part of this change I've switched from calling gdb_compile_shlib
Andrew> directly, to instead call build_executable and adding the 'shlib'
Andrew> flag.

This looks good to me.  Thank you.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/testsuite: remove unnecessary -Wl, -soname, NAME build flags
  2024-05-14 13:30 ` [PATCH] gdb/testsuite: remove unnecessary -Wl, -soname, NAME " Tom Tromey
@ 2024-05-14 15:52   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2024-05-14 15:52 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Tom Tromey <tom@tromey.com> writes:

>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
> Andrew> I believe that all of the places where tests add '-Wl,-soname,NAME' as
> Andrew> a build option, are unnecessary.
>
> Andrew> In this commit I propose we remove them all.
>
> Andrew> As part of this change I've switched from calling gdb_compile_shlib
> Andrew> directly, to instead call build_executable and adding the 'shlib'
> Andrew> flag.
>
> This looks good to me.  Thank you.
> Approved-By: Tom Tromey <tom@tromey.com>

Pushed.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-14 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-14 10:38 [PATCH] gdb/testsuite: remove unnecessary -Wl,-soname,NAME build flags Andrew Burgess
2024-05-14 13:30 ` [PATCH] gdb/testsuite: remove unnecessary -Wl, -soname, NAME " Tom Tromey
2024-05-14 15:52   ` Andrew Burgess

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).