Skip to content
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
51 changes: 51 additions & 0 deletions easybuild/easyblocks/a/aocc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,22 @@
"""

import os
import stat

from distutils.version import LooseVersion

from easybuild.easyblocks.generic.packedbinary import PackedBinary
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import adjust_permissions, move_file, write_file
from easybuild.tools.systemtools import get_shared_lib_ext

# Wrapper script definition
WRAPPER_TEMPLATE = """#!/bin/sh

%(compiler_name)s --gcc-toolchain=$EBROOTGCCCORE "$@"
"""


class EB_AOCC(PackedBinary):
"""
Expand All @@ -61,6 +71,7 @@ def _aocc_guess_clang_version(self):
map_aocc_to_clang_ver = {
'2.3.0': '11.0.0',
'3.0.0': '12.0.0',
'3.1.0': '12.0.0',
}

if self.version in map_aocc_to_clang_ver:
Expand All @@ -86,6 +97,44 @@ def install_step(self):

super(EB_AOCC, self).install_step()

def post_install_step(self):
"""Create wrappers for the compilers to make sure compilers picks up GCCcore as GCC toolchain"""

orig_compiler_tmpl = '%s.orig'

def create_wrapper(wrapper_comp):
"""Create for a particular compiler, with a particular name"""
wrapper_f = os.path.join(self.installdir, 'bin', wrapper_comp)
write_file(wrapper_f, WRAPPER_TEMPLATE % {'compiler_name': orig_compiler_tmpl % wrapper_comp})
perms = stat.S_IXUSR | stat.S_IRUSR | stat.S_IXGRP | stat.S_IRGRP | stat.S_IXOTH | stat.S_IROTH
adjust_permissions(wrapper_f, perms)

compilers_to_wrap = [
'clang',
'clang++',
'clang-%s' % LooseVersion(self.clangversion).version[0],
'clang-cpp',
'flang',
]

# Rename original compilers and prepare wrappers to pick up GCCcore as GCC toolchain for the compilers
for comp in compilers_to_wrap:
actual_compiler = os.path.join(self.installdir, 'bin', comp)
if os.path.isfile(actual_compiler):
move_file(actual_compiler, orig_compiler_tmpl % actual_compiler)
else:
err_str = "Tried to move '%s' to '%s', but it does not exist!"
raise EasyBuildError(err_str, actual_compiler, '%s.orig' % actual_compiler)

if not os.path.exists(actual_compiler):
create_wrapper(comp)
self.log.info("Wrapper for %s successfully created", comp)
else:
err_str = "Creating wrapper for '%s' not possible, since original compiler was not renamed!"
raise EasyBuildError(err_str, actual_compiler)

super(EB_AOCC, self).post_install_step()

def sanity_check_step(self):
"""Custom sanity check for AOCC, based on sanity check for Clang."""
shlib_ext = get_shared_lib_ext()
Expand All @@ -103,6 +152,8 @@ def sanity_check_step(self):
custom_commands = [
"clang --help",
"clang++ --help",
"clang-%s --help" % LooseVersion(self.clangversion).version[0],
"clang-cpp --help",
"flang --help",
"llvm-config --cxxflags",
]
Expand Down