From d7e1d458f1584f895b1e36e58d593a33592710cc Mon Sep 17 00:00:00 2001 From: Ash Pera Date: Sat, 3 Oct 2026 16:47:47 -0600 Subject: [PATCH 1/2] Set a compiler's MODULEPATH before its meta-module loads modules setup-meta-modules wrote a compiler's environment prepend of MODULEPATH after the module loads, so a compiler module found only in that directory could not be loaded. Write it with the module hierarchy, before the loads. Add the directory of the EPIC-installed oneAPI compiler module to the Orion and Hercules oneAPI compiler entries. --- .../tier1/hercules/packages_oneapi-2025.3.1.yaml | 2 ++ .../sites/tier1/orion/packages_oneapi-2025.3.1.yaml | 2 ++ .../lib/jcsda-emc/spack-stack/stack/meta_modules.py | 12 ++++++++++-- .../spack-stack/tests/test_setup_meta_modules.py | 11 +++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/configs/sites/tier1/hercules/packages_oneapi-2025.3.1.yaml b/configs/sites/tier1/hercules/packages_oneapi-2025.3.1.yaml index 2d96294c1d..e14516e786 100644 --- a/configs/sites/tier1/hercules/packages_oneapi-2025.3.1.yaml +++ b/configs/sites/tier1/hercules/packages_oneapi-2025.3.1.yaml @@ -26,6 +26,8 @@ packages: environment: prepend_path: LD_LIBRARY_PATH: '/usr/lib:/usr/lib64' + # EPIC-installed oneAPI compiler module + MODULEPATH: '/apps/contrib/spack-stack/modulefiles' intel-oneapi-mkl: buildable: false externals: diff --git a/configs/sites/tier1/orion/packages_oneapi-2025.3.1.yaml b/configs/sites/tier1/orion/packages_oneapi-2025.3.1.yaml index 0ec52951fc..6e97117c49 100644 --- a/configs/sites/tier1/orion/packages_oneapi-2025.3.1.yaml +++ b/configs/sites/tier1/orion/packages_oneapi-2025.3.1.yaml @@ -26,6 +26,8 @@ packages: environment: prepend_path: LD_LIBRARY_PATH: '/usr/lib:/usr/lib64' + # EPIC-installed oneAPI compiler module + MODULEPATH: '/apps/contrib/spack-stack/modulefiles' intel-oneapi-mkl: buildable: false externals: diff --git a/spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py b/spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py index 0757f59f77..c52ff1889a 100755 --- a/spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py +++ b/spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py @@ -424,7 +424,10 @@ def setup_meta_modules(): compiler_subs["COMPFLAGS"] = compiler_subs["COMPFLAGS"].rstrip("\n") logging.debug(" ... ... COMPFLAGS: {}".format(compiler_subs["COMPFLAGS"])) - # Environment variables + # Environment variables. A change to MODULEPATH goes with MODULEPATHS, + # which the template emits before MODULELOADS: the compiler's modules may + # be found only in the directories it adds. + compiler_modulepaths = "" if "environment" in compiler.extra_attributes.keys(): for action in compiler.extra_attributes["environment"].keys(): for env_name in compiler.extra_attributes["environment"][action]: @@ -432,12 +435,16 @@ def setup_meta_modules(): env_values = None else: env_values = compiler.extra_attributes["environment"][action][env_name] - compiler_subs["ENVVARS"] += envmod_command( + command = envmod_command( module_choice, action, env_name, env_values ) + if env_name == "MODULEPATH": + compiler_modulepaths += command + else: + compiler_subs["ENVVARS"] += command # https://github.com/JCSDA/spack-stack/issues/1903 # Attempt to locate directory "compiler" in the same directory where # "icx" resides. If found, add it to PATH in the compiler module @@ -455,6 +462,7 @@ def setup_meta_modules(): # Spack compiler module hierarchy - append all saved modulepaths for modulepath in MODULEPATHS_SAVE: compiler_subs["MODULEPATHS"] += modulepath_prepend_command(module_choice, modulepath) + compiler_subs["MODULEPATHS"] += compiler_modulepaths compiler_subs["MODULEPATHS"] = compiler_subs["MODULEPATHS"].rstrip("\n") logging.debug(" ... ... MODULEPATHS : {}".format(compiler_subs["MODULEPATHS"])) diff --git a/spack-ext/lib/jcsda-emc/spack-stack/tests/test_setup_meta_modules.py b/spack-ext/lib/jcsda-emc/spack-stack/tests/test_setup_meta_modules.py index f62cf95da8..381b44c0c1 100644 --- a/spack-ext/lib/jcsda-emc/spack-stack/tests/test_setup_meta_modules.py +++ b/spack-ext/lib/jcsda-emc/spack-stack/tests/test_setup_meta_modules.py @@ -59,6 +59,8 @@ def test_setup_meta_modules(): environment: unset: - DUMMYVAR + prepend_path: + MODULEPATH: /opt/test-compiler-modulefiles mpi: buildable: false openmpi: @@ -89,6 +91,15 @@ def test_setup_meta_modules(): f"Expected module {expected_comp_meta_module} not found" ) + # The compiler's MODULEPATH must be set before the module loads that need it + with open(expected_comp_meta_module) as f: + comp_meta_module = f.read() + modulepath_line = "prepend-path {MODULEPATH} {/opt/test-compiler-modulefiles}" + load_line = "module load gcc/11.5.0" + assert modulepath_line in comp_meta_module + assert load_line in comp_meta_module + assert comp_meta_module.index(modulepath_line) < comp_meta_module.index(load_line) + expected_mpi_meta_module = os.path.join(module_dir, "gcc", "11.5.0", "stack-openmpi", "5.0.8") assert( os.path.exists(expected_mpi_meta_module), From 071beab6e41be8c42008cb499c058a0564f30d4c Mon Sep 17 00:00:00 2001 From: Ash Pera Date: Mon, 5 Oct 2026 12:30:00 -0600 Subject: [PATCH 2/2] Shorten the MODULEPATH comment and link the issue --- spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py b/spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py index c52ff1889a..d3dae411d9 100755 --- a/spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py +++ b/spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py @@ -424,9 +424,7 @@ def setup_meta_modules(): compiler_subs["COMPFLAGS"] = compiler_subs["COMPFLAGS"].rstrip("\n") logging.debug(" ... ... COMPFLAGS: {}".format(compiler_subs["COMPFLAGS"])) - # Environment variables. A change to MODULEPATH goes with MODULEPATHS, - # which the template emits before MODULELOADS: the compiler's modules may - # be found only in the directories it adds. + # MODULEPATH must be set before the module loads, https://github.com/JCSDA/spack-stack/issues/2144 compiler_modulepaths = "" if "environment" in compiler.extra_attributes.keys(): for action in compiler.extra_attributes["environment"].keys():