1
dnl Add compiler specific options
3
AC_DEFUN([MOZ_COMPILER_OPTS],
5
if test "$CLANG_CXX"; then
6
## We disable return-type-c-linkage because jsval is defined as a C++ type but is
7
## returned by C functions. This is possible because we use knowledge about the ABI
8
## to typedef it to a C type with the same layout when the headers are included
10
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-unknown-warning-option -Wno-return-type-c-linkage"
13
if test "$GNU_CC"; then
14
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
15
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
18
dnl ========================================================
19
dnl = Identical Code Folding
20
dnl ========================================================
22
MOZ_ARG_DISABLE_BOOL(icf,
23
[ --disable-icf Disable Identical Code Folding],
27
if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$MOZ_DISABLE_ICF"; then
28
AC_CACHE_CHECK([whether the linker supports Identical Code Folding],
30
[echo 'int foo() {return 42;}' \
31
'int bar() {return 42;}' \
32
'int main() {return foo() - bar();}' > conftest.${ac_ext}
33
# If the linker supports ICF, foo and bar symbols will have
35
if AC_TRY_COMMAND([${CC-cc} -o conftest${ac_exeext} $LDFLAGS -Wl,--icf=safe -ffunction-sections conftest.${ac_ext} $LIBS 1>&2]) &&
36
test -s conftest${ac_exeext} &&
37
objdump -t conftest${ac_exeext} | awk changequote(<<, >>)'{a[<<$>>6] = <<$>>1} END {if (a["foo"] && (a["foo"] != a["bar"])) { exit 1 }}'changequote([, ]); then
43
if test "$LD_SUPPORTS_ICF" = yes; then
44
_SAVE_LDFLAGS="$LDFLAGS -Wl,--icf=safe"
45
LDFLAGS="$LDFLAGS -Wl,--icf=safe -Wl,--print-icf-sections"
47
[LD_PRINT_ICF_SECTIONS=-Wl,--print-icf-sections],
48
[LD_PRINT_ICF_SECTIONS=])
49
AC_SUBST([LD_PRINT_ICF_SECTIONS])
50
LDFLAGS="$_SAVE_LDFLAGS"
54
dnl ========================================================
55
dnl = Automatically remove dead symbols
56
dnl ========================================================
58
if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -n "$MOZ_DEBUG_FLAGS"; then
60
AC_CACHE_CHECK([whether removing dead symbols breaks debugging],
61
GC_SECTIONS_BREAKS_DEBUG_RANGES,
62
[echo 'int foo() {return 42;}' \
63
'int bar() {return 1;}' \
64
'int main() {return foo();}' > conftest.${ac_ext}
65
if AC_TRY_COMMAND([${CC-cc} -o conftest.${ac_objext} $CFLAGS $MOZ_DEBUG_FLAGS -c conftest.${ac_ext} 1>&2]) &&
66
AC_TRY_COMMAND([${CC-cc} -o conftest${ac_exeext} $LDFLAGS $MOZ_DEBUG_FLAGS -Wl,--gc-sections conftest.${ac_objext} $LIBS 1>&2]) &&
67
test -s conftest${ac_exeext} -a -s conftest.${ac_objext}; then
68
if test "`$PYTHON "$_topsrcdir"/build/autoconf/check_debug_ranges.py conftest.${ac_objext} conftest.${ac_ext}`" = \
69
"`$PYTHON "$_topsrcdir"/build/autoconf/check_debug_ranges.py conftest${ac_exeext} conftest.${ac_ext}`"; then
70
GC_SECTIONS_BREAKS_DEBUG_RANGES=no
72
GC_SECTIONS_BREAKS_DEBUG_RANGES=yes
75
dnl We really don't expect to get here, but just in case
76
GC_SECTIONS_BREAKS_DEBUG_RANGES="no, but it's broken in some other way"
79
if test "$GC_SECTIONS_BREAKS_DEBUG_RANGES" = no; then
80
DSO_LDOPTS="$DSO_LDOPTS -Wl,--gc-sections"