[compiler-rt] r326833 - [scudo] Use gc-sections by default

Kostya Kortchinsky via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 6 12:13:37 PST 2018


Author: cryptoad
Date: Tue Mar  6 12:13:37 2018
New Revision: 326833

URL: http://llvm.org/viewvc/llvm-project?rev=326833&view=rev
Log:
[scudo] Use gc-sections by default

Summary:
If not using `-Wl,--gc-sections`, a whole lot of unused `sanitizer_common` code
and related static variables are pulled into the shared library.
Keep the binary size smaller, and its memory footprint smaller as well, by
using the compiler flags `-ffunction-section` & `-fdata-sections` by default,
as well as the linker flags `-Wl,--gc-sections`.

Current experiments show a large discrepency between binary sizes generated
by gcc (big) and clang (small). I am not sure yet how I can make a test that
would encompass both, so it's an outstanding work item.

Reviewers: alekseyshl, flowerhack

Reviewed By: alekseyshl

Subscribers: mgorny, delcypher, llvm-commits, #sanitizers

Differential Revision: https://reviews.llvm.org/D44121

Modified:
    compiler-rt/trunk/lib/scudo/CMakeLists.txt

Modified: compiler-rt/trunk/lib/scudo/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/CMakeLists.txt?rev=326833&r1=326832&r2=326833&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/scudo/CMakeLists.txt Tue Mar  6 12:13:37 2018
@@ -9,6 +9,10 @@ append_rtti_flag(OFF SCUDO_CFLAGS)
 
 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_SOURCES
   scudo_allocator.cpp
   scudo_crc32.cpp




More information about the llvm-commits mailing list