]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
build : pass all warning flags to nvcc via -Xcompiler (#5570)
authorJared Van Bortel <redacted>
Sun, 18 Feb 2024 21:21:52 +0000 (16:21 -0500)
committerGitHub <redacted>
Sun, 18 Feb 2024 21:21:52 +0000 (16:21 -0500)
* build : pass all warning flags to nvcc via -Xcompiler
* make : fix apparent mis-merge from #3952
* make : fix incorrect GF_CC_VER for CUDA host compiler

CMakeLists.txt
Makefile
scripts/get-flags.mk

index 0c29b5d09bd2b1db192587c0596b47fddde054c4..f5e7f2980b04e388aa6e0ab59f21427d50910b6f 100644 (file)
@@ -778,10 +778,7 @@ endif()
 set(CUDA_CXX_FLAGS "")
 
 if (LLAMA_CUBLAS)
-    set(CUDA_FLAGS ${CXX_FLAGS} -use_fast_math)
-    if (NOT MSVC)
-        list(APPEND CUDA_FLAGS -Wno-pedantic)
-    endif()
+    set(CUDA_FLAGS -use_fast_math)
 
     if (LLAMA_ALL_WARNINGS AND NOT MSVC)
         set(NVCC_CMD ${CMAKE_CUDA_COMPILER} .c)
@@ -814,7 +811,11 @@ if (LLAMA_CUBLAS)
         message("-- CUDA host compiler is ${CUDA_CCID} ${CUDA_CCVER}")
 
         get_flags(${CUDA_CCID} ${CUDA_CCVER})
-        list(APPEND CUDA_CXX_FLAGS ${GF_CXX_FLAGS})  # This is passed to -Xcompiler later
+        list(APPEND CUDA_CXX_FLAGS ${CXX_FLAGS} ${GF_CXX_FLAGS})  # This is passed to -Xcompiler later
+    endif()
+
+    if (NOT MSVC)
+        list(APPEND CUDA_CXX_FLAGS -Wno-pedantic)
     endif()
 endif()
 
index 90179860623d01a0f5912b0acc79ac6d2639ed91..f5f6d32a7673584fe1ccf48482b52edff00b2f48 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -220,30 +220,6 @@ ifeq ($(LLAMA_FATAL_WARNINGS),1)
        MK_CXXFLAGS += -Werror
 endif
 
-ifeq ($(CC_IS_CLANG), 1)
-       # clang options
-       MK_CFLAGS        += -Wunreachable-code-break -Wunreachable-code-return
-       MK_HOST_CXXFLAGS += -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi
-
-       ifneq '' '$(and $(CC_IS_LLVM_CLANG),$(filter 1,$(shell expr $(CC_VER) \>= 030800)))'
-               MK_CFLAGS += -Wdouble-promotion
-       endif
-       ifneq '' '$(and $(CC_IS_APPLE_CLANG),$(filter 1,$(shell expr $(CC_VER) \>= 070300)))'
-               MK_CFLAGS += -Wdouble-promotion
-       endif
-else
-       # gcc options
-       MK_CFLAGS        += -Wdouble-promotion
-       MK_HOST_CXXFLAGS += -Wno-array-bounds
-
-       ifeq ($(shell expr $(CC_VER) \>= 070100), 1)
-               MK_HOST_CXXFLAGS += -Wno-format-truncation
-       endif
-       ifeq ($(shell expr $(CC_VER) \>= 080100), 1)
-               MK_HOST_CXXFLAGS += -Wextra-semi
-       endif
-endif
-
 # this version of Apple ld64 is buggy
 ifneq '' '$(findstring dyld-1015.7,$(shell $(CC) $(LDFLAGS) -Wl,-v 2>&1))'
        MK_CPPFLAGS += -DHAVE_BUGGY_APPLE_LINKER
@@ -468,7 +444,7 @@ ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
 ifdef JETSON_EOL_MODULE_DETECT
        $(NVCC) -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/usr/local/cuda/targets/aarch64-linux/include -std=c++11 -O3 $(NVCCFLAGS) -Xcompiler "$(CUDA_CXXFLAGS)" -c $< -o $@
 else
-       $(NVCC) $(BASE_CXXFLAGS) $(NVCCFLAGS) -Wno-pedantic -Xcompiler "$(CUDA_CXXFLAGS)" -c $< -o $@
+       $(NVCC) $(NVCCFLAGS) -Xcompiler "$(CUDA_CXXFLAGS)" -c $< -o $@
 endif # JETSON_EOL_MODULE_DETECT
 endif # LLAMA_CUBLAS
 
@@ -579,7 +555,7 @@ override LDFLAGS   := $(MK_LDFLAGS) $(LDFLAGS)
 ifdef LLAMA_CUBLAS
 GF_CC := $(NVCC) $(NVCCFLAGS) 2>/dev/null .c -Xcompiler
 include scripts/get-flags.mk
-CUDA_CXXFLAGS := $(GF_CXXFLAGS)
+CUDA_CXXFLAGS := $(BASE_CXXFLAGS) $(GF_CXXFLAGS) -Wno-pedantic
 endif
 
 #
index 596d7ead1804332ca520988633b9787bea9bc25d..a742766d1495e818683756ccf1284f7d3293e675 100644 (file)
@@ -1,6 +1,6 @@
 ifeq '' '$(findstring clang,$(shell $(GF_CC) --version))'
        GF_CC_IS_GCC = 1
-       GF_CC_VER := $(shell { $(GF_CC) -dumpfullversion 2>/dev/null || $(GF_CC) -dumpversion; } | awk -F. '{ printf("%02d%02d%02d", $$1, $$2, $$3) }')
+       GF_CC_VER := $(shell { $(GF_CC) -dumpfullversion 2>/dev/null; echo; $(GF_CC) -dumpversion; } | awk -F. '/./ { printf("%02d%02d%02d", $$1, $$2, $$3); exit }')
 else
        GF_CC_IS_CLANG = 1
        ifeq '' '$(findstring Apple,$(shell $(GF_CC) --version))'