Skip to content

Commit 34d3fc9

Browse files
committed
test(e2e): 86_llvm_hermetic_link + llvm suite unpinned from 20.1.7
86 asserts, via a -### dry-run with the exact ldflags mcpp generated, that every CRT object and the effective dynamic linker resolve inside the sandbox (an xpkgs path) — failing on both regression modes of issue #195: bare CRT names (link failure on hosts without a system toolchain) and host-CRT contamination (silent on hosts with one). The llvm e2e scripts (36-41, 47, 65) source the new _llvm_env.sh instead of hardcoding llvm@20.1.7: MCPP_E2E_LLVM_VERSION overrides, default is the newest installed payload — so new toolchain versions get coverage the day they're installed instead of never.
1 parent df7607a commit 34d3fc9

10 files changed

Lines changed: 198 additions & 43 deletions

tests/e2e/36_llvm_toolchain.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
# 36_llvm_toolchain.sh — build a non-module C/C++ package with xlings LLVM.
44
set -e
55

6+
source "$(dirname "$0")/_llvm_env.sh"
7+
68
OS="$(uname -s)"
79
# On Windows the clang++ binary has a .exe suffix
810
if [[ "$OS" == MINGW* || "$OS" == MSYS* || "$OS" == CYGWIN* ]]; then
9-
LLVM_ROOT="${USERPROFILE}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
1011
CLANGPP_BIN="$LLVM_ROOT/bin/clang++.exe"
1112
else
12-
LLVM_ROOT="${HOME}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
1313
CLANGPP_BIN="$LLVM_ROOT/bin/clang++"
1414
fi
1515
if [[ ! -x "$CLANGPP_BIN" ]]; then
16-
echo "SKIP: xlings llvm@20.1.7 is not installed"
16+
echo "SKIP: xlings llvm@${LLVM_VERSION} is not installed"
1717
exit 0
1818
fi
1919

@@ -40,7 +40,7 @@ version = "0.1.0"
4040
import_std = false
4141
4242
[toolchain]
43-
${TC_KEY} = "llvm@20.1.7"
43+
${TC_KEY} = "llvm@${LLVM_VERSION}"
4444
EOF
4545

4646
cat > src/main.cpp <<'EOF'
@@ -61,9 +61,9 @@ int answer(void) {
6161
EOF
6262

6363
"$MCPP" toolchain list > "$TMP/list.log" 2>&1
64-
grep -q 'llvm 20.1.7' "$TMP/list.log" || {
64+
grep -q "llvm ${LLVM_VERSION}" "$TMP/list.log" || {
6565
cat "$TMP/list.log"
66-
echo "FAIL: toolchain list did not show installed llvm 20.1.7"
66+
echo "FAIL: toolchain list did not show installed llvm ${LLVM_VERSION}"
6767
exit 1
6868
}
6969

tests/e2e/37_llvm_import_std.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ if [[ "$OS" == MINGW* || "$OS" == MSYS* || "$OS" == CYGWIN* ]]; then
1212
exit 0
1313
fi
1414

15-
LLVM_ROOT="${HOME}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
15+
source "$(dirname "$0")/_llvm_env.sh"
16+
1617
if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
17-
echo "SKIP: xlings llvm@20.1.7 is not installed"
18+
echo "SKIP: xlings llvm@${LLVM_VERSION} is not installed"
1819
exit 0
1920
fi
2021
if [[ ! -f "$LLVM_ROOT/share/libc++/v1/std.cppm" ]]; then
21-
echo "SKIP: xlings llvm@20.1.7 has no libc++ std.cppm"
22+
echo "SKIP: xlings llvm@${LLVM_VERSION} has no libc++ std.cppm"
2223
exit 0
2324
fi
2425

@@ -30,13 +31,13 @@ source "$(dirname "$0")/_inherit_toolchain.sh"
3031
mkdir -p "$TMP/proj/src"
3132
cd "$TMP/proj"
3233

33-
cat > mcpp.toml <<'EOF'
34+
cat > mcpp.toml <<EOF
3435
[package]
3536
name = "hello_llvm_std"
3637
version = "0.1.0"
3738
3839
[toolchain]
39-
linux = "llvm@20.1.7"
40+
linux = "llvm@${LLVM_VERSION}"
4041
EOF
4142

4243
cat > src/main.cpp <<'EOF'

tests/e2e/38_llvm_modules.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ if [[ "$OS" == MINGW* || "$OS" == MSYS* || "$OS" == CYGWIN* ]]; then
1616
exit 0
1717
fi
1818

19-
LLVM_ROOT="${HOME}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
19+
source "$(dirname "$0")/_llvm_env.sh"
20+
2021
if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
21-
echo "SKIP: xlings llvm@20.1.7 is not installed"
22+
echo "SKIP: xlings llvm@${LLVM_VERSION} is not installed"
2223
exit 0
2324
fi
2425
if [[ ! -f "$LLVM_ROOT/share/libc++/v1/std.cppm" ]]; then
25-
echo "SKIP: xlings llvm@20.1.7 has no libc++ std.cppm"
26+
echo "SKIP: xlings llvm@${LLVM_VERSION} has no libc++ std.cppm"
2627
exit 0
2728
fi
2829

@@ -34,13 +35,13 @@ source "$(dirname "$0")/_inherit_toolchain.sh"
3435
mkdir -p "$TMP/proj/src"
3536
cd "$TMP/proj"
3637

37-
cat > mcpp.toml <<'EOF'
38+
cat > mcpp.toml <<EOF
3839
[package]
3940
name = "llvm_modules"
4041
version = "0.1.0"
4142
4243
[toolchain]
43-
linux = "llvm@20.1.7"
44+
linux = "llvm@${LLVM_VERSION}"
4445
EOF
4546

4647
# Module interface unit: exports greet()

tests/e2e/39_llvm_incremental.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
# 39_llvm_incremental.sh — Clang per-file incremental rebuild via clang-scan-deps dyndep.
44
set -e
55

6-
LLVM_ROOT="${HOME}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
6+
source "$(dirname "$0")/_llvm_env.sh"
7+
78
if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
8-
echo "SKIP: xlings llvm@20.1.7 is not installed"
9+
echo "SKIP: xlings llvm@${LLVM_VERSION} is not installed"
910
exit 0
1011
fi
1112
if [[ ! -f "$LLVM_ROOT/share/libc++/v1/std.cppm" ]]; then
12-
echo "SKIP: xlings llvm@20.1.7 has no libc++ std.cppm"
13+
echo "SKIP: xlings llvm@${LLVM_VERSION} has no libc++ std.cppm"
1314
exit 0
1415
fi
1516

@@ -21,12 +22,12 @@ source "$(dirname "$0")/_inherit_toolchain.sh"
2122
mkdir -p "$TMP/proj/src"
2223
cd "$TMP/proj"
2324

24-
cat > mcpp.toml <<'EOF'
25+
cat > mcpp.toml <<EOF
2526
[package]
2627
name = "llvm_inc"
2728
version = "0.1.0"
2829
[toolchain]
29-
linux = "llvm@20.1.7"
30+
linux = "llvm@${LLVM_VERSION}"
3031
EOF
3132

3233
cat > src/greet.cppm <<'EOF'

tests/e2e/40_llvm_bmi_cache.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ if [[ "$OS" == MINGW* || "$OS" == MSYS* || "$OS" == CYGWIN* ]]; then
1212
exit 0
1313
fi
1414

15-
LLVM_ROOT="${HOME}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
15+
source "$(dirname "$0")/_llvm_env.sh"
16+
1617
if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
17-
echo "SKIP: xlings llvm@20.1.7 is not installed"
18+
echo "SKIP: xlings llvm@${LLVM_VERSION} is not installed"
1819
exit 0
1920
fi
2021
if [[ ! -f "$LLVM_ROOT/share/libc++/v1/std.cppm" ]]; then
21-
echo "SKIP: xlings llvm@20.1.7 has no libc++ std.cppm"
22+
echo "SKIP: xlings llvm@${LLVM_VERSION} has no libc++ std.cppm"
2223
exit 0
2324
fi
2425

@@ -40,12 +41,12 @@ fi
4041
mkdir -p "$TMP/proj/src"
4142
cd "$TMP/proj"
4243

43-
cat > mcpp.toml <<'EOF'
44+
cat > mcpp.toml <<EOF
4445
[package]
4546
name = "llvm_cache"
4647
version = "0.1.0"
4748
[toolchain]
48-
linux = "llvm@20.1.7"
49+
linux = "llvm@${LLVM_VERSION}"
4950
[dependencies]
5051
"mcpplibs.cmdline" = "0.0.1"
5152
EOF

tests/e2e/41_llvm_std_compat.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ if [[ "$OS" == MINGW* || "$OS" == MSYS* || "$OS" == CYGWIN* ]]; then
1212
exit 0
1313
fi
1414

15-
LLVM_ROOT="${HOME}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
15+
source "$(dirname "$0")/_llvm_env.sh"
16+
1617
if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
17-
echo "SKIP: xlings llvm@20.1.7 is not installed"
18+
echo "SKIP: xlings llvm@${LLVM_VERSION} is not installed"
1819
exit 0
1920
fi
2021
if [[ ! -f "$LLVM_ROOT/share/libc++/v1/std.compat.cppm" ]]; then
21-
echo "SKIP: xlings llvm@20.1.7 has no libc++ std.compat.cppm"
22+
echo "SKIP: xlings llvm@${LLVM_VERSION} has no libc++ std.compat.cppm"
2223
exit 0
2324
fi
2425

@@ -30,12 +31,12 @@ source "$(dirname "$0")/_inherit_toolchain.sh"
3031
mkdir -p "$TMP/proj/src"
3132
cd "$TMP/proj"
3233

33-
cat > mcpp.toml <<'EOF'
34+
cat > mcpp.toml <<EOF
3435
[package]
3536
name = "compat_test"
3637
version = "0.1.0"
3738
[toolchain]
38-
linux = "llvm@20.1.7"
39+
linux = "llvm@${LLVM_VERSION}"
3940
EOF
4041

4142
cat > src/main.cpp <<'EOF'

tests/e2e/47_llvm_atomic_link.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ if [[ "$OS" == Darwin* ]]; then
1717
exit 0
1818
fi
1919

20-
LLVM_ROOT="${HOME}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
20+
source "$(dirname "$0")/_llvm_env.sh"
21+
2122
if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
22-
echo "SKIP: xlings llvm@20.1.7 is not installed"
23+
echo "SKIP: xlings llvm@${LLVM_VERSION} is not installed"
2324
exit 0
2425
fi
2526
# The fix only emits -latomic when a link-resolvable libatomic is present in
26-
# the toolchain (self-guarding). 20.1.7 bundles it; if a slimmed package does
27-
# not, the genuine-atomic case is out of scope here.
27+
# the toolchain (self-guarding). If a slimmed package does not bundle it, the
28+
# genuine-atomic case is out of scope here.
2829
if [[ ! -e "$LLVM_ROOT/lib/x86_64-unknown-linux-gnu/libatomic.so" \
2930
&& ! -e "$LLVM_ROOT/lib/x86_64-unknown-linux-gnu/libatomic.a" ]]; then
30-
echo "SKIP: llvm@20.1.7 package ships no link-resolvable libatomic"
31+
echo "SKIP: llvm@${LLVM_VERSION} package ships no link-resolvable libatomic"
3132
exit 0
3233
fi
3334

@@ -39,13 +40,13 @@ source "$(dirname "$0")/_inherit_toolchain.sh"
3940
mkdir -p "$TMP/proj/src"
4041
cd "$TMP/proj"
4142

42-
cat > mcpp.toml <<'EOF'
43+
cat > mcpp.toml <<EOF
4344
[package]
4445
name = "atomic_link"
4546
version = "0.1.0"
4647
4748
[toolchain]
48-
linux = "llvm@20.1.7"
49+
linux = "llvm@${LLVM_VERSION}"
4950
EOF
5051

5152
# 16-byte atomic → __atomic_load_16 / __atomic_compare_exchange_16 libcalls.

tests/e2e/65_toolchain_runtime_dirs_for_run.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ if [[ "$OS" != "Linux" ]]; then
1111
exit 0
1212
fi
1313

14-
LLVM_ROOT="${HOME}/.mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7"
14+
source "$(dirname "$0")/_llvm_env.sh"
15+
1516
if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
16-
echo "SKIP: xlings llvm@20.1.7 is not installed"
17+
echo "SKIP: xlings llvm@${LLVM_VERSION} is not installed"
1718
exit 0
1819
fi
1920

@@ -25,13 +26,13 @@ source "$(dirname "$0")/_inherit_toolchain.sh"
2526
mkdir -p "$TMP/proj/src"
2627
cd "$TMP/proj"
2728

28-
cat > mcpp.toml <<'EOF'
29+
cat > mcpp.toml <<EOF
2930
[package]
3031
name = "toolchain_runtime_env"
3132
version = "0.1.0"
3233
3334
[toolchain]
34-
linux = "llvm@20.1.7"
35+
linux = "llvm@${LLVM_VERSION}"
3536
3637
[targets.toolchain_runtime_env]
3738
kind = "bin"
@@ -47,11 +48,13 @@ int main() {
4748
if (value == nullptr) return 10;
4849
4950
std::string path(value);
50-
if (path.find("xim-x-llvm/20.1.7/lib") == std::string::npos) return 11;
51+
if (path.find("@LLVM_LIB_SUBSTR@") == std::string::npos) return 11;
5152
if (path.find("xim-x-glibc/2.39/lib64") == std::string::npos) return 12;
5253
return 0;
5354
}
5455
EOF
56+
# Inject the resolved LLVM version into the quoted heredoc via a placeholder.
57+
sed -i "s|@LLVM_LIB_SUBSTR@|xim-x-llvm/${LLVM_VERSION}/lib|" src/main.cpp
5558

5659
"$MCPP" build > "$TMP/build.log" 2>&1 || {
5760
cat "$TMP/build.log"

0 commit comments

Comments
 (0)