Skip to content

Commit 10c5110

Browse files
authored
Merge pull request #3703 from Thyre/binutils-add-gold-option
binutils: Do not build ld.gold with binutils 2.44 or newer
2 parents 38a8abe + 344d9a9 commit 10c5110

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

easybuild/easyblocks/b/binutils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ def __init__(self, *args, **kwargs):
6060
"""Easyblock constructor"""
6161
super(EB_binutils, self).__init__(*args, **kwargs)
6262

63-
# ld.gold linker is not supported on RISC-V
64-
self.use_gold = get_cpu_family() != RISCV
63+
if LooseVersion(self.version) >= LooseVersion('2.44') or get_cpu_family() == RISCV:
64+
# ld.gold linker is not supported on RISC-V, and is being phased out starting from v2.44
65+
self.use_gold = False
66+
else:
67+
self.use_gold = True
6568

6669
def determine_used_library_paths(self):
6770
"""Check which paths are used to search for libraries"""

easybuild/easyblocks/g/gcc.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
from easybuild.easyblocks.generic.configuremake import ConfigureMake
4848
from easybuild.framework.easyconfig import CUSTOM
4949
from easybuild.tools.build_log import EasyBuildError
50-
from easybuild.tools.config import build_option
51-
from easybuild.tools.filetools import apply_regex_substitutions, adjust_permissions, change_dir, copy_file
50+
from easybuild.tools.config import build_option, IGNORE
51+
from easybuild.tools.filetools import apply_regex_substitutions, adjust_permissions, change_dir, copy_file, search_file
5252
from easybuild.tools.filetools import mkdir, move_file, read_file, symlink, which, write_file
5353
from easybuild.tools.modules import MODULE_LOAD_ENV_HEADERS, get_software_root
5454
from easybuild.tools.run import run_shell_cmd
@@ -677,13 +677,32 @@ def configure_step(self):
677677
# enable plugin support
678678
self.configopts += " --enable-plugins "
679679

680+
# Determine if ld.gold is available, as being slowly faded out with binutils 2.44 and newer.
681+
# If binutils is loaded, check for ld.gold inside of that installation.
682+
# If not loaded, check in $PATH, as binutils might have been filtered.
683+
binutils_has_ld_gold = False
684+
binutils_root = get_software_root('binutils')
685+
if binutils_root:
686+
_, hits = search_file([binutils_root], 'ld.gold')
687+
if hits:
688+
binutils_has_ld_gold = True
689+
elif which('ld.gold', on_error=IGNORE):
690+
binutils_has_ld_gold = True
691+
680692
# use GOLD as default linker, except on RISC-V (since it's not supported there)
681693
if get_cpu_family() == RISCV:
682694
self.configopts += " --disable-gold --enable-ld=default"
683695
elif self.cfg['use_gold_linker']:
696+
if not binutils_has_ld_gold:
697+
raise EasyBuildError("Tried to set ld.gold as default linker, but ld.gold is not available.")
684698
self.configopts += " --enable-gold=default --enable-ld --with-plugin-ld=ld.gold"
685699
else:
686-
self.configopts += " --enable-gold --enable-ld=default"
700+
if binutils_has_ld_gold:
701+
self.configopts += " --enable-gold"
702+
else:
703+
self.log.debug("Disabling ld.gold, as is was not found")
704+
self.configopts += " --disable-gold"
705+
self.configopts += " --enable-ld=default"
687706

688707
# enable bootstrap build for self-containment (unless for staged build)
689708
if not self.stagedbuild:
@@ -789,6 +808,10 @@ def build_step(self):
789808
if lib == "gmp":
790809
cmd = "./configure --prefix=%s " % stage2prefix
791810
cmd += "--with-pic --disable-shared --enable-cxx "
811+
# Force C99 during configure to avoid newer C standard
812+
# being used. This avoids inconsistencies between the configure
813+
# result and the build, where we force C99 via a patch.
814+
cmd += "CFLAGS=-std=c99 "
792815

793816
# ensure generic build when 'generic' is set to True or when --optarch=GENERIC is used
794817
# non-generic build can be enforced with generic=False if --optarch=GENERIC is used

0 commit comments

Comments
 (0)