Use absolute paths to lib and lib64 icw $ORIGIN for the RPATH#2358
Use absolute paths to lib and lib64 icw $ORIGIN for the RPATH#2358boegel merged 10 commits intoeasybuilders:developfrom
Conversation
… $ORIGIN to RPATH. This works much better with shared libraries in non-standard locations, esp. python packages
…ldir is defined. Shuffled tests to match the changed rpath mechanism.
|
|
||
| # prepare toolchain: load toolchain module and dependencies, set up build environment | ||
| self.toolchain.prepare(self.cfg['onlytcmod'], silent=self.silent, rpath_filter_dirs=self.rpath_filter_dirs) | ||
| self.toolchain.prepare(self.cfg['onlytcmod'], silent=self.silent, rpath_filter_dirs=self.rpath_filter_dirs, rpath_include_dirs=self.rpath_include_dirs) |
There was a problem hiding this comment.
line too long (max 120 chars), so wrap it, like so:
self.toolchain.prepare(self.cfg['onlytcmod'], silent=self.silent, rpath_filter_dirs=self.rpath_filter_dirs,
rpath_include_dirs=self.rpath_include_dirs)| cmd_args_rpath = [] | ||
| if rpath_include: | ||
| for path in rpath_include: | ||
| cmd_args_rpath.append(flag_prefix + '-rpath=%s' % path) |
There was a problem hiding this comment.
This can be collapsed to a single line, since we're sure rpath_include is a list (possibly empty, but that's fine):
cmd_args_rpath = [flag_prefix + '-rpath=%s' % inc for inc in rpath_include]| if not rpath_include: | ||
| rpath_include = [] | ||
| else: | ||
| rpath_include = rpath_include.split(',') |
There was a problem hiding this comment.
positive logic is easier to follow (and maybe worth a comment to clarify possible None value):
if rpath_include:
rpath_include = rpath_include.split(',')
else: # take into account that rpath_include may be None
rpath_include = []| rpath_include = ','.join(['%s' % d for d in rpath_include_dirs or []]) | ||
| self.log.debug("Combined RPATH includes: '%s'", rpath_include) | ||
|
|
||
|
|
There was a problem hiding this comment.
avoid duplicate blank line, just one is enough
| for path in rpath_include: | ||
| cmd_args_rpath.append(flag_prefix + '-rpath=%s' % path) | ||
|
|
||
|
|
There was a problem hiding this comment.
avoid duplicate blank line, just one is enough
|
|
||
| # figure out list of patterns to use in rpath include | ||
| # rpath_include = build_option('rpath_include') | ||
| rpath_include = ','.join(['%s' % d for d in rpath_include_dirs or []]) |
There was a problem hiding this comment.
'%s' % d doesn't do much, since the directories are already strings, no?
So this is equivalent with:
rpath_include = ','.join(rpath_include_dirs or [])| 'orig_cmd': orig_cmd, | ||
| 'python': sys.executable, | ||
| 'rpath_args_py': rpath_args_py, | ||
| 'rpath_include': rpath_include, |
There was a problem hiding this comment.
Please keep this sorted alphabetically (i comes after f ;-)).
| self.log.debug("Combined RPATH filter: '%s'", rpath_filter) | ||
|
|
||
| # figure out list of patterns to use in rpath include | ||
| # rpath_include = build_option('rpath_include') |
| expected = '\n'.join([ | ||
| "CMD_ARGS=('foo.o')", | ||
| "RPATH_ARGS='--disable-new-dtags -rpath=$ORIGIN/../lib -rpath=$ORIGIN/../lib64'", | ||
| "RPATH_ARGS='--disable-new-dtags -rpath=%s/lib -rpath=%s/lib64 -rpath=$ORIGIN'" % (self.test_prefix, self.test_prefix), |
There was a problem hiding this comment.
"RPATH_ARGS='--disable-new-dtags -rpath=%(p)s/lib -rpath=%(p)s/lib64 -rpath=$ORIGIN'" % {'p': self.test_prefix},|
|
||
| # simplest possible compiler command | ||
| out, ec = run_cmd("%s gcc '' -c foo.c" % script, simple=False) | ||
| out, ec = run_cmd("%s gcc '' '%s/lib,%s/lib64,$ORIGIN' -c foo.c" % (script, self.test_prefix, self.test_prefix), simple=False) |
There was a problem hiding this comment.
Construct the argument separately, since you're using it in multiple tests.
This also avoids making the line too long.
rpath_inc = '%(prefix)s/lib,%(prefix)s/lib64,$ORIGIN' % {'prefix': self.test_prefix}
out, ec = run_cmd("%s gcc '' '%s' -c foo.c" % (script, rpath_inc), simple=False)And then reuse rpath_inc below too.
| # see also https://linux.die.net/man/8/ld-linux; | ||
| self.rpath_include_dirs.append(self.installdir+'/lib') | ||
| self.rpath_include_dirs.append(self.installdir+'/lib64') | ||
| self.rpath_include_dirs.append('$ORIGIN') |
There was a problem hiding this comment.
@jdonners Shouldn't we also retain $ORIGIN/../lib and $ORIGIN/../lib64 in here? That's not necessarily the same as <installdir>/lib and <installdir>/lib64, is it?
There was a problem hiding this comment.
@boegel indeed they're not necessarily the same. Conservatively, I thought it's better to add fewer paths to the RPATH. I'd expect that packages that install shared objects in non-standard locations, also somehow make these directories findable in some wrapper scripts. There's no guarantee that that is indeed the case. On the other side, it still is an experimental feature..
There was a problem hiding this comment.
For now, I'd stick to also included $ORIGIIN/../lib and $ORIGIN/../lib64.
It indeed makes sense to limit the amount of paths we inject, but 3 or 5 isn't going to make a big difference I think.
The order may be important though (w.r.t. speeding up the loader): we should probably list the most common locations first?
…ected by RPATH compiler wrapper
enhance test to catch fixed bug + re-instate injection of $ORIGIN/../lib and $ORIGIN/../lib64
|
Going in, thanks @jdonners! |
Add %installdir/lib, %installdir/lib64 and $ORIGIN to RPATH. This works much better with shared libraries in non-standard locations, esp. python packages. See the discussion in #2076. This patch has been tested for building Tensorflow+python (using foss-2016b) and VTK (for intel-2016b) from scratch. Works without hacks in the easyconfig.