|
1 | 1 | # Build for the AddressSanitizer runtime support library.
|
2 | 2 |
|
| 3 | +set(COMPILER_RT_ASAN_BUILD_SHARED_LIBS_default ON) |
| 4 | +if (CMAKE_SYSTEM_NAME STREQUAL "WASI") |
| 5 | + set(COMPILER_RT_ASAN_BUILD_SHARED_LIBS_default OFF) |
| 6 | +endif() |
| 7 | +option(COMPILER_RT_ASAN_BUILD_SHARED_LIBS |
| 8 | + "Build AddressSanitizer shared libraries" ${COMPILER_RT_ASAN_BUILD_SHARED_LIBS_default}) |
| 9 | + |
3 | 10 | set(ASAN_SOURCES
|
4 | 11 | asan_allocator.cpp
|
5 | 12 | asan_activation.cpp
|
@@ -296,25 +303,27 @@ else()
|
296 | 303 | SanitizerCommonWeakInterception)
|
297 | 304 | endif()
|
298 | 305 |
|
299 |
| - add_compiler_rt_runtime(clang_rt.asan |
300 |
| - SHARED |
301 |
| - ARCHS ${arch} |
302 |
| - OBJECT_LIBS ${ASAN_COMMON_RUNTIME_OBJECT_LIBS} |
303 |
| - RTAsan_dynamic |
304 |
| - # The only purpose of RTAsan_dynamic_version_script_dummy is to |
305 |
| - # carry a dependency of the shared runtime on the version script. |
306 |
| - # Replacing it with a straightforward |
307 |
| - # add_dependencies(clang_rt.asan-dynamic-${arch} clang_rt.asan-dynamic-${arch}-version-list) |
308 |
| - # generates an order-only dependency in ninja. |
309 |
| - RTAsan_dynamic_version_script_dummy |
310 |
| - RTUbsan_cxx |
311 |
| - ${ASAN_DYNAMIC_WEAK_INTERCEPTION} |
312 |
| - CFLAGS ${ASAN_DYNAMIC_CFLAGS} |
313 |
| - LINK_FLAGS ${ASAN_DYNAMIC_LINK_FLAGS} |
314 |
| - ${VERSION_SCRIPT_FLAG} |
315 |
| - LINK_LIBS ${ASAN_DYNAMIC_LIBS} |
316 |
| - DEFS ${ASAN_DYNAMIC_DEFINITIONS} |
317 |
| - PARENT_TARGET asan) |
| 306 | + if (COMPILER_RT_ASAN_BUILD_SHARED_LIBS) |
| 307 | + add_compiler_rt_runtime(clang_rt.asan |
| 308 | + SHARED |
| 309 | + ARCHS ${arch} |
| 310 | + OBJECT_LIBS ${ASAN_COMMON_RUNTIME_OBJECT_LIBS} |
| 311 | + RTAsan_dynamic |
| 312 | + # The only purpose of RTAsan_dynamic_version_script_dummy is to |
| 313 | + # carry a dependency of the shared runtime on the version script. |
| 314 | + # Replacing it with a straightforward |
| 315 | + # add_dependencies(clang_rt.asan-dynamic-${arch} clang_rt.asan-dynamic-${arch}-version-list) |
| 316 | + # generates an order-only dependency in ninja. |
| 317 | + RTAsan_dynamic_version_script_dummy |
| 318 | + RTUbsan_cxx |
| 319 | + ${ASAN_DYNAMIC_WEAK_INTERCEPTION} |
| 320 | + CFLAGS ${ASAN_DYNAMIC_CFLAGS} |
| 321 | + LINK_FLAGS ${ASAN_DYNAMIC_LINK_FLAGS} |
| 322 | + ${VERSION_SCRIPT_FLAG} |
| 323 | + LINK_LIBS ${ASAN_DYNAMIC_LIBS} |
| 324 | + DEFS ${ASAN_DYNAMIC_DEFINITIONS} |
| 325 | + PARENT_TARGET asan) |
| 326 | + endif() |
318 | 327 |
|
319 | 328 | if (SANITIZER_USE_SYMBOLS AND NOT ${arch} STREQUAL "i386")
|
320 | 329 | add_sanitizer_rt_symbols(clang_rt.asan_cxx
|
|
0 commit comments