boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

build-tcc-gcc.sh (1442B)


      1 #!/bin/sh
      2 ## build-tcc-gcc.sh — link tcc.flat.c + libc.flat.c with stock gcc.
      3 ##
      4 ## Sanity-check sibling of the cc.scm path. Inputs are the *same*
      5 ## flatten outputs the cc.scm pipeline consumes; harness sources
      6 ## (tcc/gcc/<arch>/{start.S,sys_stubs.c}) provide a minimal _start and
      7 ## syscall stubs so we don't need musl's crt0 or its libc. If
      8 ## tcc-gcc -version works and our cc.scm-built tcc-boot2 doesn't, the
      9 ## bug is downstream of the C source.
     10 ##
     11 ## Runs inside the boot2-alpine-gcc:<arch> image. -nodefaultlibs (not
     12 ## -nostdlib) keeps libgcc available for long-double soft-float
     13 ## helpers (__addtf3 etc., needed on aarch64 musl).
     14 ##
     15 ## Env: ARCH=aarch64 (only arch wired today; start.S is per-arch)
     16 ## Usage: build-tcc-gcc.sh <out> <tcc.flat.c> <libc.flat.c>
     17 
     18 set -eu
     19 
     20 : "${ARCH:?ARCH must be set}"
     21 [ "$#" -eq 3 ] || { echo "usage: ARCH=<arch> $0 <out> <tcc.flat.c> <libc.flat.c>" >&2; exit 2; }
     22 
     23 OUT=$1
     24 TCC_FLAT=$2
     25 LIBC_FLAT=$3
     26 
     27 HARNESS=tcc/gcc/$ARCH
     28 [ -d "$HARNESS" ] || { echo "no harness for ARCH=$ARCH at $HARNESS" >&2; exit 1; }
     29 
     30 mkdir -p "$(dirname "$OUT")"
     31 
     32 gcc -static -nodefaultlibs -nostartfiles -fno-stack-protector \
     33     -fno-builtin \
     34     -Wno-implicit-function-declaration \
     35     -Wno-builtin-declaration-mismatch \
     36     -Wno-incompatible-pointer-types \
     37     -Wno-int-conversion \
     38     -e _start \
     39     "$HARNESS/start.S" "$HARNESS/sys_stubs.c" \
     40     tcc/cc/mem.c \
     41     "$TCC_FLAT" "$LIBC_FLAT" \
     42     -lgcc -o "$OUT"