@@ -32,6 +32,20 @@ set(ASAN_SOURCES
32
32
asan_win.cpp
33
33
)
34
34
35
+ if (WIN32 )
36
+ set (ASAN_DYNAMIC_RUNTIME_THUNK_SOURCES
37
+ asan_globals_win.cpp
38
+ asan_win_common_runtime_thunk.cpp
39
+ asan_win_dynamic_runtime_thunk.cpp
40
+ )
41
+ set (ASAN_STATIC_RUNTIME_THUNK_SOURCES
42
+ asan_globals_win.cpp
43
+ asan_malloc_win_thunk.cpp
44
+ asan_win_common_runtime_thunk.cpp
45
+ asan_win_static_runtime_thunk.cpp
46
+ )
47
+ endif ()
48
+
35
49
if (NOT WIN32 AND NOT APPLE )
36
50
list (APPEND ASAN_SOURCES
37
51
asan_interceptors_vfork.S
@@ -136,7 +150,7 @@ append_list_if(MINGW "${MINGW_LIBRARIES}" ASAN_DYNAMIC_LIBS)
136
150
add_compiler_rt_object_libraries(RTAsan_dynamic
137
151
OS ${SANITIZER_COMMON_SUPPORTED_OS}
138
152
ARCHS ${ASAN_SUPPORTED_ARCH}
139
- SOURCES ${ASAN_SOURCES} ${ASAN_CXX_SOURCES}
153
+ SOURCES ${ASAN_SOURCES}
140
154
ADDITIONAL_HEADERS ${ASAN_HEADERS}
141
155
CFLAGS ${ASAN_DYNAMIC_CFLAGS}
142
156
DEFS ${ASAN_DYNAMIC_DEFINITIONS} )
@@ -221,46 +235,52 @@ else()
221
235
RTSanitizerCommonSymbolizerInternal
222
236
RTLSanCommon
223
237
RTUbsan)
238
+ if (NOT WIN32 )
239
+ add_compiler_rt_runtime(clang_rt.asan
240
+ STATIC
241
+ ARCHS ${ASAN_SUPPORTED_ARCH}
242
+ OBJECT_LIBS RTAsan_preinit
243
+ RTAsan
244
+ ${ASAN_COMMON_RUNTIME_OBJECT_LIBS}
245
+ CFLAGS ${ASAN_CFLAGS}
246
+ DEFS ${ASAN_COMMON_DEFINITIONS}
247
+ PARENT_TARGET asan)
224
248
225
- add_compiler_rt_runtime(clang_rt.asan
226
- STATIC
227
- ARCHS ${ASAN_SUPPORTED_ARCH}
228
- OBJECT_LIBS RTAsan_preinit
229
- RTAsan
230
- ${ASAN_COMMON_RUNTIME_OBJECT_LIBS}
231
- CFLAGS ${ASAN_CFLAGS}
232
- DEFS ${ASAN_COMMON_DEFINITIONS}
233
- PARENT_TARGET asan)
234
-
235
- add_compiler_rt_runtime(clang_rt.asan_cxx
236
- STATIC
237
- ARCHS ${ASAN_SUPPORTED_ARCH}
238
- OBJECT_LIBS RTAsan_cxx
239
- RTUbsan_cxx
240
- CFLAGS ${ASAN_CFLAGS}
241
- DEFS ${ASAN_COMMON_DEFINITIONS}
242
- PARENT_TARGET asan)
249
+ add_compiler_rt_runtime(clang_rt.asan_cxx
250
+ STATIC
251
+ ARCHS ${ASAN_SUPPORTED_ARCH}
252
+ OBJECT_LIBS RTAsan_cxx
253
+ RTUbsan_cxx
254
+ CFLAGS ${ASAN_CFLAGS}
255
+ DEFS ${ASAN_COMMON_DEFINITIONS}
256
+ PARENT_TARGET asan)
243
257
244
- add_compiler_rt_runtime(clang_rt.asan_static
245
- STATIC
246
- ARCHS ${ASAN_SUPPORTED_ARCH}
247
- OBJECT_LIBS RTAsan_static
248
- CFLAGS ${ASAN_CFLAGS}
249
- DEFS ${ASAN_COMMON_DEFINITIONS}
250
- PARENT_TARGET asan)
258
+ add_compiler_rt_runtime(clang_rt.asan_static
259
+ STATIC
260
+ ARCHS ${ASAN_SUPPORTED_ARCH}
261
+ OBJECT_LIBS RTAsan_static
262
+ CFLAGS ${ASAN_CFLAGS}
263
+ DEFS ${ASAN_COMMON_DEFINITIONS}
264
+ PARENT_TARGET asan)
251
265
252
- add_compiler_rt_runtime(clang_rt.asan-preinit
253
- STATIC
254
- ARCHS ${ASAN_SUPPORTED_ARCH}
255
- OBJECT_LIBS RTAsan_preinit
256
- CFLAGS ${ASAN_CFLAGS}
257
- DEFS ${ASAN_COMMON_DEFINITIONS}
258
- PARENT_TARGET asan)
266
+ add_compiler_rt_runtime(clang_rt.asan-preinit
267
+ STATIC
268
+ ARCHS ${ASAN_SUPPORTED_ARCH}
269
+ OBJECT_LIBS RTAsan_preinit
270
+ CFLAGS ${ASAN_CFLAGS}
271
+ DEFS ${ASAN_COMMON_DEFINITIONS}
272
+ PARENT_TARGET asan)
273
+ endif ()
259
274
260
275
foreach (arch ${ASAN_SUPPORTED_ARCH} )
261
276
if (COMPILER_RT_HAS_VERSION_SCRIPT)
277
+ if (WIN32 )
278
+ set (SANITIZER_RT_VERSION_LIST_LIBS clang_rt.asan-${arch} )
279
+ else ()
280
+ set (SANITIZER_RT_VERSION_LIST_LIBS clang_rt.asan-${arch} clang_rt.asan_cxx-${arch} )
281
+ endif ()
262
282
add_sanitizer_rt_version_list(clang_rt.asan-dynamic-${arch}
263
- LIBS clang_rt.asan- ${arch} clang_rt.asan_cxx- ${arch }
283
+ LIBS ${SANITIZER_RT_VERSION_LIST_LIBS }
264
284
EXTRA asan.syms.extra)
265
285
set (VERSION_SCRIPT_FLAG
266
286
-Wl,--version -script,${CMAKE_CURRENT_BINARY_DIR} /clang_rt.asan-dynamic-${arch} .vers)
@@ -278,25 +298,11 @@ else()
278
298
endif ()
279
299
280
300
set (ASAN_DYNAMIC_WEAK_INTERCEPTION)
281
- if (WIN32 )
282
- add_compiler_rt_object_libraries(AsanWeakInterception
283
- ${SANITIZER_COMMON_SUPPORTED_OS}
284
- ARCHS ${arch}
285
- SOURCES
286
- asan_win_weak_interception.cpp
287
- CFLAGS ${ASAN_CFLAGS} -DSANITIZER_DYNAMIC
288
- DEFS ${ASAN_COMMON_DEFINITIONS} )
289
- set (ASAN_DYNAMIC_WEAK_INTERCEPTION
290
- AsanWeakInterception
291
- UbsanWeakInterception
292
- SancovWeakInterception
293
- SanitizerCommonWeakInterception)
294
- endif ()
295
-
296
301
add_compiler_rt_runtime(clang_rt.asan
297
302
SHARED
298
303
ARCHS ${arch}
299
304
OBJECT_LIBS ${ASAN_COMMON_RUNTIME_OBJECT_LIBS}
305
+ RTAsan_cxx
300
306
RTAsan_dynamic
301
307
# The only purpose of RTAsan_dynamic_version_script_dummy is to
302
308
# carry a dependency of the shared runtime on the version script.
@@ -324,49 +330,48 @@ else()
324
330
endif ()
325
331
326
332
if (WIN32 )
327
- add_compiler_rt_object_libraries(AsanDllThunk
328
- ${SANITIZER_COMMON_SUPPORTED_OS}
329
- ARCHS ${arch}
330
- SOURCES asan_globals_win.cpp
331
- asan_win_dll_thunk.cpp
332
- CFLAGS ${ASAN_CFLAGS} -DSANITIZER_DLL_THUNK
333
- DEFS ${ASAN_COMMON_DEFINITIONS} )
334
-
335
- add_compiler_rt_runtime(clang_rt.asan_dll_thunk
336
- STATIC
337
- ARCHS ${arch}
338
- OBJECT_LIBS AsanDllThunk
339
- UbsanDllThunk
340
- SancovDllThunk
341
- SanitizerCommonDllThunk
342
- SOURCES $<TARGET_OBJECTS:RTInterception.${arch} >
343
- PARENT_TARGET asan)
344
-
345
333
set (DYNAMIC_RUNTIME_THUNK_CFLAGS "-DSANITIZER_DYNAMIC_RUNTIME_THUNK" )
346
- if (MSVC )
347
- list (APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-Zl" )
348
- elseif (CMAKE_C_COMPILER_ID MATCHES Clang)
349
- list (APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-nodefaultlibs" )
350
- endif ()
351
334
352
335
add_compiler_rt_object_libraries(AsanDynamicRuntimeThunk
353
336
${SANITIZER_COMMON_SUPPORTED_OS}
354
337
ARCHS ${arch}
355
- SOURCES asan_globals_win.cpp
356
- asan_win_dynamic_runtime_thunk.cpp
338
+ SOURCES ${ASAN_DYNAMIC_RUNTIME_THUNK_SOURCES}
357
339
CFLAGS ${ASAN_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
358
340
DEFS ${ASAN_COMMON_DEFINITIONS} )
359
341
360
342
add_compiler_rt_runtime(clang_rt.asan_dynamic_runtime_thunk
361
343
STATIC
362
344
ARCHS ${arch}
363
345
OBJECT_LIBS AsanDynamicRuntimeThunk
364
- UbsanDynamicRuntimeThunk
365
- SancovDynamicRuntimeThunk
366
- SanitizerCommonDynamicRuntimeThunk
346
+ UbsanRuntimeThunk
347
+ SancovRuntimeThunk
348
+ SanitizerRuntimeThunk
367
349
CFLAGS ${ASAN_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
368
350
DEFS ${ASAN_COMMON_DEFINITIONS}
369
351
PARENT_TARGET asan)
352
+
353
+ # mingw does not support static linkage of the CRT
354
+ if (NOT MINGW)
355
+ set (STATIC_RUNTIME_THUNK_CFLAGS "-DSANITIZER_STATIC_RUNTIME_THUNK" )
356
+
357
+ add_compiler_rt_object_libraries(AsanStaticRuntimeThunk
358
+ ${SANITIZER_COMMON_SUPPORTED_OS}
359
+ ARCHS ${arch}
360
+ SOURCES ${ASAN_STATIC_RUNTIME_THUNK_SOURCES}
361
+ CFLAGS ${ASAN_DYNAMIC_CFLAGS} ${STATIC_RUNTIME_THUNK_CFLAGS}
362
+ DEFS ${ASAN_DYNAMIC_DEFINITIONS} )
363
+
364
+ add_compiler_rt_runtime(clang_rt.asan_static_runtime_thunk
365
+ STATIC
366
+ ARCHS ${arch}
367
+ OBJECT_LIBS AsanStaticRuntimeThunk
368
+ UbsanRuntimeThunk
369
+ SancovRuntimeThunk
370
+ SanitizerRuntimeThunk
371
+ CFLAGS ${ASAN_DYNAMIC_CFLAGS} ${STATIC_RUNTIME_THUNK_CFLAGS}
372
+ DEFS ${ASAN_DYNAMIC_DEFINITIONS}
373
+ PARENT_TARGET asan)
374
+ endif ()
370
375
endif ()
371
376
endforeach ()
372
377
endif ()
0 commit comments