[PATCH] D44791: [scudo] Fuchsia minimal shared runtime
Kostya Kortchinsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 25 13:11:29 PDT 2018
cryptoad updated this revision to Diff 139745.
cryptoad added a comment.
Finally got the toolchain working.
A few changes: `-nostdlib++` is a clang flag, and as of now Fuchsia requires
`libunwind` to be explicitely linked (it was in `SANITIZER_CXX_ABI_LIBRARY`
before). It will go away when I am done splitting the stacktraces from
RTSanitizerCommon.
Resulting binary for Fuchsia is no longer C++ dependent (UBSan is gone - for
now), but still has ~512kB of unneeded BSS usage due to the internal allocator
used by the symbolizer. This will also go away when the split it done.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D44791
Files:
lib/scudo/CMakeLists.txt
Index: lib/scudo/CMakeLists.txt
===================================================================
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,15 +4,25 @@
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)
+if (FUCHSIA)
+ list(APPEND SCUDO_CFLAGS -nostdinc++ -nostdlib++)
+ # TODO(kostyak): remove when stacktraces are split off of RTSanitizerCommon
+ list(APPEND SCUDO_DYNAMIC_LIBS unwind_shared)
+endif()
+
set(SCUDO_SOURCES
scudo_allocator.cpp
scudo_crc32.cpp
@@ -38,13 +48,6 @@
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}
@@ -65,18 +68,32 @@
CFLAGS ${SCUDO_CFLAGS}
PARENT_TARGET scudo)
- add_compiler_rt_runtime(clang_rt.scudo
- SHARED
- ARCHS ${SCUDO_SUPPORTED_ARCH}
- SOURCES ${SCUDO_SOURCES} ${SCUDO_CXX_SOURCES}
- OBJECT_LIBS RTSanitizerCommonNoTermination
- RTSanitizerCommonLibc
- RTSanitizerCommonCoverage
- RTInterception
- RTUbsan
- RTUbsan_cxx
- CFLAGS ${SCUDO_CFLAGS}
- LINK_FLAGS ${SCUDO_DYNAMIC_LINK_FLAGS}
- LINK_LIBS ${SCUDO_DYNAMIC_LIBS}
- PARENT_TARGET scudo)
+ if (NOT FUCHSIA)
+ add_compiler_rt_runtime(clang_rt.scudo
+ SHARED
+ ARCHS ${SCUDO_SUPPORTED_ARCH}
+ SOURCES ${SCUDO_SOURCES} ${SCUDO_CXX_SOURCES}
+ OBJECT_LIBS RTSanitizerCommonNoTermination
+ RTSanitizerCommonLibc
+ RTSanitizerCommonCoverage
+ RTInterception
+ RTUbsan
+ RTUbsan_cxx
+ CFLAGS ${SCUDO_CFLAGS}
+ LINK_FLAGS ${SCUDO_DYNAMIC_LINK_FLAGS}
+ LINK_LIBS ${SCUDO_DYNAMIC_LIBS} ${SANITIZER_CXX_ABI_LIBRARY}
+ PARENT_TARGET scudo)
+ else()
+ add_compiler_rt_runtime(clang_rt.scudo
+ SHARED
+ ARCHS ${SCUDO_SUPPORTED_ARCH}
+ SOURCES ${SCUDO_SOURCES} ${SCUDO_CXX_SOURCES}
+ OBJECT_LIBS RTSanitizerCommonNoTermination
+ RTSanitizerCommonLibc
+ RTInterception
+ CFLAGS ${SCUDO_CFLAGS}
+ LINK_FLAGS ${SCUDO_DYNAMIC_LINK_FLAGS}
+ LINK_LIBS ${SCUDO_DYNAMIC_LIBS}
+ PARENT_TARGET scudo)
+ endif()
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44791.139745.patch
Type: text/x-patch
Size: 3451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180325/b5145078/attachment.bin>
More information about the llvm-commits
mailing list