Skip to content

Commit 291c105

Browse files
committed
chore(diag): no-heredoc guard injection
1 parent e6780b0 commit 291c105

1 file changed

Lines changed: 24 additions & 17 deletions

File tree

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ jobs:
3636
"$MCPP" test -p boost-ext.ut || true
3737
bin=$(find tests/examples/boost-ext.ut/target -name 'ut' -type f | head -1)
3838
echo "BIN=$bin"
39-
echo "=== dyld_info -initializers (symbol names!) ==="
40-
dyld_info -initializers "$bin" 2>&1 | tail -40 || true
41-
echo "=== DYLD_PRINT_INITIALIZERS full (execution order) ==="
42-
DYLD_PRINT_INITIALIZERS=1 "$bin" 2>&1 | grep -v "^dyld\[" | head -10 || true
43-
DYLD_PRINT_INITIALIZERS=1 "$bin" 2>&1 | grep "^dyld\[" | head -40 || true
44-
- name: relink matrix
39+
echo "=== symbolize __init_offsets (ASLR off) ==="
40+
offs=$(otool -s __TEXT __init_offsets "$bin" 2>/dev/null | awk '/Contents of/{next} {for(i=1;i<=NF;i++) print $i}')
41+
printf 'settings set target.disable-aslr true\nrun\n' > /tmp/x.lldb
42+
for off in $offs; do
43+
addr=$((16#$off))
44+
printf 'image lookup -a 0x%x\n' $((0x100000000 + addr)) >> /tmp/x.lldb
45+
done
46+
lldb -b -s /tmp/x.lldb -- "$bin" 2>&1 | grep -E "image lookup|Summary:|Function:|0x100000" | head -60 || true
47+
- name: relink matrix + guard test
4548
shell: bash
4649
env:
4750
MCPP_INDEX_MIRROR: GLOBAL
@@ -51,19 +54,23 @@ jobs:
5154
d=$(ls -d tests/examples/boost-ext.ut/target/aarch64-macos/*/ | head -1)
5255
cd "$d"
5356
C="$clang -nostdinc++ -isystem $pkgroot/include/c++/v1 --sysroot=$(xcrun --show-sdk-path) -mmacosx-version-min=14.0"
57+
stdpcm=$(ls pcm.cache/std.pcm 2>/dev/null)
58+
cppm=$(find tests/examples/boost-ext.ut -path '*generated*/boost.ut.cppm' | head -1)
59+
echo "CPPM=$cppm STD=$stdpcm"
5460
runit() { if ./"$1" >/tmp/out.txt 2>&1; then echo "$2 exit: 0 :: $(head -1 /tmp/out.txt)"; else echo "$2 exit: $? :: $(head -1 /tmp/out.txt)"; fi; }
5561
$C -o ut_f obj/ut.o obj/boost.ut.m.o "$pkgroot/lib/libc++.a" "$pkgroot/lib/libc++abi.a" 2>&1 | tail -2
5662
runit ut_f "F(static plain)"
57-
echo " F initializers:"; dyld_info -initializers ut_f 2>&1 | tail -25
5863
$C -o ut_g obj/ut.o obj/boost.ut.m.o -Wl,-no_dead_strip "$pkgroot/lib/libc++.a" "$pkgroot/lib/libc++abi.a" 2>&1 | tail -2
5964
runit ut_g "G(no_dead_strip)"
60-
echo " G initializers:"; dyld_info -initializers ut_g 2>&1 | tail -25
61-
tmp=$(mktemp -d)
62-
(cd "$tmp" && ar -x "$pkgroot/lib/libc++.a" iostream.cpp.o 2>/dev/null || true)
63-
$C -o ut_i obj/ut.o obj/boost.ut.m.o "$tmp/iostream.cpp.o" "$pkgroot/lib/libc++.a" "$pkgroot/lib/libc++abi.a" 2>&1 | tail -2
64-
runit ut_i "I(force iostream.o)"
65-
$C -o ut_m obj/ut.o obj/boost.ut.m.o -L"$pkgroot/lib" -lc++ -lc++abi 2>&1 | tail -2
66-
otool -L ut_m 2>/dev/null | grep -i c++ || true
67-
runit ut_m "M(xpkg dylib)"
68-
$C -o ut_d obj/ut.o obj/boost.ut.m.o -Wl,-dead_strip "$pkgroot/lib/libc++.a" "$pkgroot/lib/libc++abi.a" 2>&1 | tail -2
69-
runit ut_d "D(dead_strip explicit)"
65+
echo "=== K: recompile cppm with ios_base::Init guard, static link ==="
66+
cp "$cppm" /tmp/guarded.cppm
67+
python3 -c "p='/tmp/guarded.cppm'; s=open(p).read(); g='namespace {\nstruct [[maybe_unused]] ut_stream_guard { std::ios_base::Init init; };\n[[maybe_unused]] ut_stream_guard ut_ensure_streams{};\n}\n'; m='#define BOOST_UT_CXX_MODULES 1'; assert m in s; open(p,'w').write(s.replace(m, g+m)); print('guard injected')"
68+
$C -std=c++23 -fmodule-file=std=$stdpcm -fprebuilt-module-path=pcm.cache -O0 -g --no-default-config -Wno-template-body -c /tmp/guarded.cppm -o obj/guarded.m.o 2>&1 | tail -3
69+
$C -o ut_k obj/ut.o obj/guarded.m.o "$pkgroot/lib/libc++.a" "$pkgroot/lib/libc++abi.a" 2>&1 | tail -2
70+
runit ut_k "K(guard static plain)"
71+
echo " K initializer order:"; printf 'settings set target.disable-aslr true\nrun\n' > /tmp/y.lldb
72+
offs=$(otool -s __TEXT __init_offsets ut_k 2>/dev/null | awk '/Contents of/{next} {for(i=1;i<=NF;i++) print $i}')
73+
for off in $offs; do addr=$((16#$off)); printf 'image lookup -a 0x%x\n' $((0x100000000 + addr)) >> /tmp/y.lldb; done
74+
lldb -b -s /tmp/y.lldb -- ./ut_k 2>&1 | grep -E "Summary:|Function:" | head -30 || true
75+
$C -o ut_l obj/ut.o obj/guarded.m.o -Wl,-no_dead_strip "$pkgroot/lib/libc++.a" "$pkgroot/lib/libc++abi.a" 2>&1 | tail -2
76+
runit ut_l "L(guard no_dead_strip)"

0 commit comments

Comments
 (0)