@@ -249,7 +249,8 @@ def __init__(self, *args, **kwargs):
249
249
else :
250
250
self .final_projects = ['llvm' ]
251
251
self .final_runtimes = []
252
- self .gcc_prefix = None
252
+ self ._gcc_prefix = None
253
+ self ._gcc_root = None
253
254
self .runtimes_cmake_args = {
254
255
'CMAKE_C_COMPILER' : [],
255
256
'CMAKE_C_FLAGS' : [],
@@ -326,9 +327,8 @@ def __init__(self, *args, **kwargs):
326
327
else :
327
328
self .log .warning ("OpenMP offloading is included with the OpenMP runtime for LLVM < 19" )
328
329
329
- if self .cfg ['build_openmp_tools' ]:
330
- if not self .cfg ['build_openmp' ]:
331
- raise EasyBuildError ("Building OpenMP tools requires building OpenMP runtime" )
330
+ if self .cfg ['build_openmp_tools' ] and not self .cfg ['build_openmp' ]:
331
+ raise EasyBuildError ("Building OpenMP tools requires building OpenMP runtime" )
332
332
333
333
if self .cfg ['usepolly' ]:
334
334
self .final_projects .append ('polly' )
@@ -467,6 +467,23 @@ def __init__(self, *args, **kwargs):
467
467
self ._cmakeopts = {}
468
468
self ._cfgopts = list (filter (None , self .cfg .get ('configopts' , '' ).split ()))
469
469
470
+ @property
471
+ def gcc_prefix (self ):
472
+ """Return the GCC prefix (versioned folder in <gcc_root>/lib)."""
473
+ self ._set_gcc_prefix_probs ()
474
+ return self ._gcc_prefix
475
+
476
+ @property
477
+ def gcc_root (self ):
478
+ """Return the GCC root folder from dependencies/toolchain."""
479
+ self ._set_gcc_prefix_probs ()
480
+ return self ._gcc_root
481
+
482
+ def _set_gcc_prefix_probs (self ):
483
+ """Set properties of currently loaded GCC installation"""
484
+ self ._gcc_root , self ._gcc_prefix = self ._get_gcc_prefix ()
485
+ self .log .debug ("Using %s as the gcc install location" , self ._gcc_prefix )
486
+
470
487
@property
471
488
def llvm_src_dir (self ):
472
489
"""Return root source directory of LLVM (containing all components)"""
@@ -587,25 +604,6 @@ def _get_gcc_libpath(strict=False):
587
604
return ''
588
605
return os .path .join (gcc_root , 'lib64' )
589
606
590
- def _set_gcc_prefix (self ):
591
- """Set the GCC prefix for the build."""
592
- if self .gcc_prefix is None :
593
- gcc_root , gcc_prefix = self ._get_gcc_prefix ()
594
-
595
- # --gcc-toolchain and --gcc-install-dir for flang are not supported before LLVM 19
596
- # https://github.com/llvm/llvm-project/pull/87360
597
- if LooseVersion (self .version ) < LooseVersion ('19' ):
598
- self .log .debug ("Using GCC_INSTALL_PREFIX" )
599
- general_opts ['GCC_INSTALL_PREFIX' ] = gcc_root
600
- else :
601
- # See https://github.com/llvm/llvm-project/pull/85891#issuecomment-2021370667
602
- self .log .debug ("Using '--gcc-install-dir' in CMAKE_C_FLAGS and CMAKE_CXX_FLAGS" )
603
- self .runtimes_cmake_args ['CMAKE_C_FLAGS' ] += ['--gcc-install-dir=%s' % gcc_prefix ]
604
- self .runtimes_cmake_args ['CMAKE_CXX_FLAGS' ] += ['--gcc-install-dir=%s' % gcc_prefix ]
605
-
606
- self .gcc_prefix = gcc_prefix
607
- self .log .debug ("Using %s as the gcc install location" , self .gcc_prefix )
608
-
609
607
def _set_dynamic_linker (self ):
610
608
"""Set the dynamic linker for the build if not the default one."""
611
609
if self .sysroot :
@@ -776,15 +774,24 @@ def configure_step(self):
776
774
]
777
775
apply_regex_substitutions (lit_cfg_file , regex_subs )
778
776
779
- self ._set_gcc_prefix ()
777
+ # --gcc-toolchain and --gcc-install-dir for flang are not supported before LLVM 19
778
+ # https://github.com/llvm/llvm-project/pull/87360
779
+ if LooseVersion (self .version ) < '19' :
780
+ self .log .debug ("Using GCC_INSTALL_PREFIX" )
781
+ general_opts ['GCC_INSTALL_PREFIX' ] = self .gcc_root
782
+ else :
783
+ # See https://github.com/llvm/llvm-project/pull/85891#issuecomment-2021370667
784
+ self .log .debug ("Using '--gcc-install-dir' in CMAKE_C_FLAGS and CMAKE_CXX_FLAGS" )
785
+ self .runtimes_cmake_args ['CMAKE_C_FLAGS' ] += [f'--gcc-install-dir={ self .gcc_prefix } ' ]
786
+ self .runtimes_cmake_args ['CMAKE_CXX_FLAGS' ] += [f'--gcc-install-dir={ self .gcc_prefix } ' ]
780
787
781
788
# If we don't want to build with CUDA (not in dependencies) trick CMakes FindCUDA module into not finding it by
782
789
# using the environment variable which is used as-is and later checked for a falsy value when determining
783
790
# whether CUDA was found
784
791
if not get_software_root ('CUDA' ):
785
792
setvar ('CUDA_NVCC_EXECUTABLE' , 'IGNORE' )
786
793
787
- if self .cfg ['build_openmp_offload' ] and LooseVersion ( '19' ) <= LooseVersion (self .version ) < LooseVersion ( '20' ) :
794
+ if self .cfg ['build_openmp_offload' ] and '19' <= LooseVersion (self .version ) < '20' :
788
795
gpu_archs = []
789
796
gpu_archs += ['sm_%s' % cc for cc in self .cuda_cc ]
790
797
gpu_archs += self .amd_gfx
@@ -858,7 +865,6 @@ def configure_step3(self):
858
865
859
866
def _create_compiler_config_file (self , installdir ):
860
867
"""Create a config file for the compiler to point to the correct GCC installation."""
861
- self ._set_gcc_prefix ()
862
868
863
869
# This is only needed for LLVM >= 19, as the --gcc-install-dir option was introduced then
864
870
if LooseVersion (self .version ) < LooseVersion ('19' ):
@@ -1491,7 +1497,6 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, extension=F
1491
1497
'dirs' : check_dirs ,
1492
1498
}
1493
1499
1494
- self ._set_gcc_prefix ()
1495
1500
if lib_dir_runtime :
1496
1501
# Required for 'clang -v' to work if linked to LLVM runtimes
1497
1502
with _wrap_env (ld_path = os .path .join (self .installdir , lib_dir_runtime )):
0 commit comments