Skip to content

Commit a1d6609

Browse files
committed
chore(diag): symbol forensics + mini repro matrix (std.pcm x force-load)
1 parent 39a0942 commit a1d6609

1 file changed

Lines changed: 44 additions & 26 deletions

File tree

.github/workflows/diag-ut-macos.yml

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,61 @@ jobs:
2727
echo "MCPP=$root/bin/mcpp" >> "$GITHUB_ENV"
2828
echo "MCPP_VENDORED_XLINGS=$root/registry/bin/xlings" >> "$GITHUB_ENV"
2929
echo "$root/bin" >> "$GITHUB_PATH"
30-
- name: mcpp test (collect crash)
30+
- name: mcpp test + symbol forensics
3131
shell: bash
3232
env:
3333
MCPP_INDEX_MIRROR: GLOBAL
3434
run: |
3535
"$MCPP" --version
3636
"$MCPP" test -p boost-ext.ut || true
37-
bin=$(find tests/examples/boost-ext.ut/target -name 'ut' -type f 2>/dev/null | head -1)
38-
echo "BIN=$bin"
39-
if [ -n "$bin" ]; then
40-
echo "=== otool -L ==="
41-
otool -L "$bin" || true
42-
echo "=== nm: cout / stream / init symbols ==="
43-
nm -nm "$bin" 2>/dev/null | grep -iE "cout|iostream|DoIOSInit|start_std_streams|ios_base" || true
44-
echo "=== DYLD_PRINT_INITIALIZERS ==="
45-
DYLD_PRINT_INITIALIZERS=1 "$bin" 2>&1 | tail -100 || true
46-
echo "=== lldb deep ==="
47-
printf 'run\nbt\nregister read pc sp x0\ndisassemble --pc\nimage lookup -rn "cout"\nimage lookup -rn "DoIOSInit"\nimage lookup -rn "start_std_streams"\nimage lookup -rn "reporter_junit"\n' > ut.lldb
48-
lldb -b -s ut.lldb -- "$bin" 2>&1 | tail -250 || true
49-
echo "=== compile_commands (module build flags) ==="
50-
find tests/examples/boost-ext.ut -name 'compile_commands.json' -exec cat {} \; 2>/dev/null | head -80 || true
51-
fi
52-
- name: minimal module repro (same toolchain)
37+
echo "=== locate binary/objs ==="
38+
dir=tests/examples/boost-ext.ut/target/aarch64-macos
39+
d=$(ls -d $dir/*/ | head -1)
40+
echo "TARGETDIR=$d"
41+
bin="$d/bin/ut"
42+
echo "=== module object: cout references ==="
43+
nm -nm "$d/obj/boost.ut.m.o" 2>/dev/null | grep -iE "cout|ios_base" || echo "(none)"
44+
echo "=== module object: all undefined ==="
45+
nm -u "$d/obj/boost.ut.m.o" 2>/dev/null | grep -iE "cout" || echo "(no cout undefined)"
46+
echo "=== test object: cout references ==="
47+
nm -nm "$d/obj/ut.o" 2>/dev/null | grep -iE "cout|ios_base" || echo "(none)"
48+
echo "=== binary: undefined symbols (cout/init) ==="
49+
nm -u "$bin" 2>/dev/null | grep -iE "cout|ios_base|Init" || echo "(none)"
50+
echo "=== binary: defined data (cout) ==="
51+
nm -nm "$bin" 2>/dev/null | grep -iE "cout" | grep -iE "data|const|common" || echo "(no cout data symbol)"
52+
echo "=== binary: __mod_init_func count ==="
53+
otool -l "$bin" | grep -A3 "mod_init_func" || echo "(no mod_init_func)"
54+
echo "=== link flags (verbose mcpp) ==="
55+
"$MCPP" test -p boost-ext.ut -v 2>&1 | grep -iE "clang|ld|libc|o bin" | tail -30 || true
56+
- name: mini repro matrix with xpkg clang
5357
shell: bash
5458
env:
5559
MCPP_INDEX_MIRROR: GLOBAL
5660
run: |
57-
clang=$(find "$HOME/.mcpp" tests/examples/boost-ext.ut/.mcpp -name 'clang++' -type f 2>/dev/null | head -1)
61+
clang=$(python3 -c "import json;print(json.load(open('tests/examples/boost-ext.ut/compile_commands.json'))[0]['arguments'][0])")
62+
pkgroot=$(dirname $(dirname $clang))
5863
echo "CLANG=$clang"
64+
echo "PKGROOT=$pkgroot"
65+
ls "$pkgroot/lib" | head -20
5966
mkdir -p /tmp/repro && cd /tmp/repro
6067
printf 'module;\n#include <iostream>\nexport module mini;\nexport inline int the_stream = (std::cout.rdbuf() != nullptr) ? 1 : 0;\n' > mini.cppm
6168
printf 'import mini;\nint main() { return std::cout.rdbuf() != nullptr ? 0 : 1; }\n' > main.cpp
62-
printf 'import std;\nimport mini;\nint main() { return std::cout.rdbuf() != nullptr ? 0 : 1; }\n' > main_importstd.cpp
63-
"$clang" -std=c++23 --precompile mini.cppm -o mini.pcm && \
64-
"$clang" -std=c++23 -fmodule-file=mini=mini.pcm main.cpp mini.pcm -o mini && \
65-
./mini; echo "mini(no import std) exit: $?"
66-
"$clang" -std=c++23 -fmodule-file=mini=mini.pcm main_importstd.cpp mini.pcm -o mini2 && \
67-
./mini2; echo "mini(import std) exit: $?"
68-
printf '#include <iostream>\ninline int h = (std::cout.rdbuf() != nullptr) ? 1 : 0;\nint main() { return std::cout.rdbuf() != nullptr ? 0 : 1; }\n' > header.cpp
69-
"$clang" -std=c++23 header.cpp -o header && ./header; echo "header-form exit: $?"
69+
echo "--- mini A: no std.pcm, plain link ---"
70+
"$clang" -std=c++23 --precompile mini.cppm -o a.pcm && \
71+
"$clang" -std=c++23 -fmodule-file=mini=a.pcm main.cpp a.pcm -o a 2>&1 | tail -3
72+
nm -u a 2>/dev/null | grep -i cout || echo "(no undefined cout)"
73+
./a; echo "A exit: $?"
74+
echo "--- mini B: no std.pcm, force_load libc++.a ---"
75+
"$clang" -std=c++23 -fmodule-file=mini=a.pcm main.cpp a.pcm -Wl,-force_load,"$pkgroot/lib/libc++.a" -o b 2>&1 | tail -3
76+
nm -nm b 2>/dev/null | grep -iE "cout" | grep -iE "data|const" || echo "(no cout data)"
77+
./b; echo "B exit: $?"
78+
echo "--- mini C: with std.pcm (mirror mcpp), plain link ---"
79+
stdfile=tests/examples/boost-ext.ut/target/aarch64-macos/*/pcm.cache/std.pcm
80+
stdfile=$(ls $stdfile 2>/dev/null | head -1)
81+
echo "STD=$stdfile"
82+
"$clang" -std=c++23 -fmodule-file=std=$stdfile --precompile mini.cppm -o c.pcm 2>&1 | tail -3 && \
83+
"$clang" -std=c++23 -fmodule-file=mini=c.pcm -fmodule-file=std=$stdfile main.cpp c.pcm -o c 2>&1 | tail -3
84+
./c; echo "C exit: $?"
85+
echo "--- mini D: std.pcm + force_load ---"
86+
"$clang" -std=c++23 -fmodule-file=mini=c.pcm -fmodule-file=std=$stdfile main.cpp c.pcm -Wl,-force_load,"$pkgroot/lib/libc++.a" -o d 2>&1 | tail -3
87+
./d; echo "D exit: $?"

0 commit comments

Comments
 (0)