mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-11-03 09:22:01 +00:00 
			
		
		
		
	cmake : apply only sanitizer flags at top level
ggml-ci
This commit is contained in:
		@@ -83,9 +83,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake)
 | 
			
		||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
 | 
			
		||||
 | 
			
		||||
# override ggml options
 | 
			
		||||
set(GGML_SANITIZE_THREAD    ${LLAMA_SANITIZE_THREAD})
 | 
			
		||||
set(GGML_SANITIZE_ADDRESS   ${LLAMA_SANITIZE_ADDRESS})
 | 
			
		||||
set(GGML_SANITIZE_UNDEFINED ${LLAMA_SANITIZE_UNDEFINED})
 | 
			
		||||
set(GGML_ALL_WARNINGS   ${LLAMA_ALL_WARNINGS})
 | 
			
		||||
set(GGML_FATAL_WARNINGS ${LLAMA_FATAL_WARNINGS})
 | 
			
		||||
 | 
			
		||||
@@ -117,6 +114,23 @@ llama_option_depr(WARNING     LLAMA_SYCL                GGML_SYCL)
 | 
			
		||||
llama_option_depr(WARNING     LLAMA_SYCL_F16            GGML_SYCL_F16)
 | 
			
		||||
llama_option_depr(WARNING     LLAMA_CANN                GGML_CANN)
 | 
			
		||||
 | 
			
		||||
if (NOT MSVC)
 | 
			
		||||
    if (LLAMA_SANITIZE_THREAD)
 | 
			
		||||
        add_compile_options(-fsanitize=thread)
 | 
			
		||||
        link_libraries     (-fsanitize=thread)
 | 
			
		||||
    endif()
 | 
			
		||||
 | 
			
		||||
    if (LLAMA_SANITIZE_ADDRESS)
 | 
			
		||||
        add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
 | 
			
		||||
        link_libraries     (-fsanitize=address)
 | 
			
		||||
    endif()
 | 
			
		||||
 | 
			
		||||
    if (LLAMA_SANITIZE_UNDEFINED)
 | 
			
		||||
        add_compile_options(-fsanitize=undefined)
 | 
			
		||||
        link_libraries     (-fsanitize=undefined)
 | 
			
		||||
    endif()
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# 3rd party
 | 
			
		||||
#
 | 
			
		||||
@@ -130,8 +144,6 @@ endif()
 | 
			
		||||
# build the library
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
llama_add_compile_flags() # llama-only flags
 | 
			
		||||
 | 
			
		||||
add_subdirectory(src)
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
 
 | 
			
		||||
@@ -30,21 +30,4 @@ function(llama_add_compile_flags)
 | 
			
		||||
            set(CXX_FLAGS "" PARENT_SCOPE)
 | 
			
		||||
        endif()
 | 
			
		||||
    endif()
 | 
			
		||||
 | 
			
		||||
    if (NOT MSVC)
 | 
			
		||||
        if (LLAMA_SANITIZE_THREAD)
 | 
			
		||||
            add_compile_options(-fsanitize=thread)
 | 
			
		||||
            link_libraries     (-fsanitize=thread)
 | 
			
		||||
        endif()
 | 
			
		||||
 | 
			
		||||
        if (LLAMA_SANITIZE_ADDRESS)
 | 
			
		||||
            add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
 | 
			
		||||
            link_libraries     (-fsanitize=address)
 | 
			
		||||
        endif()
 | 
			
		||||
 | 
			
		||||
        if (LLAMA_SANITIZE_UNDEFINED)
 | 
			
		||||
            add_compile_options(-fsanitize=undefined)
 | 
			
		||||
            link_libraries     (-fsanitize=undefined)
 | 
			
		||||
        endif()
 | 
			
		||||
    endif()
 | 
			
		||||
endfunction()
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
find_package(Threads REQUIRED)
 | 
			
		||||
 | 
			
		||||
llama_add_compile_flags()
 | 
			
		||||
 | 
			
		||||
# Build info header
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ find_package(Threads REQUIRED)
 | 
			
		||||
 | 
			
		||||
# flags
 | 
			
		||||
 | 
			
		||||
# ...
 | 
			
		||||
llama_add_compile_flags()
 | 
			
		||||
 | 
			
		||||
# examples
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
llama_add_compile_flags()
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# libraries
 | 
			
		||||
#
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
llama_add_compile_flags()
 | 
			
		||||
 | 
			
		||||
function(llama_test target)
 | 
			
		||||
    include(CMakeParseArguments)
 | 
			
		||||
    set(options)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user