~ubuntu-branches/ubuntu/quantal/lightning-extension/quantal-security

« back to all changes in this revision

Viewing changes to mozilla/build/autoconf/compiler-opts.m4

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-05-21 16:09:39 UTC
  • mfrom: (1.3.1) (25.1.1 precise-security)
  • Revision ID: package-import@ubuntu.com-20120521160939-0702473a46xfq3tl
Tags: 1.5~b2+build1-0ubuntu1
New upstream release from the beta channel (CALENDAR_1_5b2_BUILD1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl Add compiler specific options
 
2
 
 
3
AC_DEFUN([MOZ_COMPILER_OPTS],
 
4
[
 
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
 
9
    ## from C.
 
10
    _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-unknown-warning-option -Wno-return-type-c-linkage"
 
11
fi
 
12
 
 
13
if test "$GNU_CC"; then
 
14
    CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
 
15
    CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
 
16
fi
 
17
 
 
18
dnl ========================================================
 
19
dnl = Identical Code Folding
 
20
dnl ========================================================
 
21
 
 
22
MOZ_ARG_DISABLE_BOOL(icf,
 
23
[  --disable-icf          Disable Identical Code Folding],
 
24
    MOZ_DISABLE_ICF=1,
 
25
    MOZ_DISABLE_ICF= )
 
26
 
 
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],
 
29
        LD_SUPPORTS_ICF,
 
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
 
34
        # the same address
 
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
 
38
            LD_SUPPORTS_ICF=yes
 
39
        else
 
40
            LD_SUPPORTS_ICF=no
 
41
        fi
 
42
        rm -rf conftest*])
 
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"
 
46
        AC_TRY_LINK([], [],
 
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"
 
51
    fi
 
52
fi
 
53
 
 
54
dnl ========================================================
 
55
dnl = Automatically remove dead symbols
 
56
dnl ========================================================
 
57
 
 
58
if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -n "$MOZ_DEBUG_FLAGS"; then
 
59
   dnl See bug 670659
 
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
 
71
            else
 
72
                GC_SECTIONS_BREAKS_DEBUG_RANGES=yes
 
73
            fi
 
74
        else
 
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"
 
77
        fi
 
78
        rm -rf conftest*])
 
79
    if test "$GC_SECTIONS_BREAKS_DEBUG_RANGES" = no; then
 
80
        DSO_LDOPTS="$DSO_LDOPTS -Wl,--gc-sections"
 
81
    fi
 
82
fi
 
83
 
 
84
])