4848from easybuild .tools .filetools import apply_regex_substitutions , symlink , write_file
4949from easybuild .tools .modules import get_software_root
5050from easybuild .tools .run import run_cmd
51- from easybuild .tools .systemtools import check_os_dependency , get_os_name , get_os_type , get_platform_name
51+ from easybuild .tools .systemtools import check_os_dependency , get_os_name , get_os_type
5252from easybuild .tools .systemtools import get_gcc_version , get_shared_lib_ext
5353from easybuild .tools .toolchain .compiler import OPTARCH_GENERIC
54+ from easybuild .tools .utilities import nub
5455
5556
5657COMP_CMD_SYMLINKS = {
@@ -381,22 +382,14 @@ def configure_step(self):
381382 else :
382383 objdir = self .create_dir ("obj" )
383384
385+ # note: this also triggers the use of an updated config.guess script
386+ # (unless both the 'build_type' and 'host_type' easyconfig parameters are specified)
384387 build_type , host_type = self .determine_build_and_host_type ()
385388 if build_type :
386389 configopts += ' --build=' + build_type
387390 if host_type :
388391 configopts += ' --host=' + host_type
389392
390- # instead of relying on uname, we use the actual --build option
391- if build_type :
392- self .platform_lib = build_type
393- else :
394- # Fallback
395- out , ec = run_cmd ("../config.guess" )
396- if ec != 0 :
397- raise EasyBuildError ('Failed to obtain platform_lib value from config.guess' )
398- self .platform_lib = out .strip ()
399-
400393 # IV) actual configure, but not on default path
401394 cmd = "../configure %s %s" % (self .configopts , configopts )
402395
@@ -632,7 +625,26 @@ def sanity_check_step(self):
632625
633626 os_type = get_os_type ()
634627 sharedlib_ext = get_shared_lib_ext ()
635- common_infix = os .path .join ('gcc' , self .platform_lib , self .version )
628+
629+ # determine "configuration name" directory, see https://sourceware.org/autobook/autobook/autobook_17.html
630+ # this differs across GCC versions;
631+ # x86_64-unknown-linux-gnu was common for old GCC versions,
632+ # x86_64-pc-linux-gnu is more likely with an updated config.guess script;
633+ # since this is internal to GCC, we don't really care how it is named exactly,
634+ # we only care that it's actually there
635+
636+ # we may get multiple hits (libexec/, lib/), which is fine,
637+ # but we expect the same configuration name subdirectory in each of them
638+ glob_pattern = os .path .join (self .installdir , 'lib*' , 'gcc' , '*-linux-gnu' , self .version )
639+ matches = glob .glob (glob_pattern )
640+ if matches :
641+ cands = nub ([os .path .basename (os .path .dirname (x )) for x in matches ])
642+ if len (cands ) == 1 :
643+ config_name_subdir = cands [0 ]
644+ else :
645+ raise EasyBuildError ("Found multiple candidates for configuration name: %s" , ', ' .join (cands ))
646+ else :
647+ raise EasyBuildError ("Failed to determine configuration name: no matches for '%s'" , glob_pattern )
636648
637649 bin_files = ["gcov" ]
638650 lib_files = []
@@ -647,7 +659,7 @@ def sanity_check_step(self):
647659 else :
648660 lib_files .extend (["libasan.%s" % sharedlib_ext , "libasan.a" ])
649661 libexec_files = []
650- dirs = ['lib/%s' % common_infix ]
662+ dirs = [os . path . join ( 'lib' , 'gcc' , config_name_subdir , self . version ) ]
651663
652664 if not self .cfg ['languages' ]:
653665 # default languages are c, c++, fortran
@@ -686,7 +698,8 @@ def sanity_check_step(self):
686698 lib_files = [tuple ([os .path .join (libdir , x ) for libdir in libdirs ]) for x in lib_files ]
687699 # lib on SuSE, libexec otherwise
688700 libdirs = ['libexec' , 'lib' ]
689- libexec_files = [tuple ([os .path .join (libdir , common_infix , x ) for libdir in libdirs ]) for x in libexec_files ]
701+ common_infix = os .path .join ('gcc' , config_name_subdir , self .version )
702+ libexec_files = [tuple ([os .path .join (d , common_infix , x ) for d in libdirs ]) for x in libexec_files ]
690703
691704 old_cmds = [os .path .join ('bin' , x ) for x in COMP_CMD_SYMLINKS .keys ()]
692705
0 commit comments