port.mk (3467B)
1 # mk/port.mk — portability test surface (doc/plan/PORT.md). 2 # 3 # Two modes over the canonical support set defined in scripts/hosted.sh: 4 # test-cross can kit cross-compile a correct executable for a target? 5 # test-selfhost can kit be built to run on a target, then compile + run there? 6 # test-port both 7 # kit-cross build a runnable kit binary for a target (clang or kit) 8 # provision the network + VM setup (separate from running) 9 # 10 # Parametrized surface: 11 # TARGET support-set selector (default all): all | <os> | linux-<libc> | 12 # <token> | a,b,c (see scripts/hosted.sh expand) 13 # DEPTH test-cross: coarse | smoke (default) | full; test-selfhost: smoke | full 14 # KIT_VM 1 (default; include freebsd/windows) | 0 (drop them) 15 # RUN 1 (default; execute linked smoke/full artifacts) | 0 (build/link only) 16 # CROSS_CC kit (default) | clang — kit-cross toolchain backend 17 # VERIFY 0 (default) | 1 — kit-cross: run the built kit on-target 18 # 19 # Examples: 20 # make test-cross # smoke across the whole support set 21 # make test-cross DEPTH=coarse # compile/link across the set, no execution 22 # make test-cross RUN=0 # same, via the execution knob 23 # make test-cross TARGET=linux-glibc-x64 DEPTH=full 24 # make test-cross TARGET=freestanding # all 4 bare-metal arches 25 # make test-selfhost TARGET=freebsd-aa64 26 # make kit-cross TARGET=windows-x64 # build kit.exe for windows-x64 (kit) 27 # make kit-cross TARGET=linux CROSS_CC=clang VERIFY=1 28 # make provision TARGET=linux # just the linux sysroots + images 29 30 TARGET ?= all 31 DEPTH ?= smoke 32 KIT_VM ?= 1 33 RUN ?= 1 34 CROSS_CC ?= kit 35 VERIFY ?= 0 36 37 .PHONY: test-port test-cross test-selfhost kit-cross provision 38 39 test-port: test-cross test-selfhost 40 41 # The corpus runners depend on $(LIB_AR); list them so a libkit change rebuilds 42 # them before the cross lanes run. cross_test.sh only checks the runners exist 43 # (test/parse/run.sh errors when missing but not when stale), so without these 44 # prereqs a stale parse-runner can run against fresh codegen and report a false 45 # pass/fail (e.g. an "opt native emit" error already fixed in libkit). The toy 46 # lane drives $(BIN) directly and so is covered by `bin`. 47 test-cross: bin $(PARSE_RUNNER) $(LINK_EXE_RUNNER) 48 @KIT='$(abspath $(BIN))' KIT_VM='$(KIT_VM)' KIT_CROSS_RUN='$(RUN)' \ 49 bash scripts/cross_test.sh '$(TARGET)' '$(DEPTH)' 50 51 test-selfhost: bin 52 @KIT='$(abspath $(BIN))' KIT_VM='$(KIT_VM)' \ 53 bash scripts/selfhost.sh '$(TARGET)' '$(DEPTH)' 54 55 # kit-cross: cross-build a runnable kit for each in-scope target (clang or kit 56 # backend), excluding freestanding (kit needs an OS to run on — same set as 57 # selfhost). VERIFY=1 additionally runs the built kit on-target via the exec 58 # seam. The per-target work lives in scripts/kit_cross.sh. 59 kit-cross: bin 60 @set -e; vflag=''; [ '$(VERIFY)' = 1 ] && vflag='--verify'; \ 61 for t in $$(bash scripts/hosted.sh expand '$(TARGET)' --mode=selfhost); do \ 62 KIT='$(abspath $(BIN))' bash scripts/kit_cross.sh "$$t" --cc='$(CROSS_CC)' $$vflag; \ 63 done 64 65 # provision: sysroots / run-images / VMs for the in-scope targets. Idempotent; 66 # this is the only step that touches the network. The provisioner calls back into 67 # `make` for the image/sysroot targets it needs (test-images, etc.). 68 provision: 69 @KIT_VM='$(KIT_VM)' MAKE='$(MAKE)' bash scripts/provision.sh '$(TARGET)'