From 7d377a0f02cc07958065a2d4cd47fdc059a71307 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 20 Apr 2026 20:47:59 -0400 Subject: [PATCH] clang detection in unix hints Closes #1500 but it does apply the pull request. Hopefully, this makes things a little clearer. --- sys/unix/hints/include/compiler.370 | 19 ++++++++++++++----- sys/unix/hints/linux.370 | 2 +- sys/unix/hints/macOS.370 | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/unix/hints/include/compiler.370 b/sys/unix/hints/include/compiler.370 index 100d86299..70f9eadeb 100755 --- a/sys/unix/hints/include/compiler.370 +++ b/sys/unix/hints/include/compiler.370 @@ -14,7 +14,7 @@ CCFLAGS = -g #If you want to force use of one particular set of compilers, do it #here, ahead of the detection, so that the detection will match your -#choice and set variables CCISCLANG, GCCGTEQ, CLANGPPGTEQ9 etc. +#choice and set variables CCISCLANG, CCISGCC, GCCGTEQ, CLANGPPGTEQ9 etc. #accordingly. # #CC= gcc @@ -41,7 +41,7 @@ endif # If you want to override the compiler detection just carried out # uncomment one of the following pairs. Note, however, that # doing this after the detection above will likely result in -# mismatched variable values for CCISCLANG, GCCGTEQ, CLANGPPGTEQ9 etc. +# mismatched variable values for CCISCLANG, CCISGCC, GCCGTEQ, CLANGPPGTEQ9 etc. # #CC= gcc #CXX= g++ -std-gnu++11 @@ -72,8 +72,17 @@ CFLAGS+=-Wstrict-prototypes CFLAGS+=-Wnonnull #detection of clang vs gcc -CCISCLANG := $(shell echo `$(CC) --version` | grep clang) -ifeq "$(CCISCLANG)" "" +CCTEST := $(shell echo `$(CC) --version` | grep clang) +ifneq "$(CCTEST)" "" +CCISCLANG=1 +CCISGCC= +else +CCISCLANG= +CCISGCC=1 +endif +#$(info CCISCLANG=$(CCISCLANG), CCISGCC=$(CCISGCC)) + +ifeq "$(CCISGCC)" "1" # gcc-specific follows CXX=g++ -std=gnu++11 # get the version of gcc @@ -95,8 +104,8 @@ CFLAGS+=-Wimplicit-fallthrough #endif # end of gcc-specific else # gcc or clang? -CXX=clang++ -std=gnu++11 # clang-specific follows +CXX=clang++ -std=gnu++11 CLANGGTEQ12 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 12) CLANGGTEQ14 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 14) CLANGGTEQ21 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 21) diff --git a/sys/unix/hints/linux.370 b/sys/unix/hints/linux.370 index 3ceb7cda3..8b402350c 100755 --- a/sys/unix/hints/linux.370 +++ b/sys/unix/hints/linux.370 @@ -415,7 +415,7 @@ endif SYSCFLAGS=-DLUA_USE_LINUX ifdef GITSUBMODULES LUAFLAGS=CC='$(CC)' SYSCFLAGS='$(SYSCFLAGS)' -ifneq "$(CCISCLANG)" "" +ifeq "$(CCISCLANG)" "1" # clang LUAFLAGS +=CWARNGCC='' endif # clang diff --git a/sys/unix/hints/macOS.370 b/sys/unix/hints/macOS.370 index 31279a3cd..02e5dbba6 100755 --- a/sys/unix/hints/macOS.370 +++ b/sys/unix/hints/macOS.370 @@ -338,7 +338,7 @@ endif # WANT_LIBNH # this needs to be passed via make rather than defined in unixconf.h ifdef GITSUBMODULES LUAFLAGS=CC='$(CC)' MYCFLAGS=' -DLUA_USE_MACOSX' -ifneq "$(CCISCLANG)" "" +ifeq "$(CCISCLANG)" "1" # clang LUAFLAGS +=CWARNGCC='' endif # clang