From 32f90a04dbd3fdde6ff8a4c98c81d1f883a4397e Mon Sep 17 00:00:00 2001 From: kalsprite Date: Thu, 13 Aug 2026 22:11:53 -0700 Subject: [PATCH] add optimization on to harness --- .github/workflows/ci.yml | 5 +++++ tests/abi/cross.sh | 8 ++++++-- tests/abi/run.bat | 8 ++++++-- tests/abi/run.sh | 5 ++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a59fa456..e18998504 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: ./odin test tests/vendor -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -microarch:native (cd tests/issues; ./run.sh) (cd tests/abi; ./run.sh) + (cd tests/abi; ABI_CFLAGS=-O2 ./run.sh "" "" -o:speed) ./odin check tests/benchmark -vet -strict-style -no-entry-point build_freebsd: @@ -75,6 +76,7 @@ jobs: ./odin test tests/vendor -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true (cd tests/issues; ./run.sh) (cd tests/abi; ./run.sh) + (cd tests/abi; ABI_CFLAGS=-O2 ./run.sh "" "" -o:speed) ./odin check tests/benchmark -vet -strict-style -no-entry-point ci: strategy: @@ -177,6 +179,7 @@ jobs: run: | cd tests/abi ./run.sh + ABI_CFLAGS=-O2 ./run.sh "" "" -o:speed - name: Run demo on WASI WASM32 run: | @@ -292,6 +295,8 @@ jobs: call run.bat cd ../abi call run.bat + set ABI_CFLAGS=-O2 + call run.bat -o:speed - name: Check benchmarks shell: cmd run: | diff --git a/tests/abi/cross.sh b/tests/abi/cross.sh index 137087b5b..5113336e5 100755 --- a/tests/abi/cross.sh +++ b/tests/abi/cross.sh @@ -18,8 +18,12 @@ set -eu TARGET=${1:?odin target, e.g. linux_arm64} TRIPLE=${2:?clang triple, e.g. aarch64-linux-gnu} QEMU=${3:?qemu binary, e.g. qemu-aarch64} +shift 3 # anything else goes to `odin build` : "${ODIN:=../../odin}" : "${CLANG:=clang}" +# The C side's optimisation level. An ABI is a link-time contract, so the two +# sides are built independently and either may be optimised: `ABI_CFLAGS=-O2`. +: "${ABI_CFLAGS:=}" case "$TARGET" in *i386*) START='.text @@ -98,8 +102,8 @@ EOF set -x $ODIN build build-cross/p -target:"$TARGET" -build-mode:obj -no-entry-point \ - -no-thread-local -reloc-mode:static $TIERS -out:build-cross/o -$CLANG --target="$TRIPLE" -c build-cross/abi_corpus.c -o build-cross/abi_corpus_c.o -w -fno-stack-protector + -no-thread-local -reloc-mode:static $TIERS -out:build-cross/o "$@" +$CLANG --target="$TRIPLE" $ABI_CFLAGS -c build-cross/abi_corpus.c -o build-cross/abi_corpus_c.o -w -fno-stack-protector $CLANG --target="$TRIPLE" -c build-cross/start.s -o build-cross/start.o $CLANG --target="$TRIPLE" -ffreestanding -fno-builtin -O1 -w -c build-cross/shim.c -o build-cross/shim.o $CLANG --target="$TRIPLE" -nostdlib -static -fuse-ld=lld \ diff --git a/tests/abi/run.bat b/tests/abi/run.bat index e89e989d6..db03eda3b 100644 --- a/tests/abi/run.bat +++ b/tests/abi/run.bat @@ -2,6 +2,10 @@ REM The ABI comparator. Every check is "Odin agrees with the platform C compiler" +REM An ABI is a link-time contract, so the two sides are built independently and +REM either may be optimised: `set ABI_CFLAGS=-O2` for the C side, and any +REM argument here goes to `odin test`, e.g. `run.bat -o:speed`. + REM cleaned BEFORE, not after: the generated corpus is left to inspect if exist "build\" rmdir /S /Q build mkdir build @@ -30,8 +34,8 @@ echo tiers: %TIERS% REM -w because the corpus deliberately uses zero-length arrays and empty REM structs; both are the extensions under test. -clang -c abi_corpus.c -o abi_corpus_c.o -w || exit /b -..\..\..\odin test abi_corpus.odin %COMMON% %TIERS% || exit /b +clang %ABI_CFLAGS% -c abi_corpus.c -o abi_corpus_c.o -w || exit /b +..\..\..\odin test abi_corpus.odin %COMMON% %TIERS% %* || exit /b @echo off diff --git a/tests/abi/run.sh b/tests/abi/run.sh index bba46b2a1..0fea5f67b 100755 --- a/tests/abi/run.sh +++ b/tests/abi/run.sh @@ -19,6 +19,9 @@ if [ $# -gt 2 ]; then shift 2; else shift $#; fi # anything else goes to `odin here=$(cd "$(dirname "$0")" && pwd) : "${ODIN:=$here/../../odin}" : "${CLANG:=clang}" +# The C side's optimisation level. An ABI is a link-time contract, so the two +# sides are built independently and either may be optimised: `ABI_CFLAGS=-O2`. +: "${ABI_CFLAGS:=}" COMMON="-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused-defineables" CC_TARGET=""; [ -n "$TRIPLE" ] && CC_TARGET="--target=$TRIPLE" @@ -42,7 +45,7 @@ TIERS="-define:ABI_TIER_GNU=$(have GNU) -define:ABI_TIER_F16=$(have F16) -define # `-w` because the corpus deliberately uses zero-length arrays and empty # structs; both are the extensions under test. -$CLANG $CC_TARGET -c abi_corpus.c -o abi_corpus_c.o -w +$CLANG $CC_TARGET $ABI_CFLAGS -c abi_corpus.c -o abi_corpus_c.o -w $ODIN test abi_corpus.odin $COMMON $ODIN_TARGET $TIERS "$@" set +x