add optimization on to harness

This commit is contained in:
kalsprite
2026-08-13 22:11:53 -07:00
parent 98e580404a
commit 32f90a04db
4 changed files with 21 additions and 5 deletions

View File

@@ -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 \

View File

@@ -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

View File

@@ -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