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 trying to generate RPATH wrappers for Clang #4088

Merged
merged 5 commits into from
Oct 18, 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
3 changes: 3 additions & 0 deletions easybuild/tools/toolchain/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,9 @@ def prepare_rpath_wrappers(self, rpath_filter_dirs=None, rpath_include_dirs=None

# create wrappers
for cmd in nub(c_comps + fortran_comps + ['ld', 'ld.gold', 'ld.bfd']):
# Not all toolchains have fortran compilers (e.g. Clang), in which case they are 'None'
if cmd is None:
continue
orig_cmd = which(cmd)

if orig_cmd:
Expand Down
21 changes: 21 additions & 0 deletions test/framework/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from easybuild.tools.toolchain.mpi import get_mpi_cmd_template
from easybuild.tools.toolchain.toolchain import env_vars_external_module
from easybuild.tools.toolchain.utilities import get_toolchain, search_toolchain
from easybuild.toolchains.compiler.clang import Clang

easybuild.tools.toolchain.compiler.systemtools.get_compiler_family = lambda: st.POWER

Expand Down Expand Up @@ -2617,6 +2618,26 @@ def test_toolchain_prepare_rpath(self):
# any other available 'g++' commands should not be a wrapper or our fake g++
self.assertFalse(any(os.path.samefile(x, fake_gxx) for x in res[2:]))

# Check that we can create a wrapper for a toolchain for which self.compilers() returns 'None' for the Fortran
# compilers (i.e. Clang)
fake_clang = os.path.join(self.test_prefix, 'fake', 'clang')
write_file(fake_clang, '#!/bin/bash\necho "$@"')
adjust_permissions(fake_clang, stat.S_IXUSR)
tc_clang = Clang(name='Clang', version='1')
tc_clang.prepare_rpath_wrappers()

# Check that the clang wrapper is indeed in place
res = which('clang', retain_all=True)
# there should be at least 2 hits: the RPATH wrapper, and our fake 'clang' command (there may be real ones too)
self.assertTrue(len(res) >= 2)
self.assertTrue(tc_clang.is_rpath_wrapper(res[0]))
self.assertEqual(os.path.basename(res[0]), 'clang')
self.assertEqual(os.path.basename(os.path.dirname(res[0])), 'clang_wrapper')
self.assertFalse(any(tc_clang.is_rpath_wrapper(x) for x in res[1:]))
self.assertTrue(os.path.samefile(res[1], fake_clang))
# any other available 'clang' commands should not be a wrapper or our fake clang
self.assertFalse(any(os.path.samefile(x, fake_clang) for x in res[2:]))

# RPATH wrapper should be robust against Python environment variables & site-packages magic,
# so we set up a weird environment here to verify that
# (see https://github.com/easybuilders/easybuild-framework/issues/3421)
Expand Down