mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-23 21:41:34 +00:00
fix windows ci
This commit is contained in:
@@ -51,15 +51,15 @@ _start:
|
||||
*) echo "no start stub for $TARGET" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
# Ask the C compiler which tiers it actually has, the Odin side must have the same answer or
|
||||
# it references symbols the C side never emitted ( eg `__int128` does not exist on i386).
|
||||
macros=$($CLANG --target="$TRIPLE" -dM -E -x c /dev/null 2>/dev/null)
|
||||
tier() { case "$macros" in *"$1"*) echo true ;; *) echo false ;; esac; }
|
||||
TIERS="-define:ABI_TIER_GNU=$(tier __GNUC__) -define:ABI_TIER_F16=$(tier __FLT16_MANT_DIG__) -define:ABI_TIER_I128=$(tier __SIZEOF_INT128__)"
|
||||
|
||||
rm -rf build-cross
|
||||
mkdir -p build-cross/p
|
||||
python3 gen.py build-cross
|
||||
|
||||
# Ask the C compiler which tiers it has, by preprocessing the generated `build-cross/tiers.c`.
|
||||
# The Odin side must use the same tiers or it references symbols C never emitted.
|
||||
have() { $CLANG --target="$TRIPLE" -E build-cross/tiers.c 2>/dev/null | grep -q "ABI_YES_$1" && echo true || echo false; }
|
||||
TIERS="-define:ABI_TIER_GNU=$(have GNU) -define:ABI_TIER_F16=$(have F16) -define:ABI_TIER_I128=$(have I128)"
|
||||
mv build-cross/abi_main.odin build-cross/p/
|
||||
printf '%s\n' "$START" > build-cross/start.s
|
||||
|
||||
|
||||
@@ -398,6 +398,25 @@ def build():
|
||||
GUARD = {TIER_CORE: None, TIER_GNU: "ABI_TIER_GNU", TIER_F16: "ABI_TIER_F16",
|
||||
TIER_I128: "ABI_TIER_I128"}
|
||||
|
||||
# The tier conditions live here. The corpus is guarded by them, `tiers.c` reports them.
|
||||
TIER_COND = {
|
||||
TIER_GNU: "defined(__GNUC__)",
|
||||
TIER_F16: "defined(__FLT16_MANT_DIG__) && !defined(_MSC_VER)",
|
||||
TIER_I128: "defined(__SIZEOF_INT128__)",
|
||||
}
|
||||
|
||||
|
||||
def emit_tiers_c():
|
||||
o = io.StringIO()
|
||||
o.write("/* GENERATED by tests/abi/gen.py -- do not edit.\n"
|
||||
" Preprocess this and grep the markers: it answers which tiers the C\n"
|
||||
" compiler actually has, so the Odin side can be gated by the same\n"
|
||||
" answer rather than by a restatement of the condition. */\n")
|
||||
for tier, cond in TIER_COND.items():
|
||||
o.write(f"#if {cond}\nABI_YES_{GUARD[tier].replace('ABI_TIER_', '')}\n#endif\n")
|
||||
return o.getvalue()
|
||||
|
||||
|
||||
C_HEAD = """\
|
||||
/* GENERATED by tests/abi/gen.py -- do not edit. */
|
||||
#include <stdint.h>
|
||||
@@ -405,15 +424,7 @@ C_HEAD = """\
|
||||
|
||||
/* Tier guards. A target whose C compiler lacks an extension still runs the
|
||||
core corpus; the Odin side is gated by the matching -define. */
|
||||
#if defined(__GNUC__)
|
||||
#define ABI_TIER_GNU 1
|
||||
#endif
|
||||
#if defined(__FLT16_MANT_DIG__) && !defined(_MSC_VER)
|
||||
#define ABI_TIER_F16 1
|
||||
#endif
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
#define ABI_TIER_I128 1
|
||||
#endif
|
||||
@TIER_DEFINES@
|
||||
|
||||
/* An enum with an explicit wide enumerator, so it is int-sized rather than
|
||||
whatever the compiler picks for a small one. */
|
||||
@@ -472,7 +483,8 @@ foreign import lib "abi_corpus_c.o"
|
||||
|
||||
def emit_c(types):
|
||||
o = io.StringIO()
|
||||
o.write(C_HEAD)
|
||||
defines = "".join(f"#if {c}\n#define {GUARD[t]} 1\n#endif\n" for t, c in TIER_COND.items())
|
||||
o.write(C_HEAD.replace("@TIER_DEFINES@", defines.rstrip()))
|
||||
for t in types:
|
||||
g = GUARD[t.tier]
|
||||
if g:
|
||||
@@ -694,4 +706,5 @@ if __name__ == "__main__":
|
||||
open(os.path.join(here, "abi_corpus.c"), "w").write(emit_c(ts))
|
||||
open(os.path.join(here, "abi_corpus.odin"), "w").write(emit_odin(ts))
|
||||
open(os.path.join(here, "abi_main.odin"), "w").write(emit_main(ts))
|
||||
open(os.path.join(here, "tiers.c"), "w").write(emit_tiers_c())
|
||||
print(f"{len(ts)} types, {sum(7 + (1 if t.fields else 0) for t in ts)} C functions, {len(ts) * 2} Odin callees")
|
||||
|
||||
@@ -11,10 +11,25 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused
|
||||
|
||||
python3 ..\gen.py . || exit /b
|
||||
|
||||
@echo off
|
||||
REM Ask the C compiler which tiers it has, by preprocessing the generated
|
||||
REM `tiers.c`. Clang targeting MSVC doesnt define `__GNUC__` or `_Float16`,
|
||||
REM Odin side needs to match
|
||||
set TIER_GNU=false
|
||||
set TIER_F16=false
|
||||
set TIER_I128=false
|
||||
clang -E tiers.c 2>nul | findstr /C:"ABI_YES_GNU" >nul && set TIER_GNU=true
|
||||
clang -E tiers.c 2>nul | findstr /C:"ABI_YES_F16" >nul && set TIER_F16=true
|
||||
clang -E tiers.c 2>nul | findstr /C:"ABI_YES_I128" >nul && set TIER_I128=true
|
||||
set TIERS=-define:ABI_TIER_GNU=%TIER_GNU% -define:ABI_TIER_F16=%TIER_F16% -define:ABI_TIER_I128=%TIER_I128%
|
||||
echo tiers: %TIERS%
|
||||
|
||||
@echo on
|
||||
|
||||
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% || exit /b
|
||||
..\..\..\odin test abi_corpus.odin %COMMON% %TIERS% || exit /b
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
@@ -24,11 +24,6 @@ COMMON="-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused-de
|
||||
CC_TARGET=""; [ -n "$TRIPLE" ] && CC_TARGET="--target=$TRIPLE"
|
||||
ODIN_TARGET=""; [ -n "$TARGET" ] && ODIN_TARGET="-target:$TARGET"
|
||||
|
||||
# Ask the C compiler which tiers it actually has, the Odin side must have the same answer or
|
||||
# it references symbols the C side never emitted ( eg `__int128` does not exist on i386).
|
||||
macros=$($CLANG $CC_TARGET -dM -E -x c /dev/null 2>/dev/null)
|
||||
tier() { case "$macros" in *"$1"*) echo true ;; *) echo false ;; esac; }
|
||||
TIERS="-define:ABI_TIER_GNU=$(tier __GNUC__) -define:ABI_TIER_F16=$(tier __FLT16_MANT_DIG__) -define:ABI_TIER_I128=$(tier __SIZEOF_INT128__)"
|
||||
|
||||
rm -rf "$here/build"
|
||||
mkdir -p "$here/build"
|
||||
@@ -39,6 +34,11 @@ set -x
|
||||
|
||||
python3 ../gen.py .
|
||||
|
||||
# Ask the C compiler which tiers it has, by preprocessing the generated `build-cross/tiers.c`.
|
||||
# The Odin side must use the same tiers or it references symbols C never emitted.
|
||||
have() { $CLANG $CC_TARGET -E tiers.c 2>/dev/null | grep -q "ABI_YES_$1" && echo true || echo false; }
|
||||
TIERS="-define:ABI_TIER_GNU=$(have GNU) -define:ABI_TIER_F16=$(have F16) -define:ABI_TIER_I128=$(have I128)"
|
||||
|
||||
# `-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
|
||||
|
||||
Reference in New Issue
Block a user