Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Nathan Froyd <froydnj@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [PATCH,testsuite] fix remote-host testing for tests using shared libraries
Date: Thu, 12 Nov 2009 15:44:00 -0000	[thread overview]
Message-ID: <20091112154430.GK31393@codesourcery.com> (raw)

The patch below fixes various remote-host failures for tests that use
shared libraries.  In normal testing, we link shared libraries using
absolute paths, so it's not a problem to find the libraries at runtime.
However, in remote-host testing, shared libraries are copied to the
remote host and linked against using relative paths.  Therefore, we need
to specify -rpath to ensure that the library is found at runtime.  The
patch just moves a bit of logic around and adds a remote_host check.

Tested with cross to powerpc-linux-gnu on mingw32 host.  OK to commit?

-Nathan

	* lib/gdb.exp (gdb_compile): Also set rpath for shlib=, on a
	remote host.

Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.126
diff -u -u -r1.126 gdb.exp
--- lib/gdb.exp	10 Nov 2009 20:54:55 -0000	1.126
+++ lib/gdb.exp	12 Nov 2009 15:35:42 -0000
@@ -1734,6 +1734,7 @@
     # "shlib=librarypath" in OPTIONS.
     set new_options ""
     set shlib_found 0
+    set shlib_load 0
     foreach opt $options {
         if [regexp {^shlib=(.*)} $opt dummy_var shlib_name] {
             if [test_compiler_info "xlc-*"] {
@@ -1755,22 +1756,33 @@
 		}
             }
 	} elseif { $opt == "shlib_load" } {
-	    if { ([istarget "*-*-mingw*"]
-		  || [istarget *-*-cygwin*]
-		  || [istarget *-*-pe*]
-		  || [istarget arm*-*-symbianelf*]
-		  || [istarget hppa*-*-hpux*])} {
-		# Do not need anything.
-	    } elseif { [istarget *-*-openbsd*] } {
-		lappend new_options "additional_flags=-Wl,-rpath,${outdir}"
-	    } else {
-		lappend new_options "libs=-ldl"
-		lappend new_options "additional_flags=-Wl,-rpath,\\\$ORIGIN"
-	    }
+	    set shlib_load 1
         } else {
             lappend new_options $opt
         }
     }
+
+    # We typically link to shared libraries using an absolute path, and
+    # that's how they are found at runtime.  If we are going to
+    # dynamically load one by basename, we must specify rpath.  If we
+    # are using a remote host, DejaGNU will link to the shared library
+    # using a relative path, so again we must specify an rpath.
+    if { $shlib_load || ($shlib_found && [is_remote host]) } {
+	if { ([istarget "*-*-mingw*"]
+	      || [istarget *-*-cygwin*]
+	      || [istarget *-*-pe*]
+	      || [istarget arm*-*-symbianelf*]
+	      || [istarget hppa*-*-hpux*])} {
+	    # Do not need anything.
+	} elseif { [istarget *-*-openbsd*] } {
+	    lappend new_options "additional_flags=-Wl,-rpath,${outdir}"
+	} else {
+	    if { $shlib_load } {
+		lappend new_options "libs=-ldl"
+	    }
+	    lappend new_options "additional_flags=-Wl,-rpath,\\\$ORIGIN"
+	}
+    }
     set options $new_options
 
     if [target_info exists gdb_stub] {


             reply	other threads:[~2009-11-12 15:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-12 15:44 Nathan Froyd [this message]
2009-11-12 15:55 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091112154430.GK31393@codesourcery.com \
    --to=froydnj@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox