Skip to content

Commit a884e7f

Browse files
committed
This should work on Windows
After talking with compnerd, because we're passing this directly to the swift driver, we shouldn't have to do anything weird with the flags and it should "just work". I'm frustrated enough with Windows that I'm just going to go with that and go to bed. If I broke something, I'm sorry. I tried as far as my sanity would allow.
1 parent 90abf31 commit a884e7f

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,36 +77,31 @@ endfunction()
7777

7878
function(_add_host_variant_swift_sanitizer_flags target)
7979
if (LLVM_USE_SANITIZER)
80-
if (LLVM_ON_UNIX)
81-
82-
if (LLVM_USE_SANITIZER STREQUAL "Address")
83-
set(_Swift_SANITIZER_FLAGS "-sanitize=address")
84-
elseif (LLVM_USE_SANITIZER STREQUAL "HWAddress")
85-
# Not supported?
86-
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
87-
# Not supported
88-
if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
89-
# Not supported
90-
endif()
91-
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
92-
set(_Swift_SANITIZER_FLAGS "-sanitize=undefined")
93-
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
94-
set(_Swift_SANITIZER_FLAGS "-sanitize=thread")
95-
elseif (LLVM_USE_SANITIZER STREQUAL "DataFlow")
96-
# Not supported
97-
elseif (LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
98-
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
99-
set(_Swift_SANITIZER_FLAGS "-sanitize=address -sanitize=undefined")
100-
elseif (LLVM_USE_SANITIZER STREQUAL "Leaks")
80+
if (LLVM_USE_SANITIZER STREQUAL "Address")
81+
set(_Swift_SANITIZER_FLAGS "-sanitize=address")
82+
elseif (LLVM_USE_SANITIZER STREQUAL "HWAddress")
83+
# Not supported?
84+
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
85+
# Not supported
86+
if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
10187
# Not supported
102-
else()
103-
message(FATAL_ERROR "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
10488
endif()
89+
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
90+
set(_Swift_SANITIZER_FLAGS "-sanitize=undefined")
91+
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
92+
set(_Swift_SANITIZER_FLAGS "-sanitize=thread")
93+
elseif (LLVM_USE_SANITIZER STREQUAL "DataFlow")
94+
# Not supported
95+
elseif (LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
96+
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
97+
set(_Swift_SANITIZER_FLAGS "-sanitize=address -sanitize=undefined")
98+
elseif (LLVM_USE_SANITIZER STREQUAL "Leaks")
99+
# Not supported
100+
else()
101+
message(FATAL_ERROR "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
102+
endif()
105103

106-
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:${_Swift_SANITIZER_FLAGS}>)
107-
else ()
108-
# TODO (etcwilde): Pass sanitizer flags to swiftc on windows
109-
endif ()
104+
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:${_Swift_SANITIZER_FLAGS}>)
110105
endif ()
111106
endfunction()
112107

0 commit comments

Comments
 (0)