[compiler-rt] b9663eb - [SCUDO] add cmake options for custom sysroot
Michael Jones via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 15:03:13 PDT 2022
Author: Michael Jones
Date: 2022-10-12T15:03:04-07:00
New Revision: b9663ebbf825eed3fc45fbb7d4773271ee2ca259
URL: https://github.com/llvm/llvm-project/commit/b9663ebbf825eed3fc45fbb7d4773271ee2ca259
DIFF: https://github.com/llvm/llvm-project/commit/b9663ebbf825eed3fc45fbb7d4773271ee2ca259.diff
LOG: [SCUDO] add cmake options for custom sysroot
These options will allow the SCUDO standalone to be built with custom
headers. Specifically, this patch will enable building with the
LLVM-libc headers.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D135702
Added:
Modified:
compiler-rt/CMakeLists.txt
compiler-rt/lib/scudo/standalone/CMakeLists.txt
Removed:
################################################################################
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index fc7607ea521ce..7f4737f221e88 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -57,6 +57,13 @@ option(COMPILER_RT_BUILD_GWP_ASAN "Build GWP-ASan, and link it into SCUDO" ON)
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)
+option(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC "Build SCUDO standalone with LLVM's libc headers" OFF)
+mark_as_advanced(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC)
+
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
index 4b586bc662b45..d7d1c3259fbab 100644
--- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt
+++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt
@@ -38,6 +38,10 @@ list(APPEND SCUDO_LINK_FLAGS -ffunction-sections -fdata-sections -Wl,--gc-sectio
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)
@@ -137,6 +141,14 @@ endif()
set(SCUDO_LINK_LIBS ${COMPILER_RT_UNWINDER_LINK_LIBS})
+if(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC)
+ include_directories(${COMPILER_RT_BINARY_DIR}/../libc/include/)
+
+ set(SCUDO_DEPS libc-headers)
+
+ list(APPEND SCUDO_CFLAGS "-ffreestanding")
+endif()
+
append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread SCUDO_LINK_FLAGS)
append_list_if(FUCHSIA zircon SCUDO_LINK_LIBS)
@@ -150,17 +162,20 @@ if(COMPILER_RT_HAS_SCUDO_STANDALONE)
ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
SOURCES ${SCUDO_SOURCES}
ADDITIONAL_HEADERS ${SCUDO_HEADERS}
- CFLAGS ${SCUDO_CFLAGS})
+ CFLAGS ${SCUDO_CFLAGS}
+ DEPS ${SCUDO_DEPS})
add_compiler_rt_object_libraries(RTScudoStandaloneCWrappers
ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
SOURCES ${SCUDO_SOURCES_C_WRAPPERS}
ADDITIONAL_HEADERS ${SCUDO_HEADERS}
- CFLAGS ${SCUDO_CFLAGS})
+ CFLAGS ${SCUDO_CFLAGS}
+ DEPS ${SCUDO_DEPS})
add_compiler_rt_object_libraries(RTScudoStandaloneCxxWrappers
ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH}
SOURCES ${SCUDO_SOURCES_CXX_WRAPPERS}
ADDITIONAL_HEADERS ${SCUDO_HEADERS}
- CFLAGS ${SCUDO_CFLAGS})
+ CFLAGS ${SCUDO_CFLAGS}
+ DEPS ${SCUDO_DEPS})
add_compiler_rt_runtime(clang_rt.scudo_standalone
STATIC
@@ -168,6 +183,7 @@ if(COMPILER_RT_HAS_SCUDO_STANDALONE)
SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS}
ADDITIONAL_HEADERS ${SCUDO_HEADERS}
CFLAGS ${SCUDO_CFLAGS}
+ DEPS ${SCUDO_DEPS}
OBJECT_LIBS ${SCUDO_OBJECT_LIBS}
PARENT_TARGET scudo_standalone)
add_compiler_rt_runtime(clang_rt.scudo_standalone_cxx
@@ -176,18 +192,22 @@ if(COMPILER_RT_HAS_SCUDO_STANDALONE)
SOURCES ${SCUDO_SOURCES_CXX_WRAPPERS}
ADDITIONAL_HEADERS ${SCUDO_HEADERS}
CFLAGS ${SCUDO_CFLAGS}
+ DEPS ${SCUDO_DEPS}
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}
+ DEPS ${SCUDO_DEPS}
+ 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)
More information about the llvm-commits
mailing list