@@ -244,7 +244,8 @@ def __init__(self, *args, **kwargs):
244
244
else :
245
245
self .final_projects = ['llvm' ]
246
246
self .final_runtimes = []
247
- self .gcc_prefix = None
247
+ self ._gcc_prefix = None
248
+ self ._gcc_root = None
248
249
self .runtimes_cmake_args = {
249
250
'CMAKE_C_COMPILER' : [],
250
251
'CMAKE_C_FLAGS' : [],
@@ -321,9 +322,8 @@ def __init__(self, *args, **kwargs):
321
322
else :
322
323
self .log .warning ("OpenMP offloading is included with the OpenMP runtime for LLVM < 19" )
323
324
324
- if self .cfg ['build_openmp_tools' ]:
325
- if not self .cfg ['build_openmp' ]:
326
- raise EasyBuildError ("Building OpenMP tools requires building OpenMP runtime" )
325
+ if self .cfg ['build_openmp_tools' ] and not self .cfg ['build_openmp' ]:
326
+ raise EasyBuildError ("Building OpenMP tools requires building OpenMP runtime" )
327
327
328
328
if self .cfg ['usepolly' ]:
329
329
self .final_projects .append ('polly' )
@@ -462,6 +462,23 @@ def __init__(self, *args, **kwargs):
462
462
self ._cmakeopts = {}
463
463
self ._cfgopts = list (filter (None , self .cfg .get ('configopts' , '' ).split ()))
464
464
465
+ @property
466
+ def gcc_prefix (self ):
467
+ """Return the GCC prefix (versioned folder in <gcc_root>/lib)."""
468
+ self ._set_gcc_prefix_probs ()
469
+ return self ._gcc_prefix
470
+
471
+ @property
472
+ def gcc_root (self ):
473
+ """Return the GCC root folder from dependencies/toolchain."""
474
+ self ._set_gcc_prefix_probs ()
475
+ return self ._gcc_root
476
+
477
+ def _set_gcc_prefix_probs (self ):
478
+ """Set properties of currently loaded GCC installation"""
479
+ self ._gcc_root , self ._gcc_prefix = self ._get_gcc_prefix ()
480
+ self .log .debug ("Using %s as the gcc install location" , self ._gcc_prefix )
481
+
465
482
@property
466
483
def llvm_src_dir (self ):
467
484
"""Return root source directory of LLVM (containing all components)"""
@@ -572,24 +589,6 @@ def _get_gcc_libpath(strict=False):
572
589
return ''
573
590
return os .path .join (gcc_root , 'lib64' )
574
591
575
- def _set_gcc_prefix (self ):
576
- """Set the GCC prefix for the build."""
577
- if self .gcc_prefix is None :
578
- gcc_root , gcc_prefix = self ._get_gcc_prefix ()
579
-
580
- # --gcc-toolchain and --gcc-install-dir for flang are not supported before LLVM 19
581
- # https://github.com/llvm/llvm-project/pull/87360
582
- if LooseVersion (self .version ) < LooseVersion ('19' ):
583
- self .log .debug ("Using GCC_INSTALL_PREFIX" )
584
- general_opts ['GCC_INSTALL_PREFIX' ] = gcc_root
585
- else :
586
- # See https://github.com/llvm/llvm-project/pull/85891#issuecomment-2021370667
587
- self .log .debug ("Using '--gcc-install-dir' in CMAKE_C_FLAGS and CMAKE_CXX_FLAGS" )
588
- self .runtimes_cmake_args ['CMAKE_C_FLAGS' ] += ['--gcc-install-dir=%s' % gcc_prefix ]
589
- self .runtimes_cmake_args ['CMAKE_CXX_FLAGS' ] += ['--gcc-install-dir=%s' % gcc_prefix ]
590
-
591
- self .gcc_prefix = gcc_prefix
592
- self .log .debug ("Using %s as the gcc install location" , self .gcc_prefix )
593
592
594
593
def _set_dynamic_linker (self ):
595
594
"""Set the dynamic linker for the build if not the default one."""
@@ -761,15 +760,24 @@ def configure_step(self):
761
760
]
762
761
apply_regex_substitutions (lit_cfg_file , regex_subs )
763
762
764
- self ._set_gcc_prefix ()
763
+ # --gcc-toolchain and --gcc-install-dir for flang are not supported before LLVM 19
764
+ # https://github.com/llvm/llvm-project/pull/87360
765
+ if LooseVersion (self .version ) < '19' :
766
+ self .log .debug ("Using GCC_INSTALL_PREFIX" )
767
+ general_opts ['GCC_INSTALL_PREFIX' ] = self .gcc_root
768
+ else :
769
+ # See https://github.com/llvm/llvm-project/pull/85891#issuecomment-2021370667
770
+ self .log .debug ("Using '--gcc-install-dir' in CMAKE_C_FLAGS and CMAKE_CXX_FLAGS" )
771
+ self .runtimes_cmake_args ['CMAKE_C_FLAGS' ] += [f'--gcc-install-dir={ self .gcc_prefix } ' ]
772
+ self .runtimes_cmake_args ['CMAKE_CXX_FLAGS' ] += [f'--gcc-install-dir={ self .gcc_prefix } ' ]
765
773
766
774
# If we don't want to build with CUDA (not in dependencies) trick CMakes FindCUDA module into not finding it by
767
775
# using the environment variable which is used as-is and later checked for a falsy value when determining
768
776
# whether CUDA was found
769
777
if not get_software_root ('CUDA' ):
770
778
setvar ('CUDA_NVCC_EXECUTABLE' , 'IGNORE' )
771
779
772
- if self .cfg ['build_openmp_offload' ] and LooseVersion ( '19' ) <= LooseVersion (self .version ) < LooseVersion ( '20' ) :
780
+ if self .cfg ['build_openmp_offload' ] and '19' <= LooseVersion (self .version ) < '20' :
773
781
gpu_archs = []
774
782
gpu_archs += ['sm_%s' % cc for cc in self .cuda_cc ]
775
783
gpu_archs += self .amd_gfx
@@ -843,7 +851,6 @@ def configure_step3(self):
843
851
844
852
def _create_compiler_config_file (self , installdir ):
845
853
"""Create a config file for the compiler to point to the correct GCC installation."""
846
- self ._set_gcc_prefix ()
847
854
bin_dir = os .path .join (installdir , 'bin' )
848
855
opts = [f'--gcc-install-dir={ self .gcc_prefix } ' ]
849
856
@@ -1475,7 +1482,6 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, extension=F
1475
1482
'dirs' : check_dirs ,
1476
1483
}
1477
1484
1478
- self ._set_gcc_prefix ()
1479
1485
if lib_dir_runtime :
1480
1486
# Required for 'clang -v' to work if linked to LLVM runtimes
1481
1487
with _wrap_env (ld_path = os .path .join (self .installdir , lib_dir_runtime )):
0 commit comments