From 094b55919af9389ee746433e95d0c133bb2a6524 Mon Sep 17 00:00:00 2001 From: Danny Date: Fri, 20 Mar 2026 13:41:04 +0100 Subject: [PATCH] Added Debug --- toolchain/scripts/024-chroot-essentials.sh | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/toolchain/scripts/024-chroot-essentials.sh b/toolchain/scripts/024-chroot-essentials.sh index 018ebce..b30c6bc 100755 --- a/toolchain/scripts/024-chroot-essentials.sh +++ b/toolchain/scripts/024-chroot-essentials.sh @@ -69,5 +69,54 @@ install -o root -g root -m 664 /dev/null /var/log/faillog install -o root -g utmp -m 664 /dev/null /var/log/wtmp echo "=== Essential files and symlinks created ===" +echo "" + +# --- Verify compiler works inside chroot -------------------------------------- +echo ">>> Verifying gcc works inside chroot..." +echo "" + +# Show where gcc is +echo " which gcc: $(which gcc 2>&1 || echo 'NOT FOUND')" +echo " which cc: $(which cc 2>&1 || echo 'NOT FOUND')" +echo " which ld: $(which ld 2>&1 || echo 'NOT FOUND')" +echo "" + +# Check for the dynamic linker +if [ -e /lib64/ld-linux-x86-64.so.2 ]; then + echo " /lib64/ld-linux-x86-64.so.2: EXISTS" + ls -la /lib64/ld-linux-x86-64.so.2 +else + echo " WARNING: /lib64/ld-linux-x86-64.so.2 NOT FOUND" + echo " Checking /usr/lib..." + ls -la /usr/lib/ld-linux-x86-64.so.2 2>/dev/null || echo " /usr/lib/ld-linux-x86-64.so.2 NOT FOUND" + echo " Contents of /lib64/:" + ls -la /lib64/ 2>/dev/null || echo " /lib64 does not exist" +fi +echo "" + +# Check for crt files +echo " crt1.o: $(find /usr/lib -name crt1.o 2>/dev/null || echo 'NOT FOUND')" +echo " crti.o: $(find /usr/lib -name crti.o 2>/dev/null || echo 'NOT FOUND')" +echo "" + +# Try to compile a test program +echo " Testing: echo 'int main(){}' | gcc -x c - -o /tmp/test-gcc" +if echo 'int main(){}' | gcc -x c - -o /tmp/test-gcc 2>/tmp/gcc-test-error.log; then + echo " PASS: gcc can create executables" + rm -f /tmp/test-gcc +else + echo " FAIL: gcc cannot create executables!" + echo " Error output:" + cat /tmp/gcc-test-error.log + echo "" + echo " Trying with verbose output:" + echo 'int main(){}' | gcc -v -x c - -o /tmp/test-gcc 2>&1 | tail -30 + echo "" + echo " gcc search dirs:" + gcc -print-search-dirs 2>&1 | head -10 + exit 1 +fi +rm -f /tmp/gcc-test-error.log + echo "" echo "Next: Run the chroot build scripts (025-xxx) to build additional tools."