Skip to content

Commit 2e5a227

Browse files
authored
Merge pull request #3952 from Crivella/fix-LLVM_sysroot_sanity
LLVM: Run dynamic linker check only if `clang` is being built
2 parents 35461d4 + c1c31c5 commit 2e5a227

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

easybuild/easyblocks/l/llvm.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,8 @@ def _sanity_check_gcc_prefix(compilers, gcc_prefix, installdir):
14871487

14881488
def _sanity_check_dynamic_linker(self):
14891489
"""Check if the dynamic linker is correct."""
1490-
if self.sysroot:
1490+
sysroot = build_option('sysroot')
1491+
if sysroot and 'clang' in self.final_projects:
14911492
# compile & test trivial C program to verify that works
14921493
test_fn = 'test123'
14931494
test_txt = '#include <stdio.h>\n'
@@ -1503,7 +1504,7 @@ def _sanity_check_dynamic_linker(self):
15031504
out = res.output
15041505

15051506
# Check if the dynamic linker is set to the sysroot
1506-
if self.sysroot not in out:
1507+
if sysroot not in out:
15071508
error_msg = f"Dynamic linker is not set to the sysroot '{self.sysroot}'"
15081509
raise EasyBuildError(error_msg)
15091510

@@ -1537,6 +1538,14 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, *args, **kw
15371538
else:
15381539
print_warning("Unknown CPU architecture (%s) for OpenMP and runtime libraries check!" % arch, log=self.log)
15391540

1541+
extra_modules = kwargs.get('extra_modules', [])
1542+
# binutils is required for the linking step in the `llvm-config --link-static` test
1543+
extra_modules.extend(
1544+
d['short_mod_name'] for d in self.cfg.dependencies() if d['name'] == 'binutils'
1545+
)
1546+
# Perform the module loading for the sanity check here to ensure that gcc_prefix can be checked
1547+
self.sanity_check_load_module(extra_modules=extra_modules)
1548+
15401549
check_files = []
15411550
check_bin_files = []
15421551
check_lib_files = []
@@ -1721,9 +1730,6 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, *args, **kw
17211730
# Here, we add the system libraries LLVM expects to find
17221731
minimal_cpp_compiler_cmd += "$(llvm-config --link-static --system-libs all)"
17231732
custom_commands.append(minimal_cpp_compiler_cmd)
1724-
# binutils is required for the linking step
1725-
kwargs.setdefault('extra_modules', []).extend(
1726-
d['short_mod_name'] for d in self.cfg.dependencies() if d['name'] == 'binutils')
17271733

17281734
return super().sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands, *args, **kwargs)
17291735

0 commit comments

Comments
 (0)