|
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
|
@@ -307,25 +314,27 @@ else()
|
307 | 314 | endif()
|
308 | 315 |
|
309 | 316 | set(ASAN_DYNAMIC_WEAK_INTERCEPTION)
|
310 |
| - add_compiler_rt_runtime(clang_rt.asan |
311 |
| - SHARED |
312 |
| - ARCHS ${arch} |
313 |
| - OBJECT_LIBS ${ASAN_COMMON_RUNTIME_OBJECT_LIBS} |
314 |
| - RTAsan_dynamic |
315 |
| - # The only purpose of RTAsan_dynamic_version_script_dummy is to |
316 |
| - # carry a dependency of the shared runtime on the version script. |
317 |
| - # Replacing it with a straightforward |
318 |
| - # add_dependencies(clang_rt.asan-dynamic-${arch} clang_rt.asan-dynamic-${arch}-version-list) |
319 |
| - # generates an order-only dependency in ninja. |
320 |
| - RTAsan_dynamic_version_script_dummy |
321 |
| - RTUbsan_cxx |
322 |
| - ${ASAN_DYNAMIC_WEAK_INTERCEPTION} |
323 |
| - CFLAGS ${ASAN_DYNAMIC_CFLAGS} |
324 |
| - LINK_FLAGS ${ASAN_DYNAMIC_LINK_FLAGS} |
325 |
| - ${VERSION_SCRIPT_FLAG} |
326 |
| - LINK_LIBS ${ASAN_DYNAMIC_LIBS} |
327 |
| - DEFS ${ASAN_DYNAMIC_DEFINITIONS} |
328 |
| - PARENT_TARGET asan) |
| 317 | + if (COMPILER_RT_ASAN_BUILD_SHARED_LIBS) |
| 318 | + add_compiler_rt_runtime(clang_rt.asan |
| 319 | + SHARED |
| 320 | + ARCHS ${arch} |
| 321 | + OBJECT_LIBS ${ASAN_COMMON_RUNTIME_OBJECT_LIBS} |
| 322 | + RTAsan_dynamic |
| 323 | + # The only purpose of RTAsan_dynamic_version_script_dummy is to |
| 324 | + # carry a dependency of the shared runtime on the version script. |
| 325 | + # Replacing it with a straightforward |
| 326 | + # add_dependencies(clang_rt.asan-dynamic-${arch} clang_rt.asan-dynamic-${arch}-version-list) |
| 327 | + # generates an order-only dependency in ninja. |
| 328 | + RTAsan_dynamic_version_script_dummy |
| 329 | + RTUbsan_cxx |
| 330 | + ${ASAN_DYNAMIC_WEAK_INTERCEPTION} |
| 331 | + CFLAGS ${ASAN_DYNAMIC_CFLAGS} |
| 332 | + LINK_FLAGS ${ASAN_DYNAMIC_LINK_FLAGS} |
| 333 | + ${VERSION_SCRIPT_FLAG} |
| 334 | + LINK_LIBS ${ASAN_DYNAMIC_LIBS} |
| 335 | + DEFS ${ASAN_DYNAMIC_DEFINITIONS} |
| 336 | + PARENT_TARGET asan) |
| 337 | + endif() |
329 | 338 |
|
330 | 339 | if (SANITIZER_USE_SYMBOLS AND NOT ${arch} STREQUAL "i386")
|
331 | 340 | add_sanitizer_rt_symbols(clang_rt.asan_cxx
|
|
0 commit comments