Skip to content

Commit 7dc5137

Browse files
author
Kostya Kortchinsky
committedMar 6, 2018
[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 llvm-svn: 326833
1 parent 80d3bb3 commit 7dc5137

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎compiler-rt/lib/scudo/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ append_rtti_flag(OFF SCUDO_CFLAGS)
99

1010
set(SCUDO_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
1111

12+
# Use gc-sections by default to avoid unused code being pulled in.
13+
list(APPEND SCUDO_CFLAGS -ffunction-sections -fdata-sections)
14+
list(APPEND SCUDO_DYNAMIC_LINK_FLAGS -Wl,--gc-sections)
15+
1216
set(SCUDO_SOURCES
1317
scudo_allocator.cpp
1418
scudo_crc32.cpp

0 commit comments

Comments
 (0)
Please sign in to comment.