--- /dev/null
+#!/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
./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
--- /dev/null
+#!/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"
--- /dev/null
+#!/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 <stddef.h>' | 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 <stddef.h> 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
source "$(dirname "$0")/environment.sh"
-echo "Γ°\9f\93\9a Building glibc headers..."
+echo "Γ°\9f\93Β¦ 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
--- /dev/null
+#!/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 <stddef.h>' | 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 <stddef.h> 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
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