diff options
author | Gabe Black <gabeblack@google.com> | 2019-02-20 17:43:15 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-02-21 22:37:21 +0000 |
commit | 0a7372633a9542cf5ed6709ac87f1adfe9e87171 (patch) | |
tree | 747840630e00a45a97142408361f0d987f6ddd54 /src | |
parent | 84a9094ef7fd8e322c2e532a54a37d8fae332724 (diff) | |
download | gem5-0a7372633a9542cf5ed6709ac87f1adfe9e87171.tar.xz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/SConscript | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/SConscript b/src/SConscript index 81b6cd3f1..ef7e670ab 100644 --- a/src/SConscript +++ b/src/SConscript @@ -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') |