[Xorp-cvs] SF.net SVN: xorp:[11626] trunk/xorp/SConstruct

bms_fbsd at users.sourceforge.net bms_fbsd at users.sourceforge.net
Sat Nov 28 16:03:38 PST 2009


Revision: 11626
          http://xorp.svn.sourceforge.net/xorp/?rev=11626&view=rev
Author:   bms_fbsd
Date:     2009-11-29 00:03:38 +0000 (Sun, 29 Nov 2009)

Log Message:
-----------
Commit top level support for rtld ORIGIN as an experimental build
feature. Default to disabled.

ORIGIN support allows relative paths to shared libraries
to be embedded in binaries, instead of absolute ones. XORP uses
a lot of shared libraries of its own, so may benefit from this support.

Unfortunately, RPATH ORIGIN support hasn't been MFC'ed yet to FreeBSD
7.2, so I cannot fully test this change just now.

Also, because we currently install binaries in various weird and
wonderful places which roughly match to the layout of the source tree,
RPATH would need to be set individually for each set of binaries with
a system location.

The use of os.path.relpath() also requires Python 2.6 to run the
SConstruct when this feature is in use.

Modified Paths:
--------------
    trunk/xorp/SConstruct

Modified: trunk/xorp/SConstruct
===================================================================
--- trunk/xorp/SConstruct	2009-11-28 23:37:15 UTC (rev 11625)
+++ trunk/xorp/SConstruct	2009-11-29 00:03:38 UTC (rev 11626)
@@ -63,7 +63,7 @@
 vars.AddVariables(
     BoolVariable('shared', 'build with shared libraries', True),
     BoolVariable('strip',  'strip executables and libraries when installed', False),
-    #BoolVariable('use_rtld_origin', 'Use ORIGIN in dynamically linked programs ', False),
+    BoolVariable('rtld_origin', 'Use ORIGIN in dynamically linked programs', False),
     BoolVariable('ignore_check_errors', 'Ignore errors when building tests', False),
     BoolVariable('debug_stl',  'Build with checked STL operations', False),
     BoolVariable('debug_msg',  'Build with debug messages', False),
@@ -163,6 +163,7 @@
         print gnutoolwarning % 'ld linker'
     env['SHAREDLIBS'] = "defined"
 print 'Shared libraries: ', env.has_key('SHAREDLIBS')
+print 'Use rtld ORIGIN:  ', env['rtld_origin']
 
 # AUTOTEST_SKIP_ERRORS is SetDefault() by site_scons/site_tools/autotest.py,
 # so print its value here.
@@ -452,11 +453,31 @@
     ])
 
 # Shared libraries are installed in $exec_prefix/lib by default.
-env.AppendUnique(RPATH = [
-    '$libdir',
-    ])
+#
+# Experimental feature: if rtld_origin is True, the linker will
+# be passed a relative RPATH. The ORIGIN flag will be enabled for all
+# dynamically linked binaries, instead of hardcoding an absolute RPATH.
+#
+# XXX This may not be correct for all binaries. Some binaries still
+# get installed in locations other than $bindir.
+if env.has_key('SHAREDLIBS'):
+    if env['rtld_origin']:
+	# XXX Will this pass it to the linker correctly?
+	# In most cases the C++ compiler is used as the link tool.
+	#env.PrependUnique( LINKFLAGS = [ '-Wl,-z,origin' ] )
+	env.PrependUnique( LINKFLAGS = Split('-z origin') )
+	rellibdir = os.path.relpath(env.Dir('$libdir').abspath,
+				    env.Dir('$bindir').abspath)
+	env.AppendUnique(RPATH = [
+	    env.Literal(os.path.join('\\$$ORIGIN', rellibdir))
+	])
+    else:
+	env.AppendUnique(RPATH = [
+	    '$libdir',
+	])
 
-# Export dynamic symbols in executables for runtime backtraces w/o GDB.
+# Export global symbols as dynamic in executables for runtime backtraces
+# w/o GDB or corefiles in production deployments.
 # NOTE: GNU ld specific flag.
 env.AppendUnique(LINKFLAGS = [
     '-rdynamic',


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Xorp-cvs mailing list