From 4c7f4bc7bf285c97680c6317ffadded0b9d5f828 Mon Sep 17 00:00:00 2001
From: Damian Alvarez <d.alvarez@fz-juelich.de>
Date: Sun, 5 Dec 2021 16:32:39 +0100
Subject: [PATCH] To make AOCC and Clang side compilers

---
 Custom_Hooks/eb_hooks.py                       | 10 ++++++++++
 Custom_MNS/flexible_custom_hierarchical_mns.py |  6 ++++++
 2 files changed, 16 insertions(+)

diff --git a/Custom_Hooks/eb_hooks.py b/Custom_Hooks/eb_hooks.py
index a00a87516..2fccb5268 100644
--- a/Custom_Hooks/eb_hooks.py
+++ b/Custom_Hooks/eb_hooks.py
@@ -68,6 +68,8 @@ TWEAKABLE_DEPENDENCIES = {
     'glew': ('OpenGL', '2021b'),
 }
 
+SIDECOMPILERS = ['AOCC', 'Clang']
+
 common_site_contact = 'Support <sc@fz-juelich.de>'
 
 # Also maintain a list of CUDA enabled compilers
@@ -228,6 +230,8 @@ def parse_hook(ec, *args, **kwargs):
     if os.getenv('CI') is None:
         ec = tweak_dependencies(ec)
 
+    ec = tweak_moduleclass(ec)
+
     # If we are parsing we are not searching, in this case if the easyconfig is
     # located in the search path, warn that it's dependencies will (most probably)
     # not be resolved
@@ -278,6 +282,12 @@ def tweak_dependencies(ec):
 
     return ec
 
+def tweak_moduleclass(ec):
+    if ec['name'] in SIDECOMPILERS:
+        ec['moduleclass'] = 'sidecompiler'
+
+    return ec
+
 def inject_site_contact_and_user_labels(ec):
     ec_dict = ec.asdict()
     # Check where installations are going to go and add appropriate site contact
diff --git a/Custom_MNS/flexible_custom_hierarchical_mns.py b/Custom_MNS/flexible_custom_hierarchical_mns.py
index 0259dc2fe..a75d4f9a3 100644
--- a/Custom_MNS/flexible_custom_hierarchical_mns.py
+++ b/Custom_MNS/flexible_custom_hierarchical_mns.py
@@ -23,6 +23,7 @@ COMM_SETTINGS = 'comm_settings'
 
 MODULECLASS_COMPILER = 'compiler'
 MODULECLASS_MPI = 'mpi'
+MODULECLASS_SIDECOMPILER = 'sidecompiler'
 
 GCCCORE = 'GCCcore'
 
@@ -185,6 +186,8 @@ class FlexibleCustomHierarchicalMNS(HierarchicalMNS):
                 # but we want the mpi module class to stand alone
                 if ec['moduleclass'] == MODULECLASS_MPI:
                     subdir = os.path.join(COMPILER, MODULECLASS_MPI, tc_comp_name, tc_comp_ver)
+                elif ec['moduleclass'] == MODULECLASS_SIDECOMPILER:
+                    subdir = os.path.join(COMPILER, MODULECLASS_SIDECOMPILER, tc_comp_name, tc_comp_ver)
                 else:
                     subdir = os.path.join(COMPILER, tc_comp_name, tc_comp_ver)
             else:
@@ -254,6 +257,9 @@ class FlexibleCustomHierarchicalMNS(HierarchicalMNS):
                 # Always extend to capture the MPI implementations too (which are in a separate directory)
                 if ec['name'] not in [GCCCORE]:
                     paths.append(os.path.join(COMPILER, MODULECLASS_MPI, *comp_name_ver))
+                # Extend the MOODULEPATH to include the side compilers available in GCCcore
+                else:
+                    paths.append(os.path.join(COMPILER, MODULECLASS_SIDECOMPILER, *comp_name_ver))
 
         elif modclass == MODULECLASS_MPI:
             if tc_comp_info is None:
-- 
GitLab