From: Thomas Walker Lynch Date: Mon, 5 May 2025 07:37:35 +0000 (-0700) Subject: cp X-Git-Url: https://git.reasoningtechnology.com/usr/lib/python2.7/encodings/iso8859_16.py?a=commitdiff_plain;h=34efd69cf41eea71276d38cb07e0e2b6dc99adfc;p=RT-gcc cp --- diff --git "a/script\360\237\226\211/audit_glibc_headers.sh" "b/script\360\237\226\211/audit_glibc_headers.sh" new file mode 100755 index 0000000..64ddd57 --- /dev/null +++ "b/script\360\237\226\211/audit_glibc_headers.sh" @@ -0,0 +1,50 @@ +#!/bin/bash +set -euo pipefail + +source "$(dirname "$0")/environment.sh" + +echo "🔎 Auditing glibc build state..." + +declare -a missing +declare -a present + +# GLIBC_BUILD sanity +[[ -d "$GLIBC_BUILD" ]] && present+=("GLIBC_BUILD exists: $GLIBC_BUILD") || missing+=("GLIBC_BUILD missing") + +# Check for Makefile +if [[ -s "$GLIBC_BUILD/Makefile" ]]; then + present+=("Makefile exists and non-empty") +else + missing+=("Makefile missing or empty in $GLIBC_BUILD") +fi + +# Check bits/stdio_lim.h +if [[ -f "$GLIBC_BUILD/bits/stdio_lim.h" ]]; then + present+=("bits/stdio_lim.h exists (post-header install marker)") +else + missing+=("bits/stdio_lim.h missing — make install-headers likely incomplete") +fi + +# Check csu/Makefile +if [[ -f "$GLIBC_BUILD/csu/Makefile" ]]; then + present+=("csu/Makefile exists") + grep -q 'crt1\.o' "$GLIBC_BUILD/csu/Makefile" \ + && present+=("csu/Makefile defines crt1.o") \ + || missing+=("csu/Makefile missing rule for crt1.o") +else + missing+=("csu/Makefile missing") +fi + +# Show report +echo "✅ Present:" +for p in "${present[@]}"; do echo " $p"; done + +echo +if (( ${#missing[@]} )); then + echo "❌ Missing:" + for m in "${missing[@]}"; do echo " $m"; done + exit 1 +else + echo "🎉 All bootstrap prerequisites are in place" + exit 0 +fi diff --git "a/script\360\237\226\211/build_Linux_requisites.sh" "b/script\360\237\226\211/build_Linux_requisites.sh" old mode 100644 new mode 100755 diff --git "a/script\360\237\226\211/build_all.sh" "b/script\360\237\226\211/build_all.sh" index 920a8f7..201e76f 100755 --- "a/script\360\237\226\211/build_all.sh" +++ "b/script\360\237\226\211/build_all.sh" @@ -21,8 +21,8 @@ cd "$SCRIPT_DIR" ./build_linux_requisites.sh ./build_linux.sh -./prepare_glibc_sources.sh -./build_glibc_headers.sh +#./build_glibc_bootstrap_requisites.sh +./build_glibc_bootstrap.sh ./build_gcc_stage1_requisites.sh ./build_gcc_stage1.sh diff --git "a/script\360\237\226\211/build_glibc_bootstrap.sh" "b/script\360\237\226\211/build_glibc_bootstrap.sh" new file mode 100755 index 0000000..b1c5c73 --- /dev/null +++ "b/script\360\237\226\211/build_glibc_bootstrap.sh" @@ -0,0 +1,40 @@ +#!/bin/bash +set -euo pipefail + +source "$(dirname "$0")/environment.sh" + +echo "📦 Building glibc startup files (crt*.o)..." + +pushd "$GLIBC_BUILD" + + # Confirm that required build artifacts are present + if [[ ! -f bits/stdio_lim.h ]]; then + echo "❌ Missing bits/stdio_lim.h — did you run build_glibc_headers.sh?" + exit 1 + fi + + if [[ ! -f csu/Makefile ]]; then + echo "❌ Missing csu/Makefile — glibc configure phase may have failed" + exit 1 + fi + + # Attempt to build the crt startup object files + make csu/crt1.o csu/crti.o csu/crtn.o -j"$MAKE_JOBS" + + # Install them to the sysroot + install -m 644 csu/crt1.o csu/crti.o csu/crtn.o "$SYSROOT/usr/lib" + + # Create a dummy libc.so to satisfy linker if needed + touch "$SYSROOT/usr/lib/libc.so" + + # ✅ Verify installation + for f in crt1.o crti.o crtn.o; do + if [[ ! -f "$SYSROOT/usr/lib/$f" ]]; then + echo "❌ Missing startup file after install: $f" + exit 1 + fi + done + +popd + +echo "✅ glibc startup files installed to $SYSROOT/usr/lib" diff --git "a/script\360\237\226\211/build_glibc_bootstrap_requisites.sh" "b/script\360\237\226\211/build_glibc_bootstrap_requisites.sh" new file mode 100755 index 0000000..e10ea96 --- /dev/null +++ "b/script\360\237\226\211/build_glibc_bootstrap_requisites.sh" @@ -0,0 +1,138 @@ +#!/bin/bash +set -euo pipefail + +source "$(dirname "$0")/environment.sh" + +echo "📦 Checking requisites for glibc startup file build (crt1.o, crti.o, crtn.o)." + +missing_requisite_list=() +found_requisite_list=() + +# ──────────────────────────────────────────────── +# 1. Required tools +# + required_tools=( + "gcc" + "g++" + "make" + "ld" + "as" + ) + + for tool in "${required_tools[@]}"; do + if location=$(command -v "$tool"); then + found_requisite_list+=("$location") + else + missing_requisite_list+=("$tool") + fi + done + +# ──────────────────────────────────────────────── +# 2. Required directories and sources +# + if [ -d "$GLIBC_SRC" ] && [ "$(ls -A "$GLIBC_SRC")" ]; then + found_requisite_list+=("$GLIBC_SRC") + else + missing_requisite_list+=("$GLIBC_SRC (empty or missing)") + fi + +# ──────────────────────────────────────────────── +# 3. Required sysroot include path with Linux headers +# + linux_headers=( + "$SYSROOT/usr/include/linux/version.h" + "$SYSROOT/usr/include/asm/unistd.h" + "$SYSROOT/usr/include/bits/types.h" + ) + + for header in "${linux_headers[@]}"; do + if [[ -f "$header" ]]; then + found_requisite_list+=("$header") + else + missing_requisite_list+=("$header") + fi + done + +# ──────────────────────────────────────────────── +# 4. Confirm SYSROOT write access +# + if [[ -w "$SYSROOT/usr/include" ]]; then + found_requisite_list+=("SYSROOT writable: $SYSROOT/usr/include") + else + missing_requisite_list+=("SYSROOT not writable: $SYSROOT/usr/include") + fi + +# ──────────────────────────────────────────────── +# Additional sanity checks before header & crt build +# + + # 1. Check that the C preprocessor works and headers can be found + echo '#include ' | gcc -E - > /dev/null 2>&1 + if [[ $? -eq 0 ]]; then + found_requisite_list+=("C preprocessor operational: gcc -E works") + else + missing_requisite_list+=("C preprocessor failed: gcc -E on failed") + fi + + # 2. Check that bits/stdio_lim.h exists after headers install (glibc marker) + if [[ -f "$GLIBC_BUILD/bits/stdio_lim.h" ]]; then + found_requisite_list+=("$GLIBC_BUILD/bits/stdio_lim.h (glibc headers marker found)") + else + missing_requisite_list+=("$GLIBC_BUILD/bits/stdio_lim.h missing — headers may not be fully installed") + fi + + # 3. Check for crt objects already present (optional) + for f in crt1.o crti.o crtn.o; do + if [[ -f "$GLIBC_BUILD/csu/$f" ]]; then + found_requisite_list+=("$GLIBC_BUILD/csu/$f (already built)") + fi + done + + # 4. Check that Makefile exists and is non-empty + if [[ -f "$GLIBC_BUILD/Makefile" ]]; then + if [[ -s "$GLIBC_BUILD/Makefile" ]]; then + found_requisite_list+=("$GLIBC_BUILD/Makefile exists and is populated") + else + missing_requisite_list+=("$GLIBC_BUILD/Makefile exists but is empty — incomplete configure?") + fi + else + missing_requisite_list+=("$GLIBC_BUILD/Makefile missing — did configure run?") + fi + + # 5. Check that csu Makefile has rules for crt1.o + if [[ -f "$GLIBC_BUILD/csu/Makefile" ]]; then + if grep -q 'crt1\.o' "$GLIBC_BUILD/csu/Makefile"; then + found_requisite_list+=("csu/Makefile defines crt1.o") + else + missing_requisite_list+=("csu/Makefile does not define crt1.o — possible misconfigure") + fi + else + missing_requisite_list+=("csu/Makefile missing — subdir config likely failed") + fi + +# ──────────────────────────────────────────────── +# Print results +# + if (( ${#found_requisite_list[@]} > 0 )); then + echo "found:" + for item in "${found_requisite_list[@]}"; do + echo " $item" + done + fi + + if (( ${#missing_requisite_list[@]} > 0 )); then + echo "missing:" + for item in "${missing_requisite_list[@]}"; do + echo " $item" + done + fi + + # Final verdict + # + if (( ${#missing_requisite_list[@]} > 0 )); then + echo "❌ Missing requisites for glibc bootstrap" + exit 1 + else + echo "✅ All specified requisites found" + exit 0 + fi diff --git "a/script\360\237\226\211/build_glibc_headers.sh" "b/script\360\237\226\211/build_glibc_headers.sh" index 67e6b59..abcb5a4 100755 --- "a/script\360\237\226\211/build_glibc_headers.sh" +++ "b/script\360\237\226\211/build_glibc_headers.sh" @@ -3,75 +3,44 @@ set -euo pipefail source "$(dirname "$0")/environment.sh" -echo "📚 Building glibc headers..." +echo "📦 Building and installing glibc headers..." -# 🧹 Clean previous build artifacts to ensure idempotence -echo "🧼 Cleaning glibc build directory: $GLIBC_BUILD" -rm -rf "$GLIBC_BUILD" mkdir -p "$GLIBC_BUILD" - pushd "$GLIBC_BUILD" -# 🏗️ Configure glibc for headers-only installation -echo "⚙️ Configuring glibc headers install..." -"$GLIBC_SRC/configure" \ - --prefix=/usr \ - --with-headers="$SYSROOT/usr/include" \ - --disable-multilib \ - --enable-static \ - --disable-shared \ - libc_cv_slibdir="/usr/lib" - -# 📥 Install headers only -echo "🛠️ Installing glibc headers to sysroot..." -make install-headers -j"$(nproc)" DESTDIR="$SYSROOT" - -# 📎 Verify critical header files and directories were installed -echo "📦 Verifying installed files..." - -required_headers=( - "$SYSROOT/usr/include/gnu/libc-version.h" - "$SYSROOT/usr/include/stdio.h" - "$SYSROOT/usr/include/unistd.h" -) - -missing_files=() -for header in "${required_headers[@]}"; do - if [[ ! -f "$header" ]]; then - missing_files+=("$header") - fi -done - -if (( ${#missing_files[@]} > 0 )); then - echo "❌ Missing required glibc headers:" - printf ' %s\n' "${missing_files[@]}" - exit 1 -fi - -# 📦 Verify the expected directory structure -if [[ ! -d "$SYSROOT/usr/include" ]]; then - echo "❌ Expected include directory not found: $SYSROOT/usr/include" - exit 1 -fi - -if [[ ! -d "$SYSROOT/usr/lib" ]]; then - echo "❌ Expected lib directory not found: $SYSROOT/usr/lib" - exit 1 -fi - -# 📚 Additional verification: check for key startup files -startup_files=( - "$SYSROOT/usr/lib/crt1.o" - "$SYSROOT/usr/lib/crti.o" - "$SYSROOT/usr/lib/crtn.o" -) - -for file in "${startup_files[@]}"; do - if [[ ! -f "$file" ]]; then - echo "❌ Missing startup file: $file" + # Configure glibc with minimal bootstrap options + "$GLIBC_SRC/configure" \ + --prefix=/usr \ + --build="$HOST" \ + --host="$HOST" \ + --with-headers="$SYSROOT/usr/include" \ + --disable-multilib \ + --enable-static \ + --disable-shared \ + --enable-kernel=4.4.0 \ + libc_cv_slibdir="/usr/lib" + + + # Install headers into sysroot + make install-headers -j"$MAKE_JOBS" DESTDIR="$SYSROOT" + + # ✅ Verify headers were installed + required_headers=( + "$SYSROOT/usr/include/gnu/libc-version.h" + "$SYSROOT/usr/include/stdio.h" + "$SYSROOT/usr/include/unistd.h" + ) + + missing=() + for h in "${required_headers[@]}"; do + [[ -f "$h" ]] || missing+=("$h") + done + + if (( ${#missing[@]} > 0 )); then + echo "❌ Missing required glibc headers:" + printf ' %s\n' "${missing[@]}" exit 1 fi -done popd diff --git "a/script\360\237\226\211/build_glibc_headers_requisites.sh" "b/script\360\237\226\211/build_glibc_headers_requisites.sh" new file mode 100755 index 0000000..0264c81 --- /dev/null +++ "b/script\360\237\226\211/build_glibc_headers_requisites.sh" @@ -0,0 +1,99 @@ +#!/bin/bash +set -euo pipefail + +source "$(dirname "$0")/environment.sh" + +echo "📦 Checking requisites for glibc headers installation." + +missing_requisite_list=() +found_requisite_list=() + +# ──────────────────────────────────────────────── +# 1. Required tools for headers phase +# +required_tools=( + "gcc" + "g++" + "make" + "ld" + "as" +) + +for tool in "${required_tools[@]}"; do + if location=$(command -v "$tool"); then + found_requisite_list+=("$location") + else + missing_requisite_list+=("$tool") + fi +done + +# ──────────────────────────────────────────────── +# 2. glibc source directory check +# +if [ -d "$GLIBC_SRC" ] && [ "$(ls -A "$GLIBC_SRC")" ]; then + found_requisite_list+=("$GLIBC_SRC") +else + missing_requisite_list+=("$GLIBC_SRC (empty or missing)") +fi + +# ──────────────────────────────────────────────── +# 3. Kernel headers required for bootstrap glibc +# +linux_headers=( + "$SYSROOT/usr/include/linux/version.h" + "$SYSROOT/usr/include/asm/unistd.h" + "$SYSROOT/usr/include/bits/types.h" +) + +for header in "${linux_headers[@]}"; do + if [[ -f "$header" ]]; then + found_requisite_list+=("$header") + else + missing_requisite_list+=("$header") + fi +done + +# ──────────────────────────────────────────────── +# 4. Confirm SYSROOT write access for header install +# +if [[ -w "$SYSROOT/usr/include" ]]; then + found_requisite_list+=("SYSROOT writable: $SYSROOT/usr/include") +else + missing_requisite_list+=("SYSROOT not writable: $SYSROOT/usr/include") +fi + +# ──────────────────────────────────────────────── +# 5. Check C preprocessor is operational +# +echo '#include ' | gcc -E - > /dev/null 2>&1 +if [[ $? -eq 0 ]]; then + found_requisite_list+=("C preprocessor operational: gcc -E works") +else + missing_requisite_list+=("C preprocessor failed: gcc -E on failed") +fi + +# ──────────────────────────────────────────────── +# Print results +# +if (( ${#found_requisite_list[@]} > 0 )); then + echo "found:" + for item in "${found_requisite_list[@]}"; do + echo " $item" + done +fi + +if (( ${#missing_requisite_list[@]} > 0 )); then + echo "missing:" + for item in "${missing_requisite_list[@]}"; do + echo " $item" + done +fi + +# Final verdict +if (( ${#missing_requisite_list[@]} > 0 )); then + echo "❌ Missing requisites for glibc header install" + exit 1 +else + echo "✅ All specified requisites found for glibc headers" + exit 0 +fi diff --git "a/script\360\237\226\211/clean_build.sh" "b/script\360\237\226\211/clean_build.sh" index d239cef..7c9bca3 100755 --- "a/script\360\237\226\211/clean_build.sh" +++ "b/script\360\237\226\211/clean_build.sh" @@ -3,7 +3,6 @@ set -euo pipefail source "$(dirname "$0")/environment.sh" -# Clean the build directories listed in BUILD_DIR_LISTECTORY_LIST echo "🧹 Cleaning build directories..." for dir in "${BUILD_DIR_LIST[@]}"; do