[libstdc++] Use LD_RUN_PATH when linking abi_check

Phil Edwards phil@jaj.com
Sun Sep 1 11:09:00 GMT 2002


First, I promised that I would rewrite the command string inside abi_check
to use string literals.  So we do that here.  More readable IMHO, more
maintainable.

More importantly, Donn Terry pointed out that abi_check was being loaded with
the installed libstdc++.so (say, in /usr/lib) at execution time.  Lately
I've been seeing the same problem on my system, with symbol mismatches.
It just means that since we're using the build tree's compiler and .so to
link the executable, we must take steps to use the same .so at runtime.

Rather than trying to find an -R/-rpath/-Wl,--rpath solution that would
work on all systems, let's just trust the linker to Do The Right Thing when
LD_RUN_PATH is present.  I've verified that this works for me, additional
reports would be welcome.

Tested on athlon_mp-pc-linux-gnu.  Applied to trunk.  I'll put this on
the 3.2 branch in a few days.


2002-09-01  Phil Edwards  <pme@gcc.gnu.org>

	* testsuite/Makefile.am:  Use LD_RUN_PATH when linking abi_check.
	Fix spelling in comment.
	* testsuite/Makefile.in:  Regenerate.
	* testsuite/abi_check.cc:  Use string literals to build 'cmd' rather
	than 'quote' and 'bslash'.


Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/Makefile.am,v
retrieving revision 1.10
diff -u -3 -p -r1.10 Makefile.am
--- testsuite/Makefile.am	23 Aug 2002 03:39:51 -0000	1.10
+++ testsuite/Makefile.am	1 Sep 2002 18:07:25 -0000
@@ -37,10 +37,11 @@ AM_RUNTESTFLAGS =
 RUNTESTFLAGS =
 
 ## CXX is actually a "C" compiler. These are real C++ programs.
-## Do the same thing as `testsuite_hooks --build-cxx`
+## Do the same thing as `testsuite_flags --build-cxx`
 CXX_fake = @glibcpp_CXX@ 
 CXX=`echo $(CXX_fake) | sed 's/xgcc/g++/g'`
 CXXLINK = \
+	LD_RUN_PATH=${LD_RUN_PATH:+$LD_RUN_PATH:}${glibcpp_builddir}/src/.libs\
 	$(LIBTOOL) --tag=CXX --mode=link $(CXX) \
 	$(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
 
Index: testsuite/abi_check.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/abi_check.cc,v
retrieving revision 1.4
diff -u -3 -p -r1.4 abi_check.cc
--- testsuite/abi_check.cc	23 Aug 2002 19:33:41 -0000	1.4
+++ testsuite/abi_check.cc	1 Sep 2002 18:07:25 -0000
@@ -249,8 +249,6 @@ int main(int argc, char** argv)
    "%s:%s\n", $4, $8; else if ($4 == "OBJECT") printf "%s:%s:%s\n", $4,
    $3, $8;}' | sort >& current_symbols.txt
    */
-  const char quote = '"';
-  const char bslash = '\\';
 
   // GNU binutils, somewhere after version 2.11.2, requires -W/--wide
   // to avoid default line truncation.  -W is not supported and
@@ -259,15 +257,13 @@ int main(int argc, char** argv)
     (system("readelf --help | grep -- --wide >/dev/null") == 0);
 
   ostringstream cmd;
-  cmd << "readelf -s " << (readelf_need_wide ? "-W " : "")
-      << test_lib << " | sed '/" << bslash 
-      << ".dynsym/,/^$/p;d' | egrep -v ' (LOCAL|UND) ' | "
-      << "awk '{ if ($4 == " << quote << "FUNC" << quote << "|| $4 == " 
-      << quote << "NOTYPE" << quote << ") printf " << quote << "%s:%s"
-      << bslash << "n" << quote << ", $4, $8; else if ($4 == " 
-      << quote << "OBJECT" << quote << ") printf " << quote
-      << "%s:%s:%s" << bslash << "n" << quote << ", $4, $3, $8;}' | "
-      << "sort > " << test_file << " 2>&1";
+  cmd << "readelf -s " << (readelf_need_wide ? "-W " : "") << test_lib
+      << " | sed '/\\.dynsym/,/^$/p;d' | egrep -v ' (LOCAL|UND) ' | "
+         "awk '{ if ($4 == \"FUNC\" || $4 == \"NOTYPE\") "
+                   "printf \"%s:%s\\n\", $4, $8; "
+                 "else if ($4 == \"OBJECT\") "
+                   "printf \"%s:%s:%s\\n\", $4, $3, $8;}' | sort > "
+      << test_file << " 2>&1";
   if (system(cmd.str().c_str()) != 0)
     {
       cerr << "Unable to generate the list of exported symbols." << endl;



More information about the Gcc-patches mailing list