From 25a5822603de0455e29f96d4032b60dc22c4f7bb Mon Sep 17 00:00:00 2001 From: Sebastian Achilles Date: Sun, 8 Aug 2021 00:34:04 +0200 Subject: [PATCH 1/4] AOCC easyblock: make sure clang/flang picks up GCCcore as GCC toolchain --- easybuild/easyblocks/a/aocc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/easybuild/easyblocks/a/aocc.py b/easybuild/easyblocks/a/aocc.py index 086d0385717..0f9dbd80c1e 100644 --- a/easybuild/easyblocks/a/aocc.py +++ b/easybuild/easyblocks/a/aocc.py @@ -61,6 +61,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: @@ -116,6 +117,9 @@ def make_module_extra(self): txt += self.module_generator.set_environment('ASAN_SYMBOLIZER_PATH', asan_symbolizer_path) # setting the AOCChome path txt += self.module_generator.set_environment('AOCChome', self.installdir) + # make sure clang/flang picks up GCCcore as GCC toolchain + txt += self.module_generator.set_alias('clang', 'clang --gcc-toolchain=$EBROOTGCCCORE') + txt += self.module_generator.set_alias('flang', 'flang --gcc-toolchain=$EBROOTGCCCORE') return txt def make_module_req_guess(self): From 86aa43b7b7cdeb1fc7ab3ffab44b581798550d9b Mon Sep 17 00:00:00 2001 From: Sebastian Achilles Date: Mon, 30 Aug 2021 12:54:43 +0200 Subject: [PATCH 2/4] AOCC easyblock: use wrapper to make sure clang/flang picks up GCCcore as GCC toolchain --- easybuild/easyblocks/a/aocc.py | 49 +++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/easybuild/easyblocks/a/aocc.py b/easybuild/easyblocks/a/aocc.py index 0f9dbd80c1e..23d5a4a8c6e 100644 --- a/easybuild/easyblocks/a/aocc.py +++ b/easybuild/easyblocks/a/aocc.py @@ -32,12 +32,23 @@ """ 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.filetools import adjust_permissions +from easybuild.tools.filetools import move_file, write_file from easybuild.tools.build_log import EasyBuildError 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): """ @@ -87,6 +98,41 @@ 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""" + 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': '%s.orig' % 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 or []): + actual_compiler = os.path.join(self.installdir,'bin',comp) + if os.path.isfile(actual_compiler): + move_file(actual_compiler, '%s.orig' % actual_compiler) + else: + err_str = "Tried to move '{!s}' to '{!s}', " \ + " but it doesn't exist!" + raise EasyBuildError(err_str.format(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.format(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() @@ -117,9 +163,6 @@ def make_module_extra(self): txt += self.module_generator.set_environment('ASAN_SYMBOLIZER_PATH', asan_symbolizer_path) # setting the AOCChome path txt += self.module_generator.set_environment('AOCChome', self.installdir) - # make sure clang/flang picks up GCCcore as GCC toolchain - txt += self.module_generator.set_alias('clang', 'clang --gcc-toolchain=$EBROOTGCCCORE') - txt += self.module_generator.set_alias('flang', 'flang --gcc-toolchain=$EBROOTGCCCORE') return txt def make_module_req_guess(self): From 235484cbee1677ccfdae1c262dbfa66f7c4bb319 Mon Sep 17 00:00:00 2001 From: Sebastian Achilles Date: Mon, 30 Aug 2021 12:56:47 +0200 Subject: [PATCH 3/4] AOCC easyblock: use wrapper to make sure clang/flang picks up GCCcore as GCC toolchain --- easybuild/easyblocks/a/aocc.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/easybuild/easyblocks/a/aocc.py b/easybuild/easyblocks/a/aocc.py index 23d5a4a8c6e..8111f55ae27 100644 --- a/easybuild/easyblocks/a/aocc.py +++ b/easybuild/easyblocks/a/aocc.py @@ -109,11 +109,17 @@ def create_wrapper(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'] + 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 or []): - actual_compiler = os.path.join(self.installdir,'bin',comp) + actual_compiler = os.path.join(self.installdir, 'bin', comp) if os.path.isfile(actual_compiler): move_file(actual_compiler, '%s.orig' % actual_compiler) else: @@ -123,8 +129,8 @@ def create_wrapper(wrapper_comp): '%s.orig' % actual_compiler)) if not os.path.exists(actual_compiler): - create_wrapper(comp) - self.log.info("Wrapper for %s successfully created", comp) + create_wrapper(comp) + self.log.info("Wrapper for %s successfully created", comp) else: err_str = "Creating wrapper for '{!s}'" \ " not possible, since original" \ From 8b3cbfeb345a5baa73910ac36b551dc6156f87b3 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 2 Sep 2021 10:06:26 +0200 Subject: [PATCH 4/4] style fixes for AOCC easyblock --- easybuild/easyblocks/a/aocc.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/easybuild/easyblocks/a/aocc.py b/easybuild/easyblocks/a/aocc.py index 8111f55ae27..97d30d17dc1 100644 --- a/easybuild/easyblocks/a/aocc.py +++ b/easybuild/easyblocks/a/aocc.py @@ -38,9 +38,8 @@ from easybuild.easyblocks.generic.packedbinary import PackedBinary from easybuild.framework.easyconfig import CUSTOM -from easybuild.tools.filetools import adjust_permissions -from easybuild.tools.filetools import move_file, write_file 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 @@ -100,12 +99,13 @@ def install_step(self): 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': '%s.orig' % 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) @@ -114,28 +114,24 @@ def create_wrapper(wrapper_comp): 'clang++', 'clang-%s' % LooseVersion(self.clangversion).version[0], 'clang-cpp', - 'flang' + 'flang', ] # Rename original compilers and prepare wrappers to pick up GCCcore as GCC toolchain for the compilers - for comp in (compilers_to_wrap or []): + 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, '%s.orig' % actual_compiler) + move_file(actual_compiler, orig_compiler_tmpl % actual_compiler) else: - err_str = "Tried to move '{!s}' to '{!s}', " \ - " but it doesn't exist!" - raise EasyBuildError(err_str.format(actual_compiler, - '%s.orig' % actual_compiler)) + 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.format(actual_compiler)) + 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() @@ -156,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", ]