Skip to content

Commit 476a92c

Browse files
committed
[temp] probe: Termux exec modes, musl gcc pass, ELF types
1 parent 556016d commit 476a92c

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

‎.github/probe/termux_docker.sh‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,20 @@ docker run --rm --privileged --entrypoint /system/bin/sh \
3737
2>&1 | tee "$LOGS/pass2/container.log"
3838
say "- pass 2 (/bin -> /system/bin) exit: ${PIPESTATUS[0]}, wall: $(( $(date +%s) - start )) s"
3939

40+
# Pass 3: as pass 2, with the static musl gcc an Android default would use (D21).
41+
mkdir -p "$LOGS/pass3"; chmod 777 "$LOGS/pass3"
42+
start=$(date +%s)
43+
docker run --rm --privileged --entrypoint /system/bin/sh \
44+
-v "$DL:/mnt/dl:ro" -v "$LOGS/pass3:/mnt/logs" -e PROBE_BUILD_ARGS="--toolchain gcc@15.1.0-musl" \
45+
termux/termux-docker:aarch64 -c 'ln -s /system/bin /bin; exec /entrypoint.sh bash /mnt/dl/termux_inner.sh' \
46+
2>&1 | tee "$LOGS/pass3/container.log"
47+
say "- pass 3 (/bin -> /system/bin, --toolchain gcc@15.1.0-musl) exit: ${PIPESTATUS[0]}, wall: $(( $(date +%s) - start )) s"
48+
4049
say '### environment'
4150
say '```'
42-
for f in "$LOGS/container.log" "$LOGS/pass2/container.log"; do echo "-- $f" >> "$S"; grep -E "^(ENV|UNAME|ID|HARDLINK|XLINGS|MCPP|STAGE|TIMING)" "$f" | head -60 >> "$S"; done
51+
for f in "$LOGS/container.log" "$LOGS/pass2/container.log" "$LOGS/pass3/container.log"; do echo "-- $f" >> "$S"; grep -E "^(ENV|UNAME|ID|HARDLINK|XLINGS|MCPP|STAGE|TIMING|ELF)" "$f" | head -60 >> "$S"; done
4352
say '```'
44-
for pass in . pass2; do
53+
for pass in . pass2 pass3; do
4554
say "### first run ($pass): key lines"
4655
say '```'
4756
grep -E 'First run|Resolving|Resolved|Installing|Downloading|Planning|error|warning|hint|Finished|TIMING|glibc|llvm|musl|Can.t create' \

‎.github/probe/termux_emulator.sh‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ run)
4444
# A Termux session's environment, as the app sets it up for its shell.
4545
TENV="PREFIX=$A/usr HOME=$A/home TMPDIR=$A/usr/tmp PATH=$A/usr/bin LANG=en_US.UTF-8 LD_PRELOAD=$A/usr/lib/libtermux-exec.so"
4646
start=$(date +%s)
47-
timeout 5400 adb shell run-as com.termux $A/usr/bin/env $TENV \
48-
PROBE_OUT=$A/probe/out PROBE_TARBALL=$A/probe/mcpp.tar.gz PROBE_HOME=$A/home \
47+
# Session A: the environment a Termux shell has (termux-exec preloaded).
48+
timeout 2400 adb shell run-as com.termux $A/usr/bin/env $TENV \
49+
PROBE_OUT=$A/probe/outA PROBE_TARBALL=$A/probe/mcpp.tar.gz PROBE_HOME=$A/home \
4950
$A/usr/bin/sh $A/probe/termux_inner.sh 2>&1 | tee "$LOGS/inner.log"
51+
# Session B: the same without termux-exec, so the binaries are exec'd directly.
52+
TENVB="PREFIX=$A/usr HOME=$A/homeB TMPDIR=$A/usr/tmp PATH=$A/usr/bin LANG=en_US.UTF-8"
53+
timeout 3000 adb shell run-as com.termux $A/usr/bin/env $TENVB \
54+
PROBE_OUT=$A/probe/outB PROBE_TARBALL=$A/probe/mcpp.tar.gz PROBE_HOME=$A/homeB \
55+
$A/usr/bin/sh $A/probe/termux_inner.sh 2>&1 | sed 's/^/[B] /' | tee -a "$LOGS/inner.log"
5056
say "- wall: $(( $(date +%s) - start )) s"
5157
for f in first-build.log; do
5258
adb shell run-as com.termux cat "$A/probe/out/$f" > "$LOGS/$f" 2>/dev/null
@@ -55,12 +61,12 @@ run)
5561
say '### sandbox'
5662
say '```'
5763
cat "$LOGS/sandbox.txt" >> "$S"
58-
grep -E '^(ENV|UNAME|ID|HARDLINK|MCPP|TIMING|XLINGS|STAGE)' "$LOGS/inner.log" >> "$S"
64+
grep -E '^(\[B\] )?(ENV|UNAME|ID|HARDLINK|MCPP|TIMING|XLINGS|STAGE|ELF)' "$LOGS/inner.log" >> "$S"
5965
say '```'
6066
say '### first run: key lines'
6167
say '```'
6268
grep -E 'First run|Resolving|Resolved|Installing|Downloading|error|warning|hint|Finished|glibc|llvm|musl|Can.t create|did not complete' \
63-
"$LOGS/inner.log" | head -60 >> "$S"
69+
"$LOGS/inner.log" | head -90 >> "$S"
6470
say '```'
6571
say '### plan stage timings'
6672
say '```'

‎.github/probe/termux_inner.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export TMPDIR="${TMPDIR:-$HOME/tmp}"; mkdir -p "$TMPDIR"
1111

1212
echo "ENV ANDROID_ROOT=${ANDROID_ROOT-<unset>} ANDROID_DATA=${ANDROID_DATA-<unset>} PREFIX=${PREFIX-<unset>} TERMUX_VERSION=${TERMUX_VERSION-<unset>}"
1313
echo "ENV HOME=$HOME TMPDIR=$TMPDIR SSL_CERT_FILE=${SSL_CERT_FILE-<unset>}"
14+
echo "ENV TERMUX_EXEC: LD_PRELOAD=${LD_PRELOAD-<unset>} $(env | grep -i TERMUX_EXEC | tr '\n' ' ')"
1415
echo "ENV linker64: $(ls -l /system/bin/linker64 2>&1 | head -1)"
1516
echo "UNAME $(uname -a 2>&1)"
1617
echo "ID $(id 2>&1)"
@@ -40,8 +41,9 @@ cd "$HOME/hello"
4041
printf '[package]\nname = "hello"\nversion = "0.1.0"\n\n[targets.hello]\nkind = "bin"\nmain = "src/main.cpp"\n' > mcpp.toml
4142
printf 'import std;\nint main() { std::println("hello from termux"); }\n' > src/main.cpp
4243

44+
echo "ELF mcpp: $(od -An -tx1 -j16 -N2 "$MCPP" | tr -d ' \n') (0200=ET_EXEC 0300=ET_DYN)"
4345
t0=$(date +%s)
44-
MCPP_LOG_LEVEL=info timeout 3600 "$MCPP" build --verbose > "$OUT/first-build.log" 2>&1
46+
MCPP_LOG_LEVEL=info timeout 3600 "$MCPP" build --verbose ${PROBE_BUILD_ARGS:-} > "$OUT/first-build.log" 2>&1
4547
rc=$?
4648
cat "$OUT/first-build.log"
4749
echo "TIMING first build: exit $rc, $(( $(date +%s) - t0 )) s"
@@ -52,6 +54,9 @@ echo "TIMING run: $(( $(date +%s) - t0 )) s"
5254
mkdir -p "$OUT/mcpp-log"
5355
cp -r "$HOME"/.mcpp/log/. "$OUT/mcpp-log/" 2>/dev/null
5456
cp -r "$(dirname "$(dirname "$MCPP")")"/log/. "$OUT/mcpp-log/" 2>/dev/null
57+
for b in "$(dirname "$(dirname "$MCPP")")"/registry/data/xpkgs/*/*/bin/*; do
58+
case "$b" in *gcc*|*g++*|*clang++|*ld|*as|*ninja|*patchelf) echo "ELF $(basename "$(dirname "$(dirname "$b")")")/$(basename "$b"): $(od -An -tx1 -j16 -N2 "$b" 2>/dev/null | tr -d ' \n')";; esac
59+
done 2>/dev/null | sort -u | head -20
5560
grep -h 'build/stage' "$OUT"/mcpp-log/*.log 2>/dev/null | tail -30 | sed 's/^/STAGE /'
5661
cp "$TMPDIR"/mcpp-xlings-*.stderr "$OUT/" 2>/dev/null
5762
ls "$HOME"/.mcpp/registry/logs/hooks/ 2>/dev/null | head

0 commit comments

Comments
 (0)