Skip to content

Commit 9f1c0d3

Browse files
committed
Use CFLAGS in target-triple probe and soften mismatch warning
1 parent d02fd97 commit 9f1c0d3

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tools/abiname.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ canonicalize_abi() {
1919
}
2020

2121
detect_target_triple() {
22+
# Prefer querying with CFLAGS so explicit target flags (for example
23+
# --target=... in clang-based cross builds) are reflected.
24+
if ${CC} ${CFLAGS} -dumpmachine >/dev/null 2>&1; then
25+
${CC} ${CFLAGS} -dumpmachine
26+
return 0
27+
fi
28+
if ${CC} ${CFLAGS} --print-target-triple >/dev/null 2>&1; then
29+
${CC} ${CFLAGS} --print-target-triple
30+
return 0
31+
fi
32+
# Fall back to no CFLAGS in case unrelated build flags make the query fail.
2233
if ${CC} -dumpmachine >/dev/null 2>&1; then
2334
${CC} -dumpmachine
2435
return 0
@@ -73,7 +84,7 @@ abi=$("${tmp}.out")
7384
abi=$(canonicalize_abi "${abi}")
7485
target_abi=$(abi_from_target_triple "${target_triple}")
7586
if [ -n "${target_abi}" ] && [ "${target_abi}" != "${abi}" ]; then
76-
printf '%s\n' "warning: stackman ABI mismatch: compiler target '${target_triple}' suggests '${target_abi}', macro probe selected '${abi}'. Consider setting STACKMAN_ABI explicitly." >&2
87+
printf '%s\n' "warning: stackman ABI mismatch: compiler target '${target_triple}' suggests '${target_abi}', macro probe selected '${abi}'. This usually means target intent was not fully propagated (flags/wrapper selection). Consider setting STACKMAN_ABI explicitly for deterministic packaging." >&2
7788
fi
7889
if [ -n "${STACKMAN_ABI_DEBUG:-}" ] || [ -n "${STACKMAN_ABI_TRACE:-}" ]; then
7990
printf '%s\n' "stackman abiname: cc=${CC} target=${target_triple:-unknown} abi=${abi} source=macro" >&2

0 commit comments

Comments
 (0)