From 628ce5a9e61ebe40972e73c96c55ea23178a739b Mon Sep 17 00:00:00 2001 From: ProfessionalSeaweedDevourer Date: Tue, 30 Jun 2026 16:36:20 +0900 Subject: [PATCH] arsig: fix macOS (Apple clang) build of xgb_model.c On macOS the C compiler invoked as 'gcc' is Apple clang, which (1) caps C bracket nesting at 256 and (2) parses via recursive descent. The generated src/arsig/xgb_model.c (SVM/XGBoost ambiguity-validation model) exceeds depth 256, so the stock build fails: xgb_model.c: fatal error: bracket nesting level exceeded maximum of 256 Adding -fbracket-depth raises the limit, but on the default macOS 8 MB stack clang's parser then overflows the stack and segfaults on this file. The build only succeeds when the stack is also enlarged. Fix (arsig/Makefile, no effect on GNU/Linux builds): - add -fbracket-depth=1024 only when the C compiler is clang (GNU gcc has no such limit and rejects the flag); - raise the stack soft limit to the hard limit for the C compile so clang's recursive parser does not overflow. Verified on macOS arm64 (Apple clang 17): full install.sh build now completes under the default 8 MB stack. GNU gcc-16 builds the file unchanged (flag not added). --- src/arsig/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/arsig/Makefile b/src/arsig/Makefile index 20b9154..fb95016 100644 --- a/src/arsig/Makefile +++ b/src/arsig/Makefile @@ -11,6 +11,11 @@ OBJ_PATH = .obj/ FTN = gfortran FFLAGS = -g -O0 CFLAGS = -std=c99 +# Apple clang caps C bracket nesting at 256; the generated xgb_model.c exceeds it. +# GNU gcc has no such limit and rejects -fbracket-depth, so add it for clang only. +ifneq (,$(findstring clang,$(shell gcc --version 2>/dev/null))) + CFLAGS += -fbracket-depth=1024 +endif LIBCOM = ../lib/libcom.a @@ -33,7 +38,7 @@ $(OBJ_PATH)%.o : %.f90 $(OBJ_PATH)%.o : %.c $(DIR_GUARD) - gcc $(CFLAGS) -c $< -o $@ + ulimit -s $$(ulimit -Hs) 2>/dev/null || true; gcc $(CFLAGS) -c $< -o $@