Commit 3aba184e

3aba184ef222Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 3 files · ~3 modified

Description

fix: silence clang -Wstring-plus-int on the immortal-string idiom

The runtime header and codegen output use the idiom ("\xff" "literal" + 1) to mark a string literal as immortal (the 0xff prefix byte tells the GC scanner this is a literal pointer rather than a heap-allocated string). Apple clang flags this pattern with -Wstring-plus-int, and the Makefile test/bench rules combine that with -Werror, which was turning every test and bench into a compile error on macOS. Reported in #6.

Pass -Wno-string-plus-int unconditionally in CFLAGS, the spinel driver script, and spinel.bat. gcc does not have this warning but accepts the flag silently, so it is safe everywhere. Linux builds remain green (77 tests pass, 55 benches pass).

A more thorough fix that rewrites the idiom to (&("\xff" "literal")[1]) form (which clang understands as ordinary array indexing) is tracked separately and will eliminate the need for this flag.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
3aba184ef222
Parent
ca696c5e1515

MakefilemodifiedView file

@@ -9,7 +9,10 @@
99 # make clean Remove built binaries
1010
1111 CC ?= cc
12-CFLAGS = -O2 -Wno-all
12+# -Wno-string-plus-int silences clang's warning on the immortal-string
13+# idiom ("\xff" "literal" + 1). gcc doesn't have this warning but accepts
14+# the flag silently, so it is safe to apply unconditionally.
15+CFLAGS = -O2 -Wno-all -Wno-string-plus-int
1316 # Per-function sections allow the linker to strip unused bigint/regexp
1417 # functions from the final binary (supported since GCC 2.7 / binutils 2.17).
1518 SEC_FLAGS = -ffunction-sections -fdata-sections