Commit 003c3022

003c30228b13Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

build: silence gcc -Wformat-truncation on benign ivar/path snprintf builds

A full gcc rebuild prints -Wformat-truncation warnings on snprintf calls like snprintf(buf, sizeof buf, "@%s", name) (analyze_scope.c, codegen_stmt.c, main.c path resolution). The buffers are sized for real identifiers and paths; the truncation can't happen in practice. The warning is FORTIFY-driven and fires independently of -Wall under _FORTIFY_SOURCE, so the existing -Wno-all does not cover it.

Add -Wno-format-truncation to CFLAGS alongside the other paranoia suppressions. gcc recognizes it; clang lacks the flag and ignores it via the existing -Wno-unknown-warning-option.

optcarrot checksum 59662, build clean (0 warnings) on gcc.

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
003c30228b13
Parent
d65f6c70249a

common.mkmodifiedView file

@@ -32,8 +32,13 @@
3232 # `-Wno-alloc-size-larger-than` silences a gcc 13+ paranoia warning on the
3333 # inlined `h->cap *= 2` in sp_*Hash_grow; `-Wno-unknown-warning-option`
3434 # keeps clang (which lacks that flag) from turning it into a -Werror fail.
35+# `-Wno-format-truncation` silences gcc's FORTIFY-driven paranoia on benign
36+# `snprintf(buf, sizeof buf, "@%s", name)` ivar/path builds (the buffers are
37+# sized for real identifiers; the warning fires independently of -Wall under
38+# _FORTIFY_SOURCE, so -Wno-all does not cover it). clang lacks the flag and
39+# ignores it via -Wno-unknown-warning-option above.
3540 OPT ?= -O2
36-CFLAGS = $(OPT) -Wno-all -Wno-unknown-warning-option -Wno-alloc-size-larger-than
41+CFLAGS = $(OPT) -Wno-all -Wno-unknown-warning-option -Wno-alloc-size-larger-than -Wno-format-truncation
3742
3843 # Bootstrap-only flags: the legacy compiler runs on the developer's
3944 # machine only, so -O3 -flto buys ~5-10% wall-clock without constraining