]> git.lizzy.rs Git - rust.git/commitdiff
mk: Build jemalloc with -ffunction-sections
authorAlex Crichton <alex@alexcrichton.com>
Thu, 25 Dec 2014 04:20:01 +0000 (20:20 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 25 Dec 2014 04:20:01 +0000 (20:20 -0800)
It's quite possible that small programs don't use all of jemalloc, and building
with -ffunction-sections and -fdata-sections allows the linker (via
--gc-sections) to strip out all unused code at link time. This decreases the
size of a "hello world" executable for me from 716K to 482K with no measurable
impact on link time. After this patch jemalloc is still the largest portion of
our hello world executables, but this helps cut down on the size at least
somewhat!

mk/rt.mk

index a1d18aae1b45948fbdcbdad8a9fd9f58f1a4fd04..6a7be26c7a686abe1d959fe972a2a2c1e91ad987 100644 (file)
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -180,7 +180,7 @@ $$(JEMALLOC_LOCAL_$(1)): $$(JEMALLOC_DEPS) $$(MKFILE_DEPS)
                AR="$$(AR_$(1))" \
                RANLIB="$$(AR_$(1)) s" \
                CPPFLAGS="-I $(S)src/rt/" \
-               EXTRA_CFLAGS="-g1"
+               EXTRA_CFLAGS="-g1 -ffunction-sections -fdata-sections"
        $$(Q)$$(MAKE) -C "$$(JEMALLOC_BUILD_DIR_$(1))" build_lib_static
 
 ifeq ($$(CFG_DISABLE_JEMALLOC),)