Skip to content

Commit 1ae4a00

Browse files
committed
better zig-cc arch handling
1 parent 2b6d228 commit 1ae4a00

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/SPC/store/scripts/zig-cc.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ while [[ $# -gt 0 ]]; do
2727
-march=*|-mcpu=*)
2828
OPT_NAME="${1%%=*}"
2929
OPT_VALUE="${1#*=}"
30-
# Skip armv8- flags entirely as Zig doesn't support them
31-
if [[ "$OPT_VALUE" == armv8-* ]]; then
32-
shift
33-
continue
30+
# zig rejects -march=armv8-a but accepts -mcpu=generic+v8a; rewrite
31+
# armv<X>[.<Y>]-a[+feat] -> generic+v<X>[_<Y>]a[+feat] so it goes through.
32+
if [[ "$OPT_VALUE" =~ ^armv([89])(\.([0-9]+))?-a(\+.*)?$ ]]; then
33+
arch_feat="v${BASH_REMATCH[1]}"
34+
[[ -n "${BASH_REMATCH[3]}" ]] && arch_feat="${arch_feat}_${BASH_REMATCH[3]}"
35+
OPT_VALUE="generic+${arch_feat}a${BASH_REMATCH[4]}"
3436
fi
35-
# replace -march=x86-64 with -march=x86_64
37+
# zig uses snake_case in CPU/feature names (x86-64 -> x86_64).
3638
OPT_VALUE="${OPT_VALUE//-/_}"
3739
PARSED_ARGS+=("${OPT_NAME}=${OPT_VALUE}")
3840
shift

0 commit comments

Comments
 (0)