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

Patch gcc.c* only for older sysroot-ed installations. #1

Merged
Merged
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
16 changes: 15 additions & 1 deletion easybuild/easyblocks/g/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.config import build_option
from easybuild.tools.filetools import apply_regex_substitutions, change_dir, copy_file, move_file, symlink
from easybuild.tools.filetools import which, write_file
from easybuild.tools.filetools import which, read_file, write_file
from easybuild.tools.modules import get_software_root
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import RISCV, check_os_dependency, get_cpu_architecture, get_cpu_family
Expand Down Expand Up @@ -357,6 +357,20 @@ def configure_step(self):
# (see https://gcc.gnu.org/install/configure.html)
self.cfg.update('configopts', '--with-sysroot=%s' % sysroot)

libc_so_candidates = [os.path.join(sysroot, x, 'libc.so') for x in
['lib', 'lib64', os.path.join('usr', 'lib'), os.path.join('usr', 'lib64')]]
for libc_so in libc_so_candidates:
if os.path.exists(libc_so):
# only patch gcc.c or gcc.cc if entries in libc.so are prefixed with sysroot
if '\nGROUP ( ' + sysroot in read_file(libc_so):
gccfile = os.path.join('gcc', 'gcc.c')
# renamed to gcc.cc in GCC 12
if not os.path.exists(gccfile):
gccfile = os.path.join('gcc', 'gcc.cc')
# avoid that --sysroot is passed to linker by patching value for SYSROOT_SPEC in gcc/gcc.c*
apply_regex_substitutions(gccfile, [('--sysroot=%R', '')])
break

# prefix dynamic linkers with sysroot
# this patches lines like:
# #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
Expand Down