diff options
author | Nico Weber <nicolasweber@gmx.de> | 2013-12-27 22:38:59 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2013-12-27 22:38:59 +0000 |
commit | 5e7c782b29d4317db9098e7482046fbbc9933054 (patch) | |
tree | 19e5a016b1bacfb6df8b1717dfd667b7ad975af0 /Makefile.rules | |
parent | b2f47c6a3455a9d265e21c8ab1ca81657ff577a0 (diff) | |
download | llvm-5e7c782b29d4317db9098e7482046fbbc9933054.tar.gz |
Strip dead code when linking by default with BFD ld (linux, ...) and ld64 (os x).
This reduces the size of clang-format from 22 MB to 1.8 MB, diagtool goes from
21 MB to 2.8 MB, libclang.so goes from 29 MB to 20 MB, etc. The size of the
bin/ folder shrinks from 270 MB to 200 MB.
Targets that support plugins and don't already use EXPORTED_SYMBOL_FILE
(which libclang and libLTO already do) can set NO_DEAD_STRIP to opt out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198087 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Makefile.rules')
-rw-r--r-- | Makefile.rules | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Makefile.rules b/Makefile.rules index 68f6cf8ec5d1..1eeadac19899 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -608,6 +608,22 @@ ifndef KEEP_SYMBOLS Install.StripFlag += -s endif +# By default, strip dead symbols at link time +ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) +ifneq ($(HOST_OS),Darwin) + CXX.Flags += -ffunction-sections -fdata-sections +endif +endif +ifndef NO_DEAD_STRIP + ifeq ($(HOST_OS),Darwin) + LD.Flags += -Wl,-dead_strip + else + ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) + LD.Flags += -Wl,--gc-sections + endif + endif +endif + # Adjust linker flags for building an executable ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) ifndef TOOL_NO_EXPORTS |