Skip to content

Commit 6861a02

Browse files
committed
Fix and tested RPATH compilation
1 parent a8216f0 commit 6861a02

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

easybuild/easyblocks/l/llvmcore.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import shutil
4040

4141
from easybuild.framework.easyconfig import CUSTOM
42+
from easybuild.toolchains.compiler.clang import Clang
4243
from easybuild.tools import LooseVersion, run
4344
from easybuild.tools.build_log import EasyBuildError, print_msg, print_warning
4445
from easybuild.tools.config import build_option
@@ -489,11 +490,6 @@ def build_with_prev_stage(self, prev_dir, stage_dir):
489490
# orig_library_path = os.getenv('LIBRARY_PATH')
490491
orig_ld_library_path = os.getenv('LD_LIBRARY_PATH')
491492

492-
self._cmakeopts['CMAKE_C_COMPILER'] = os.path.join(prev_dir, 'bin/clang')
493-
self._cmakeopts['CMAKE_CXX_COMPILER'] = os.path.join(prev_dir, 'bin/clang++')
494-
self._cmakeopts['CMAKE_ASM_COMPILER'] = os.path.join(prev_dir, 'bin/clang')
495-
self._cmakeopts['CMAKE_ASM_COMPILER_ID'] = 'Clang'
496-
497493
self.add_cmake_opts()
498494

499495
bin_dir = os.path.join(prev_dir, 'bin')
@@ -514,8 +510,14 @@ def build_with_prev_stage(self, prev_dir, stage_dir):
514510

515511
# If building with rpath, create RPATH wrappers for the Clang compilers for stage 2 and 3
516512
if build_option('rpath'):
517-
my_toolchain = Toolchain(name='llvm', version='1')
518-
my_toolchain.prepare_rpath_wrappers()
513+
my_toolchain = Clang(name='Clang', version='1')
514+
my_toolchain.prepare_rpath_wrappers(
515+
rpath_include_dirs=[
516+
os.path.join(self.installdir, 'lib'),
517+
os.path.join(self.installdir, 'lib64'),
518+
os.path.join(self.installdir, lib_dir_runtime),
519+
]
520+
)
519521
self.log.info("Prepared rpath wrappers")
520522

521523
# add symlink for 'opt' to wrapper dir, since Clang expects it in the same directory
@@ -530,11 +532,22 @@ def build_with_prev_stage(self, prev_dir, stage_dir):
530532
# resulting in relocation errors).
531533
# See https://github.com/easybuilders/easybuild-easyblocks/pull/2799#issuecomment-1270621100
532534
# Here, we add -Wno-unused-command-line-argument to CXXFLAGS to avoid these warnings alltogether
533-
cflags = os.getenv('CFLAGS')
534-
cxxflags = os.getenv('CXXFLAGS')
535+
cflags = os.getenv('CFLAGS', '')
536+
cxxflags = os.getenv('CXXFLAGS', '')
535537
setvar('CFLAGS', "%s %s" % (cflags, '-Wno-unused-command-line-argument'))
536538
setvar('CXXFLAGS', "%s %s" % (cxxflags, '-Wno-unused-command-line-argument'))
537539

540+
# determine full path to clang/clang++ (which may be wrapper scripts in case of RPATH linking)
541+
clang = which('clang')
542+
clangxx = which('clang++')
543+
544+
self._cmakeopts['CMAKE_C_COMPILER'] = clang
545+
self._cmakeopts['CMAKE_CXX_COMPILER'] = clangxx
546+
self._cmakeopts['CMAKE_ASM_COMPILER'] = clang
547+
self._cmakeopts['CMAKE_ASM_COMPILER_ID'] = 'Clang'
548+
549+
self.add_cmake_opts()
550+
538551
change_dir(stage_dir)
539552
self.log.debug("Configuring %s", stage_dir)
540553
cmd = "cmake %s %s" % (self.cfg['configopts'], os.path.join(self.llvm_src_dir, 'llvm'))
@@ -558,7 +571,6 @@ def build_step(self, verbose=False, path=None):
558571
print_msg("Building stage 1/1")
559572
change_dir(self.llvm_obj_dir_stage1)
560573
super(EB_LLVMcore, self).build_step(verbose, path)
561-
# import shutil
562574
# change_dir(self.builddir)
563575
# print_msg("TESTING!!!: Copying from previosu build (REMOVE ME)")
564576
# shutil.rmtree('llvm.obj.1', ignore_errors=True)

0 commit comments

Comments
 (0)