summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin.mock/packages
diff options
context:
space:
mode:
authorTom Scogland <tom.scogland@gmail.com>2022-11-05 00:09:35 -1000
committerGitHub <noreply@github.com>2022-11-05 11:09:35 +0100
commit3346c0918bb939f3e82033ddde0a2378c602650d (patch)
tree66552915f3a353061fcf89633dc8531ee6c1e946 /var/spack/repos/builtin.mock/packages
parent71d480515b098118c5f1d84f255c4080f55c62e8 (diff)
downloadspack-3346c0918bb939f3e82033ddde0a2378c602650d.tar.gz
spack-3346c0918bb939f3e82033ddde0a2378c602650d.tar.bz2
spack-3346c0918bb939f3e82033ddde0a2378c602650d.tar.xz
spack-3346c0918bb939f3e82033ddde0a2378c602650d.zip
Fix relocation to avoid overwriting merged constant strings (#32253)
Compilers and linker optimize string constants for space by aliasing them when one is a suffix of another. For gcc / binutils this happens already at -O1, due to -fmerge-constants. This means that we have to take care during relocation to always preserve a certain length of the suffix of those prefixes that are C-strings. In this commit we pick length 7 as a safe suffix length, assuming the suffix is typically the 7 characters from the hash (i.e. random), so it's unlikely to alias with any string constant used in the sources. In general we now pad shortened strings from the left with leading dir seperators, but in the case of C-strings that are much shorter and don't share a common suffix (due to projections), we do allow shrinking the C-string, appending a null, and retaining the old part of the prefix. Also when rewiring, we ensure that the new hash preserves the last 7 bytes of the old hash. Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Diffstat (limited to 'var/spack/repos/builtin.mock/packages')
-rw-r--r--var/spack/repos/builtin.mock/packages/garply/package.py7
-rw-r--r--var/spack/repos/builtin.mock/packages/quux/package.py7
2 files changed, 12 insertions, 2 deletions
diff --git a/var/spack/repos/builtin.mock/packages/garply/package.py b/var/spack/repos/builtin.mock/packages/garply/package.py
index 819da45286..7fc3fd484a 100644
--- a/var/spack/repos/builtin.mock/packages/garply/package.py
+++ b/var/spack/repos/builtin.mock/packages/garply/package.py
@@ -83,7 +83,12 @@ const int garply_version_minor = %s;
f.write(garply_cc % prefix.config)
with open("%s/garply/garplinator.cc" % self.stage.source_path, "w") as f:
f.write(garplinator_cc)
- gpp = which("/usr/bin/g++")
+ gpp = which(
+ "g++",
+ path=":".join(
+ [s for s in os.environ["PATH"].split(os.pathsep) if "lib/spack/env" not in s]
+ ),
+ )
if sys.platform == "darwin":
gpp = which("/usr/bin/clang++")
gpp(
diff --git a/var/spack/repos/builtin.mock/packages/quux/package.py b/var/spack/repos/builtin.mock/packages/quux/package.py
index 693ef07ba4..de4f8b9327 100644
--- a/var/spack/repos/builtin.mock/packages/quux/package.py
+++ b/var/spack/repos/builtin.mock/packages/quux/package.py
@@ -97,7 +97,12 @@ const int quux_version_minor = %s;
f.write(quux_h)
with open("%s/quux/quuxifier.cc" % self.stage.source_path, "w") as f:
f.write(quuxifier_cc)
- gpp = which("/usr/bin/g++")
+ gpp = which(
+ "g++",
+ path=":".join(
+ [s for s in os.environ["PATH"].split(os.pathsep) if "lib/spack/env" not in s]
+ ),
+ )
if sys.platform == "darwin":
gpp = which("/usr/bin/clang++")
gpp(