Skip to content

Commit 9a03bc8

Browse files
committed
cmake : move sanitizer flags to llama_add_compile_flags
ggml-ci
1 parent ce293d8 commit 9a03bc8

File tree

5 files changed

+17
-68
lines changed

5 files changed

+17
-68
lines changed

cmake/common.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,21 @@ function(llama_add_compile_flags)
3030
set(CXX_FLAGS "" PARENT_SCOPE)
3131
endif()
3232
endif()
33+
34+
if (NOT MSVC)
35+
if (LLAMA_SANITIZE_THREAD)
36+
add_compile_options(-fsanitize=thread)
37+
link_libraries (-fsanitize=thread)
38+
endif()
39+
40+
if (LLAMA_SANITIZE_ADDRESS)
41+
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
42+
link_libraries (-fsanitize=address)
43+
endif()
44+
45+
if (LLAMA_SANITIZE_UNDEFINED)
46+
add_compile_options(-fsanitize=undefined)
47+
link_libraries (-fsanitize=undefined)
48+
endif()
49+
endif()
3350
endfunction()

common/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@ find_package(Threads REQUIRED)
44

55
llama_add_compile_flags()
66

7-
if (NOT MSVC)
8-
if (LLAMA_SANITIZE_THREAD)
9-
add_compile_options(-fsanitize=thread)
10-
link_libraries (-fsanitize=thread)
11-
endif()
12-
13-
if (LLAMA_SANITIZE_ADDRESS)
14-
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
15-
link_libraries (-fsanitize=address)
16-
endif()
17-
18-
if (LLAMA_SANITIZE_UNDEFINED)
19-
add_compile_options(-fsanitize=undefined)
20-
link_libraries (-fsanitize=undefined)
21-
endif()
22-
endif()
23-
247
# Build info header
258
#
269

examples/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,6 @@ find_package(Threads REQUIRED)
1010

1111
llama_add_compile_flags()
1212

13-
if (NOT MSVC)
14-
if (LLAMA_SANITIZE_THREAD)
15-
add_compile_options(-fsanitize=thread)
16-
link_libraries (-fsanitize=thread)
17-
endif()
18-
19-
if (LLAMA_SANITIZE_ADDRESS)
20-
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
21-
link_libraries (-fsanitize=address)
22-
endif()
23-
24-
if (LLAMA_SANITIZE_UNDEFINED)
25-
add_compile_options(-fsanitize=undefined)
26-
link_libraries (-fsanitize=undefined)
27-
endif()
28-
endif()
29-
3013
# examples
3114

3215
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

src/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
llama_add_compile_flags()
22

3-
if (NOT MSVC)
4-
if (LLAMA_SANITIZE_THREAD)
5-
add_compile_options(-fsanitize=thread)
6-
link_libraries (-fsanitize=thread)
7-
endif()
8-
9-
if (LLAMA_SANITIZE_ADDRESS)
10-
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
11-
link_libraries (-fsanitize=address)
12-
endif()
13-
14-
if (LLAMA_SANITIZE_UNDEFINED)
15-
add_compile_options(-fsanitize=undefined)
16-
link_libraries (-fsanitize=undefined)
17-
endif()
18-
endif()
19-
203
#
214
# libraries
225
#

tests/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
llama_add_compile_flags()
22

3-
if (NOT MSVC)
4-
if (LLAMA_SANITIZE_THREAD)
5-
add_compile_options(-fsanitize=thread)
6-
link_libraries (-fsanitize=thread)
7-
endif()
8-
9-
if (LLAMA_SANITIZE_ADDRESS)
10-
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
11-
link_libraries (-fsanitize=address)
12-
endif()
13-
14-
if (LLAMA_SANITIZE_UNDEFINED)
15-
add_compile_options(-fsanitize=undefined)
16-
link_libraries (-fsanitize=undefined)
17-
endif()
18-
endif()
19-
203
function(llama_test target)
214
include(CMakeParseArguments)
225
set(options)

0 commit comments

Comments
 (0)