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

give /lib preference over /lib64 & co, enable installation of libliberty by default #1030

Merged
merged 9 commits into from
Nov 13, 2016
38 changes: 37 additions & 1 deletion easybuild/easyblocks/b/binutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,26 @@
from distutils.version import LooseVersion

from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import apply_regex_substitutions, copy_file
from easybuild.tools.modules import get_software_libdir, get_software_root
from easybuild.tools.filetools import apply_regex_substitutions
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import get_shared_lib_ext


class EB_binutils(ConfigureMake):
"""Support for building/installing binutils."""

@staticmethod
def extra_options(extra_vars=None):
"""Extra easyconfig parameters specific to the binutils easyblock."""
extra_vars = ConfigureMake.extra_options(extra_vars=extra_vars)
extra_vars.update({
'install_libiberty': [True, "Also install libiberty (implies building with -fPIC)", CUSTOM],
})
return extra_vars

def configure_step(self):
"""Custom configuration procedure for binutils: statically link to zlib, configure options."""

Expand Down Expand Up @@ -99,6 +109,29 @@ def configure_step(self):
# complete configuration with configure_method of parent
super(EB_binutils, self).configure_step()

if self.cfg['install_libiberty']:
cflags = os.getenv('CFLAGS')
if cflags:
self.cfg.update('buildopts', 'CFLAGS="$CFLAGS -fPIC"')
else:
# if $CFLAGS is not defined, make sure we retain "-g -O2",
# since not specifying any optimization level implies -O0...
self.cfg.update('buildopts', 'CFLAGS="-g -O2 -fPIC"')

def install_step(self):
"""Install using 'make install', also install libiberty if desired."""
super(EB_binutils, self).install_step()

# only install libiberty if it's not there yet; it is installed by default for old binutils versionsuffix
libiberty_installed = glob.glob(os.path.join(self.installdir, 'lib*', 'libiberty.a'))
if self.cfg['install_libiberty'] and not libiberty_installed:
copy_file(os.path.join(self.cfg['start_dir'], 'include', 'libiberty.h'),
os.path.join(self.installdir, 'include', 'libiberty.h'))
copy_file(os.path.join(self.cfg['start_dir'], 'libiberty', 'libiberty.a'),
os.path.join(self.installdir, 'lib', 'libiberty.a'))
copy_file(os.path.join(self.cfg['start_dir'], 'libiberty', 'libiberty.texi'),
os.path.join(self.installdir, 'info', 'libiberty.texi'))

def sanity_check_step(self):
"""Custom sanity check for binutils."""

Expand All @@ -122,6 +155,9 @@ def sanity_check_step(self):
'dirs': [],
}

if self.cfg['install_libiberty']:
custom_paths['files'].extend([os.path.join('lib', 'libiberty.a'), os.path.join('include', 'libiberty.h')])

# if zlib is listed as a dependency, it should get linked in statically
if get_software_root('zlib'):
for binary in binaries:
Expand Down
17 changes: 17 additions & 0 deletions easybuild/easyblocks/g/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import write_file
from easybuild.tools.modules import get_software_root
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import check_os_dependency, get_os_name, get_os_type, get_shared_lib_ext, get_platform_name
Expand All @@ -60,13 +61,15 @@ class EB_GCC(ConfigureMake):
def extra_options():
extra_vars = {
'languages': [[], "List of languages to build GCC for (--enable-languages)", CUSTOM],
'withlibiberty': [False, "Enable installing of libiberty", CUSTOM],
'withlto': [True, "Enable LTO support", CUSTOM],
'withcloog': [False, "Build GCC with CLooG support", CUSTOM],
'withppl': [False, "Build GCC with PPL support", CUSTOM],
'withisl': [False, "Build GCC with ISL support", CUSTOM],
'pplwatchdog': [False, "Enable PPL watchdog", CUSTOM],
'clooguseisl': [False, "Use ISL with CLooG or not", CUSTOM],
'multilib': [False, "Build multilib gcc (both i386 and x86_64)", CUSTOM],
'prefer_lib_subdir': [True, "Configure GCC to prefer 'lib' subdirs over 'lib64' & co when linking", CUSTOM],
}
return ConfigureMake.extra_options(extra_vars)

Expand Down Expand Up @@ -239,6 +242,10 @@ def configure_step(self):
if self.cfg['languages']:
self.configopts += " --enable-languages=%s" % ','.join(self.cfg['languages'])

# enable building of libiberty, if desired
if self.cfg['withlibiberty']:
self.configopts += " --enable-install-libiberty"

# enable link-time-optimization (LTO) support, if desired
if self.cfg['withlto']:
self.configopts += " --enable-lto"
Expand Down Expand Up @@ -287,6 +294,16 @@ def configure_step(self):
self.log.info("Performing regular GCC build...")
configopts += " --prefix=%(p)s --with-local-prefix=%(p)s" % {'p': self.installdir}

# prioritize lib over lib{64,32,x32} for all architectures by overriding default MULTILIB_OSDIRNAMES config
# only do this when multilib is not enabled
if self.cfg['prefer_lib_subdir'] and not self.cfg['multilib']:
cfgfile = 'gcc/config/i386/t-linux64'
multilib_osdirnames = "MULTILIB_OSDIRNAMES = m64=../lib:../lib64 m32=../lib:../lib32 mx32=../lib:../libx32"
self.log.info("Patching MULTILIB_OSDIRNAMES in %s with '%s'", cfgfile, multilib_osdirnames)
write_file(cfgfile, multilib_osdirnames, append=True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebth it looks like this is causing problems with older GCC versions, i.e. GCC 4.7.2 and older (except for GCC 4.6.4)... GCC 4.7.3 and newer are OK.

This is the error:

/usr/lib/crti.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status

with:

$ file /usr/lib/crti.o
/usr/lib/crti.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped

I'll add a prefer_lib_subdir = False in those easyconfigs, but do you happen to know what the problem is?

elif self.cfg['multilib']:
self.log.info("Not patching MULTILIB_OSDIRNAMES since use of --enable-multilib is enabled")

# III) create obj dir to build in, and change to it
# GCC doesn't like to be built in the source dir
if self.stagedbuild:
Expand Down