diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -57,6 +57,11 @@ mark_as_advanced(COMPILER_RT_BUILD_GWP_ASAN) option(COMPILER_RT_ENABLE_CET "Build Compiler RT with CET enabled" OFF) +option(COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH "Set custom sysroot for building SCUDO standalone" OFF) +mark_as_advanced(COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH) +option(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED "Build SCUDO standalone for shared libraries" ON) +mark_as_advanced(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED) + if(FUCHSIA) set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT OFF) else() diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt --- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt @@ -38,6 +38,10 @@ append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ SCUDO_LINK_FLAGS) append_list_if(CXX_SUPPORTS_UNWINDLIB_NONE_FLAG --unwindlib=none SCUDO_LINK_FLAGS) +if(COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH) + list(APPEND SCUDO_CFLAGS "--sysroot=${COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH}") +endif() + if(ANDROID) list(APPEND SCUDO_CFLAGS -fno-emulated-tls) @@ -178,16 +182,18 @@ CFLAGS ${SCUDO_CFLAGS} PARENT_TARGET scudo_standalone) - add_compiler_rt_runtime(clang_rt.scudo_standalone - SHARED - ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} - SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS} ${SCUDO_SOURCES_CXX_WRAPPERS} - ADDITIONAL_HEADERS ${SCUDO_HEADERS} - CFLAGS ${SCUDO_CFLAGS} - OBJECT_LIBS ${SCUDO_OBJECT_LIBS} - LINK_FLAGS ${SCUDO_LINK_FLAGS} - LINK_LIBS ${SCUDO_LINK_LIBS} - PARENT_TARGET scudo_standalone) + if(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED) + add_compiler_rt_runtime(clang_rt.scudo_standalone + SHARED + ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} + SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS} ${SCUDO_SOURCES_CXX_WRAPPERS} + ADDITIONAL_HEADERS ${SCUDO_HEADERS} + CFLAGS ${SCUDO_CFLAGS} + OBJECT_LIBS ${SCUDO_OBJECT_LIBS} + LINK_FLAGS ${SCUDO_LINK_FLAGS} + LINK_LIBS ${SCUDO_LINK_LIBS} + PARENT_TARGET scudo_standalone) + endif() add_subdirectory(benchmarks) if(COMPILER_RT_INCLUDE_TESTS)