Skip to content

Commit 5c81f74

Browse files
authored
Merge pull request #4088 from casparvl/skip_fortran_wrappers_clang
Fix trying to generate RPATH wrappers for Clang
2 parents e276c51 + 3d3bfb0 commit 5c81f74

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

easybuild/tools/toolchain/toolchain.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,9 @@ def prepare_rpath_wrappers(self, rpath_filter_dirs=None, rpath_include_dirs=None
988988

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

993996
if orig_cmd:

test/framework/toolchain.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
from easybuild.tools.toolchain.mpi import get_mpi_cmd_template
5757
from easybuild.tools.toolchain.toolchain import env_vars_external_module
5858
from easybuild.tools.toolchain.utilities import get_toolchain, search_toolchain
59+
from easybuild.toolchains.compiler.clang import Clang
5960

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

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

2621+
# Check that we can create a wrapper for a toolchain for which self.compilers() returns 'None' for the Fortran
2622+
# compilers (i.e. Clang)
2623+
fake_clang = os.path.join(self.test_prefix, 'fake', 'clang')
2624+
write_file(fake_clang, '#!/bin/bash\necho "$@"')
2625+
adjust_permissions(fake_clang, stat.S_IXUSR)
2626+
tc_clang = Clang(name='Clang', version='1')
2627+
tc_clang.prepare_rpath_wrappers()
2628+
2629+
# Check that the clang wrapper is indeed in place
2630+
res = which('clang', retain_all=True)
2631+
# there should be at least 2 hits: the RPATH wrapper, and our fake 'clang' command (there may be real ones too)
2632+
self.assertTrue(len(res) >= 2)
2633+
self.assertTrue(tc_clang.is_rpath_wrapper(res[0]))
2634+
self.assertEqual(os.path.basename(res[0]), 'clang')
2635+
self.assertEqual(os.path.basename(os.path.dirname(res[0])), 'clang_wrapper')
2636+
self.assertFalse(any(tc_clang.is_rpath_wrapper(x) for x in res[1:]))
2637+
self.assertTrue(os.path.samefile(res[1], fake_clang))
2638+
# any other available 'clang' commands should not be a wrapper or our fake clang
2639+
self.assertFalse(any(os.path.samefile(x, fake_clang) for x in res[2:]))
2640+
26202641
# RPATH wrapper should be robust against Python environment variables & site-packages magic,
26212642
# so we set up a weird environment here to verify that
26222643
# (see https://github.com/easybuilders/easybuild-framework/issues/3421)

0 commit comments

Comments
 (0)