diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2024-04-25 13:33:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 13:33:50 +0200 |
commit | 4a40a76291f05fdd76e12497b1891c5ad1705ebe (patch) | |
tree | 0fd783a8612af4ab1fa147c074b4ccd40f5e7f16 /lib | |
parent | fe9ddf22fc95e8c6c0517f9eb058a5d4a5916a5d (diff) | |
download | spack-4a40a76291f05fdd76e12497b1891c5ad1705ebe.tar.gz spack-4a40a76291f05fdd76e12497b1891c5ad1705ebe.tar.bz2 spack-4a40a76291f05fdd76e12497b1891c5ad1705ebe.tar.xz spack-4a40a76291f05fdd76e12497b1891c5ad1705ebe.zip |
build_environment.py: expand SPACK_MANAGED_DIRS with realpath (#43844)
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/spack/env/cc | 24 | ||||
-rw-r--r-- | lib/spack/spack/build_environment.py | 11 |
2 files changed, 19 insertions, 16 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc index 52fc8f524d..11b08f4752 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -174,18 +174,6 @@ preextend() { unset IFS } -# eval this because SPACK_MANAGED_DIRS and SPACK_SYSTEM_DIRS are inputs we don't wanna loop over. -# moving the eval inside the function would eval it every call. -eval "\ -path_order() { -case \"\$1\" in - $SPACK_MANAGED_DIRS) return 0 ;; - $SPACK_SYSTEM_DIRS) return 2 ;; - /*) return 1 ;; -esac -} -" - # Fail with a clear message if the input contains any bell characters. if eval "[ \"\${*#*${lsep}}\" != \"\$*\" ]"; then die "Compiler command line contains our separator ('${lsep}'). Cannot parse." @@ -198,6 +186,18 @@ for param in $params; do fi done +# eval this because SPACK_MANAGED_DIRS and SPACK_SYSTEM_DIRS are inputs we don't wanna loop over. +# moving the eval inside the function would eval it every call. +eval "\ +path_order() { +case \"\$1\" in + $SPACK_MANAGED_DIRS) return 0 ;; + $SPACK_SYSTEM_DIRS) return 2 ;; + /*) return 1 ;; +esac +} +" + # Check if optional parameters are defined # If we aren't asking for debug flags, don't add them if [ -z "${SPACK_ADD_DEBUG_FLAGS:-}" ]; then diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 86934daf24..00c1c5ab4f 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -43,7 +43,7 @@ import types from collections import defaultdict from enum import Flag, auto from itertools import chain -from typing import List, Tuple +from typing import List, Set, Tuple import llnl.util.tty as tty from llnl.string import plural @@ -551,13 +551,16 @@ def set_wrapper_variables(pkg, env): include_dirs = list(dedupe(filter_system_paths(include_dirs))) rpath_dirs = list(dedupe(filter_system_paths(rpath_dirs))) - spack_managed_dirs: List[str] = [ + # Spack managed directories include the stage, store and upstream stores. We extend this with + # their real paths to make it more robust (e.g. /tmp vs /private/tmp on macOS). + spack_managed_dirs: Set[str] = { spack.stage.get_stage_root(), spack.store.STORE.db.root, *(db.root for db in spack.store.STORE.db.upstream_dbs), - ] + } + spack_managed_dirs.update([os.path.realpath(p) for p in spack_managed_dirs]) - env.set(SPACK_MANAGED_DIRS, "|".join(f'"{p}/"*' for p in spack_managed_dirs)) + env.set(SPACK_MANAGED_DIRS, "|".join(f'"{p}/"*' for p in sorted(spack_managed_dirs))) is_spack_managed = lambda p: any(p.startswith(store) for store in spack_managed_dirs) link_dirs_spack, link_dirs_system = stable_partition(link_dirs, is_spack_managed) include_dirs_spack, include_dirs_system = stable_partition(include_dirs, is_spack_managed) |