Skip to content

Commit

Permalink
[SCons] Use RPATH for linking shared libraries
Browse files Browse the repository at this point in the history
Prevents issues with missing shared libraries at runtime on non-Windows
systems. Can be disabled by setting the SCons flag 'use_rpath_linkage=n'.
  • Loading branch information
Nick authored and speth committed Nov 30, 2018
1 parent ded7c67 commit f1239e3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ config_options = [
as symlinks.
""",
defaults.versionedSharedLibrary),
BoolVariable(
'use_rpath_linkage',
"""If enabled, link to all shared libraries using 'rpath', i.e., a fixed
run-time search path for dynamic library loading.""",
True),
EnumVariable(
'layout',
"""The layout of the directory structure. 'standard' installs files to
Expand All @@ -619,7 +624,7 @@ config_options = [
files in the subdirectory defined by 'prefix'. This layout is best
with a prefix like '/opt/cantera'. 'debian' installs to the stage
directory in a layout used for generating Debian packages.""",
defaults.fsLayout, ('standard','compact','debian')),
defaults.fsLayout, ('standard','compact','debian'))
]

opts.AddVariables(*config_options)
Expand Down Expand Up @@ -722,6 +727,9 @@ env['extra_lib_dirs'] = [d for d in env['extra_lib_dirs'].split(':') if d]
env.Append(CPPPATH=env['extra_inc_dirs'],
LIBPATH=env['extra_lib_dirs'])

if env['use_rpath_linkage']:
env.Append(RPATH=env['extra_lib_dirs'])

if env['CC'] == 'cl':
# embed manifest file
env['LINKCOM'] = [env['LINKCOM'],
Expand All @@ -734,6 +742,8 @@ if env['boost_inc_dir']:

if env['blas_lapack_dir']:
env.Append(LIBPATH=[env['blas_lapack_dir']])
if env['use_rpath_linkage']:
env.Append(RPATH=env['blas_lapack_dir'])

if env['system_sundials'] in ('y','default'):
if env['sundials_include']:
Expand All @@ -742,6 +752,8 @@ if env['system_sundials'] in ('y','default'):
if env['sundials_libdir']:
env.Append(LIBPATH=[env['sundials_libdir']])
env['system_sundials'] = 'y'
if env['use_rpath_linkage']:
env.Append(RPATH=env['sundials_libdir'])

# BLAS / LAPACK configuration
if env['blas_lapack_libs'] != '':
Expand Down

0 comments on commit f1239e3

Please sign in to comment.