Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RPATH related issues #1243

Merged
merged 3 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion interfaces/cython/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import site
vars = get_config_vars()
vars["plat"] = get_platform()
vars["numpy_include"] = numpy.get_include()
vars["site_packages"] = site.getsitepackages()
vars["site_packages"] = [d for d in site.getsitepackages() if d.endswith("-packages")]
vars["user_site_packages"] = site.getusersitepackages()
print(json.dumps(vars))
"""
Expand Down
2 changes: 1 addition & 1 deletion platform/posix/Cantera.mak.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CANTERA_CORE_INCLUDES=-I$(CANTERA_INSTALL_ROOT)/include
CANTERA_EXTRA_INCLUDES=@mak_extra_includes@

# Required Cantera libraries
CANTERA_CORE_LIBS=@mak_threadflags@ -L@ct_libdir@ @mak_corelibs@
CANTERA_CORE_LIBS=@mak_threadflags@ -L@ct_libdir@ @mak_corelibs@ -Wl,-rpath,@ct_libdir@

CANTERA_CORE_LIBS_DEP = @ct_libdir@/libcantera.a

Expand Down
16 changes: 9 additions & 7 deletions platform/posix/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ pc_cflags = list(localenv['CXXFLAGS'])

localenv['mak_corelibs'] = ' '.join('-l' + lib for lib in localenv['cantera_libs'])

localenv['mak_extra_includes'] = ' '.join('-I%s' % s for s in localenv['extra_inc_dirs'])
pc_incdirs.extend(localenv['extra_inc_dirs'])
localenv["mak_extra_includes"] = " ".join(
f"-I{dir}" for dir in localenv["extra_inc_dirs"])
pc_incdirs.extend(localenv["extra_inc_dirs"])

localenv['mak_extra_libdirs'] = ' '.join('-L%s' % s for s in localenv['extra_lib_dirs'])
pc_libdirs.extend(localenv['extra_lib_dirs'])
localenv["mak_extra_libdirs"] = " ".join(
f"-L{dir} -Wl,-rpath,{dir}" for dir in localenv["extra_lib_dirs"])
pc_libdirs.extend(localenv["extra_lib_dirs"])

localenv['mak_stdlib'] = ''.join('-l' + lib for lib in env['cxx_stdlib'])

if localenv['system_sundials']:
# Add links to the sundials environment
localenv['mak_sundials_libs'] = ' '.join('-l%s' % s
for s in localenv['sundials_libs'])
localenv["mak_sundials_libs"] = " ".join(
f"-l{lib}" for lib in localenv["sundials_libs"])
if localenv['sundials_libdir']:
localenv['mak_sundials_libdir'] = '-L' + localenv['sundials_libdir']
pc_libdirs.append(localenv['sundials_libdir'])
Expand All @@ -67,7 +69,7 @@ else:
localenv['mak_boost_include'] = ''

# Handle BLAS/LAPACK linkage
blas_lapack_libs = ' '.join('-l%s' % s for s in localenv['blas_lapack_libs'])
blas_lapack_libs = " ".join(f"-l{lib}" for lib in localenv["blas_lapack_libs"])
if localenv['blas_lapack_dir']:
localenv['mak_blas_lapack_libs'] = '-L{} {}'.format(localenv['blas_lapack_dir'],
blas_lapack_libs)
Expand Down
2 changes: 2 additions & 0 deletions samples/cxx/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS})
# TODO: Accelerate is only used if other BLAS/LAPACK are not used
if env["OS"] == "Darwin":
localenv["cmake_extra"] += "find_library(ACCELERATE_FRAMEWORK Accelerate)"
localenv.Append(
LINKFLAGS=env.subst("${RPATHPREFIX}${ct_libdir}${RPATHSUFFIX}"))

localenv.Append(LIBS=env['cantera_libs'])
localenv.Prepend(CPPPATH=['#include'])
Expand Down
5 changes: 5 additions & 0 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@ if localenv['layout'] != 'debian':
lib = build(localenv.SharedLibrary(sharedName, libraryTargets,
SPAWN=get_spawn(localenv)))
install('$inst_libdir', lib)

if env["OS"] == "Darwin":
localenv.AddPostAction(lib,
Action(f"install_name_tool -id @rpath/{lib[0].name} {lib[0].relpath}"))

env['cantera_shlib'] = lib
localenv.Depends(lib, localenv['config_h_target'])