scons: Add a convenience method to set RPATH for local libraries.
When linking in a dynamic library which is in the gem5 build directory, it's useful to set RPATH so that you don't have to set LD_LIBRARY_PATH when you run gem5 so that the dynamic linker can find it. Since it's tricky and not entirely obvious how to set up those paths correctly, this change adds a small convenience function which does that for you. It also handles situations where the same dynamic library may be linked into different binaries in different directories which each need a different relative RPATH. It does that by letting the environment for each binary set a construction variable which says how to get from that particular binary back to the build directory. This helper method then sets RPATH to start at $ORIGIN (the binary), to follow that relative path to the variant build directory, and then the per-library but not per-binary path to the library's directory. This change also adds the -z origin linker flag which makes the linker handle $ORIGIN properly. Change-Id: I45f4d72cd14396a73e0b963cea6a39d9bfb7f984 Reviewed-on: https://gem5-review.googlesource.com/c/16566 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
@@ -449,6 +449,10 @@ class Executable(object):
|
||||
if objs is None:
|
||||
objs = self.srcs_to_objs(env, self.sources)
|
||||
|
||||
env = env.Clone()
|
||||
env['BIN_RPATH_PREFIX'] = os.path.relpath(
|
||||
env['BUILDDIR'], self.path(env).dir.abspath)
|
||||
|
||||
if env['STRIP_EXES']:
|
||||
stripped = self.path(env)
|
||||
unstripped = env.File(str(stripped) + '.unstripped')
|
||||
|
||||
Reference in New Issue
Block a user