Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use updated config.guess in GCC easyblock #2033

Merged
merged 4 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions easybuild/easyblocks/g/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ def __init__(self, *args, **kwargs):
if get_os_name() not in ['ubuntu', 'debian']:
self.cfg.update('unwanted_env_vars', ['LIBRARY_PATH'])

self.platform_lib = get_platform_name(withversion=True)

def create_dir(self, dirname):
"""
Create a dir to build in.
Expand Down Expand Up @@ -383,15 +381,25 @@ def configure_step(self):
else:
objdir = self.create_dir("obj")

build_type, host_type = self.determine_build_and_host_type()
if build_type:
configopts += ' --build=' + build_type
if host_type:
configopts += ' --host=' + host_type

# instead of relying on uname, we use the actual --build option
if build_type:
self.platform_lib = build_type
else:
# Fallback
out, ec = run_cmd("../config.guess")
if ec != 0:
raise EasyBuildError('Failed to obtain platform_lib value from config.guess')
self.platform_lib = out.strip()

# IV) actual configure, but not on default path
cmd = "../configure %s %s" % (self.configopts, configopts)

# instead of relying on uname, we run the same command GCC uses to
# determine the platform
out, ec = run_cmd("../config.guess", simple=False)
if ec == 0:
self.platform_lib = out.rstrip()

self.run_configure_cmd(cmd)

self.disable_lto_mpfr_old_gcc(objdir)
Expand Down
92 changes: 48 additions & 44 deletions easybuild/easyblocks/generic/configuremake.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,40 @@ def fetch_step(self, *args, **kwargs):
# Use an updated config.guess from a global location (if possible)
self.config_guess = self.obtain_config_guess()

def determine_build_and_host_type(self):
"""
Return the resolved build and host type for use with --build and --host
Uses the EasyConfig values or queries config.guess if those are not set
Might return None for either value
"""
build_type = self.cfg.get('build_type')
host_type = self.cfg.get('host_type')

if build_type is None or host_type is None:
# config.guess script may not be obtained yet despite the call in fetch_step,
# for example when installing a Bundle component with ConfigureMake
if not self.config_guess:
self.config_guess = self.obtain_config_guess()

if not self.config_guess:
print_warning("No config.guess available, not setting '--build' option for configure step\n"
"EasyBuild attempts to download a recent config.guess but seems to have failed!")
else:
self.check_config_guess()
system_type, _ = run_cmd(self.config_guess, log_all=True)
system_type = system_type.strip()
self.log.info("%s returned a system type '%s'", self.config_guess, system_type)

if build_type is None:
build_type = system_type
self.log.info("Providing '%s' as value to --build option of configure script", build_type)

if host_type is None:
host_type = system_type
self.log.info("Providing '%s' as value to --host option of configure script", host_type)

return build_type, host_type

def configure_step(self, cmd_prefix=''):
"""
Configure step
Expand Down Expand Up @@ -216,55 +250,25 @@ def configure_step(self, cmd_prefix=''):
# use the version downloaded by EasyBuild instead, and provide the result to the configure command;
# it is possible that the configure script is generated using preconfigopts...
# if so, we're at the mercy of the gods
build_type_option = ''
host_type_option = ''
build_and_host_options = []

# note: reading contents of 'configure' script in bytes mode,
# to avoid problems when non-UTF-8 characters are included
# see https://github.com/easybuilders/easybuild-easyblocks/pull/1817
if os.path.exists(configure_command) and AUTOCONF_GENERATED_MSG in read_file(configure_command, mode='rb'):

build_type = self.cfg.get('build_type')
host_type = self.cfg.get('host_type')

if build_type is None or host_type is None:

# config.guess script may not be obtained yet despite the call in fetch_step,
# for example when installing a Bundle component with ConfigureMake
if self.config_guess is None:
self.config_guess = self.obtain_config_guess()

if self.config_guess is None:
print_warning("No config.guess available, not setting '--build' option for configure step\n"
"EasyBuild attempts to download a recent config.guess but seems to have failed!")
else:
self.check_config_guess()
system_type, _ = run_cmd(self.config_guess, log_all=True)
system_type = system_type.strip()
self.log.info("%s returned a system type '%s'", self.config_guess, system_type)

if build_type is None:
build_type = system_type
self.log.info("Providing '%s' as value to --build option of configure script", build_type)

if host_type is None:
host_type = system_type
self.log.info("Providing '%s' as value to --host option of configure script", host_type)

if build_type is not None and build_type:
build_type_option = '--build=' + build_type

if host_type is not None and host_type:
host_type_option = '--host=' + host_type

cmd = ' '.join([
self.cfg['preconfigopts'],
configure_command,
prefix_opt + self.installdir,
build_type_option,
host_type_option,
self.cfg['configopts'],
])
build_type, host_type = self.determine_build_and_host_type()
if build_type:
build_and_host_options.append(' --build=' + build_type)
if host_type:
build_and_host_options.append(' --host=' + host_type)

cmd = ' '.join(
[
self.cfg['preconfigopts'],
configure_command,
prefix_opt + self.installdir,
] + build_and_host_options + [self.cfg['configopts']]
)

(out, _) = run_cmd(cmd, log_all=True, simple=False)

Expand Down