Index: lib/scudo/CMakeLists.txt =================================================================== --- lib/scudo/CMakeLists.txt +++ lib/scudo/CMakeLists.txt @@ -4,15 +4,34 @@ set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS}) # SANITIZER_COMMON_CFLAGS include -fno-builtin, but we actually want builtins! -list(APPEND SCUDO_CFLAGS -fbuiltin) +list(APPEND SCUDO_CFLAGS -fbuiltin -ffunction-sections -fdata-sections) append_rtti_flag(OFF SCUDO_CFLAGS) -set(SCUDO_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) +set(SCUDO_DYNAMIC_LIBS ${SANITIZER_COMMON_LINK_LIBS}) +append_list_if(COMPILER_RT_HAS_LIBDL dl SCUDO_DYNAMIC_LIBS) +append_list_if(COMPILER_RT_HAS_LIBRT rt SCUDO_DYNAMIC_LIBS) +append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread SCUDO_DYNAMIC_LIBS) +append_list_if(COMPILER_RT_HAS_LIBLOG log SCUDO_DYNAMIC_LIBS) +set(SCUDO_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) # Use gc-sections by default to avoid unused code being pulled in. -list(APPEND SCUDO_CFLAGS -ffunction-sections -fdata-sections) list(APPEND SCUDO_DYNAMIC_LINK_FLAGS -Wl,--gc-sections) +set(SCUDO_OBJECT_LIBS + RTSanitizerCommonNoTermination + RTSanitizerCommonLibc + RTInterception) + +if (FUCHSIA) + list(APPEND SCUDO_CFLAGS -nostdinc++) + list(APPEND SCUDO_DYNAMIC_LINK_FLAGS -nostdlib++) + # TODO(kostyak): remove when stacktraces are split off of RTSanitizerCommon + list(APPEND SCUDO_DYNAMIC_LIBS unwind_shared) +else() + list(APPEND SCUDO_OBJECT_LIBS RTSanitizerCommonCoverage RTUbsan) + list(APPEND SCUDO_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY}) +endif() + set(SCUDO_SOURCES scudo_allocator.cpp scudo_crc32.cpp @@ -38,22 +57,11 @@ endif() if(COMPILER_RT_HAS_SCUDO) - set(SCUDO_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY} - ${SANITIZER_COMMON_LINK_LIBS}) - append_list_if(COMPILER_RT_HAS_LIBDL dl SCUDO_DYNAMIC_LIBS) - append_list_if(COMPILER_RT_HAS_LIBRT rt SCUDO_DYNAMIC_LIBS) - append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread SCUDO_DYNAMIC_LIBS) - append_list_if(COMPILER_RT_HAS_LIBLOG log SCUDO_DYNAMIC_LIBS) - add_compiler_rt_runtime(clang_rt.scudo STATIC ARCHS ${SCUDO_SUPPORTED_ARCH} SOURCES ${SCUDO_SOURCES} - OBJECT_LIBS RTSanitizerCommonNoTermination - RTSanitizerCommonLibc - RTSanitizerCommonCoverage - RTInterception - RTUbsan + OBJECT_LIBS ${SCUDO_OBJECT_LIBS} CFLAGS ${SCUDO_CFLAGS} PARENT_TARGET scudo) @@ -69,12 +77,7 @@ SHARED ARCHS ${SCUDO_SUPPORTED_ARCH} SOURCES ${SCUDO_SOURCES} ${SCUDO_CXX_SOURCES} - OBJECT_LIBS RTSanitizerCommonNoTermination - RTSanitizerCommonLibc - RTSanitizerCommonCoverage - RTInterception - RTUbsan - RTUbsan_cxx + OBJECT_LIBS ${SCUDO_OBJECT_LIBS} CFLAGS ${SCUDO_CFLAGS} LINK_FLAGS ${SCUDO_DYNAMIC_LINK_FLAGS} LINK_LIBS ${SCUDO_DYNAMIC_LIBS}