From 26bee8ad36030c89b1300d5095f56fa635b53b95 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 7 Apr 2025 16:06:01 +0900 Subject: [PATCH 1/3] drop a few unsupported CFLAGS for clang --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 51e9f98e..1fd856f9 100644 --- a/Makefile +++ b/Makefile @@ -59,12 +59,15 @@ BENCH_PERF := $(BENCH_RUNNER:%=%.perf) BENCH_TRACE := $(BENCH_RUNNER:%=%.trace) BENCH_CSV := $(BENCH_RUNNER:%=%.csv) -CFLAGS += -fcallgraph-info=su CFLAGS += -g3 CFLAGS += -I. CFLAGS += -std=c99 -Wall -Wextra -pedantic CFLAGS += -Wmissing-prototypes +ifeq ($(shell $(CC) --version | grep clang),) CFLAGS += -ftrack-macro-expansion=0 +CFLAGS += -fcallgraph-info=su +endif + ifdef DEBUG CFLAGS += -O0 else From bff4dfd1b1f6f2ee53bd4aae6de5d3b66c172251 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 7 May 2025 22:46:31 -0500 Subject: [PATCH 2/3] Added NO_GCC to allow users to explicitly disable GCC-specific flags This is the same as the implicit Clang => NO_GCC behavior introduced by yamt, but with an explicit variable that can be assigned by users using other, non-gcc, compilers: $ NO_GCC=1 make Note, stack measurements are currently GCC specific: $ NO_GCC=1 make stack ... snip ... FileNotFoundError: [Errno 2] No such file or directory: 'lfs.ci' make: *** [Makefile:494: lfs.stack.csv] Error 1 --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1fd856f9..588e095d 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,12 @@ VALGRIND ?= valgrind GDB ?= gdb PERF ?= perf +# guess clang or gcc (clang sometimes masquerades as gcc because of +# course it does) +ifneq ($(shell $(CC) --version | grep clang),) +NO_GCC = 1 +endif + SRC ?= $(filter-out $(wildcard *.t.* *.b.*),$(wildcard *.c)) OBJ := $(SRC:%.c=$(BUILDDIR)/%.o) DEP := $(SRC:%.c=$(BUILDDIR)/%.d) @@ -63,9 +69,9 @@ CFLAGS += -g3 CFLAGS += -I. CFLAGS += -std=c99 -Wall -Wextra -pedantic CFLAGS += -Wmissing-prototypes -ifeq ($(shell $(CC) --version | grep clang),) -CFLAGS += -ftrack-macro-expansion=0 +ifndef NO_GCC CFLAGS += -fcallgraph-info=su +CFLAGS += -ftrack-macro-expansion=0 endif ifdef DEBUG From 0115cf6b74cc27e288678aeb7f8c977be0792be0 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 7 May 2025 23:45:29 -0500 Subject: [PATCH 3/3] gha: Dropped explicit CFLAGS from clang testing in CI Thanks to yamt, GCC-specific flags should now be disabled if compiling with clang. Dropping the explicit flags also doubles as a test that the NO_GCC inference works. --- .github/workflows/test.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3100bee..f18c23d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -454,8 +454,7 @@ jobs: TESTFLAGS="$TESTFLAGS --valgrind --context=1024 -Gdefault -Pnone" \ make test - # test that compilation is warning free under clang - # run with Clang, mostly to check for Clang-specific warnings + # compile/run with Clang, mostly to check for Clang-specific warnings test-clang: runs-on: ubuntu-latest steps: @@ -469,12 +468,8 @@ jobs: python3 --version - name: test-clang run: | - # override CFLAGS since Clang does not support -fcallgraph-info - # and -ftrack-macro-expansions - make \ - CC=clang \ - CFLAGS="$CFLAGS -MMD -g3 -I. -std=c99 -Wall -Wextra -pedantic" \ - test + CC=clang \ + make test # run benchmarks #