Bug 675867 - Enable Identical Code Folding when supported by the linker. r=ted

This commit is contained in:
Mike Hommey 2011-08-09 09:06:12 +02:00
parent 9489006cda
commit e01a7b607c

View File

@ -7267,6 +7267,38 @@ if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
export MOZ_DEBUG_SYMBOLS
fi
dnl ========================================================
dnl = Identical Code Folding
dnl ========================================================
MOZ_ARG_DISABLE_BOOL(icf,
[ --disable-icf Disable Identical Code Folding],
MOZ_DISABLE_ICF=1,
MOZ_DISABLE_ICF= )
if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$MOZ_DISABLE_ICF"; then
AC_CACHE_CHECK([whether the linker supports Identical Code Folding],
LD_SUPPORTS_ICF,
[echo 'int foo() {return 42;}' \
'int bar() {return 42;}' \
'int main() {return foo() - bar();}' > conftest.${ac_ext}
# If the linker supports ICF, foo and bar symbols will have
# the same address
if AC_TRY_COMMAND([${CC-cc} -o conftest${ac_exeext} $LDFLAGS -Wl,--icf=safe -ffunction-sections conftest.${ac_ext} $LIBS 1>&2]) &&
test -s conftest${ac_exeext} &&
objdump -t conftest${ac_exeext} | awk '{a[[$6]] = $1} END {if (a[["foo"]] && (a[["foo"]] != a[["bar"]])) { exit 1 }}'; then
LD_SUPPORTS_ICF=yes
else
LD_SUPPORTS_ICF=no
fi
rm -rf conftest*])
if test "$LD_SUPPORTS_ICF" = yes; then
LDFLAGS="$LDFLAGS -Wl,--icf=safe"
CFLAGS="$CFLAGS -ffunction-sections"
CXXFLAGS="$CXXFLAGS -ffunction-sections"
fi
fi
dnl ========================================================
dnl = Automatically remove dead symbols
dnl ========================================================
@ -7294,8 +7326,16 @@ if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -n "$MOZ_DEBUG_FLAGS"; then
rm -rf conftest*])
if test "$GC_SECTIONS_BREAKS_DEBUG_RANGES" = no; then
DSO_LDOPTS="$DSO_LDOPTS -Wl,--gc-sections"
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
case "$CFLAGS" in
*-ffunction-sections*)
CFLAGS="$CFLAGS -fdata-sections"
CXXFLAGS="$CXXFLAGS -fdata-sections"
;;
*)
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
;;
esac
fi
fi