mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 670659 - Detect GNU ld bug with debugging symbols when using --gc-sections and don't use it then. r=khuey
This commit is contained in:
parent
6bd23f9c3b
commit
84658faf83
47
configure.in
47
configure.in
@ -1549,10 +1549,8 @@ if test "$GNU_CC"; then
|
||||
MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
|
||||
DSO_LDOPTS='-shared'
|
||||
if test "$GCC_USE_GNU_LD"; then
|
||||
# Don't allow undefined symbols in libraries, and remove dead symbols
|
||||
DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs -Wl,--gc-sections"
|
||||
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
|
||||
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
|
||||
# Don't allow undefined symbols in libraries
|
||||
DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
|
||||
fi
|
||||
WARNINGS_AS_ERRORS='-Werror'
|
||||
DSO_CFLAGS=''
|
||||
@ -7298,6 +7296,47 @@ if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
|
||||
export MOZ_DEBUG_SYMBOLS
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Automatically remove dead symbols
|
||||
dnl ========================================================
|
||||
|
||||
if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -n "$MOZ_DEBUG_FLAGS"; then
|
||||
dnl See bug 670659
|
||||
AC_CACHE_CHECK([whether removing dead symbols breaks debugging],
|
||||
GC_SECTIONS_BREAKS_DEBUG_RANGES,
|
||||
[echo 'int foo() {return 42;}' \
|
||||
'int bar() {return 1;}' \
|
||||
'int main() {return foo();}' > conftest.${ac_ext}
|
||||
if AC_TRY_COMMAND([${CC-cc} -o conftest.${ac_objext} $CFLAGS $MOZ_DEBUG_FLAGS -ffunction-sections conftest.${ac_ext} 1>&2]) &&
|
||||
AC_TRY_COMMAND([${CC-cc} -o conftest${ac_exeext} $LDFLAGS $MOZ_DEBUG_FLAGS -ffunction-sections -Wl,--gc-sections conftest.${ac_ext} $LIBS 1>&2]) &&
|
||||
test -s conftest${ac_exeext} -a -s conftest.${ac_objext}; then
|
||||
dnl objdump -WR would be much simpler, but ancient objdump
|
||||
dnl doesn't support it.
|
||||
debug_ranges_lines() {
|
||||
awk '/^Contents/ { content=0 } /^Contents of the \.debug_ranges/ { content=1 } content { n += 1 } END { print n }'
|
||||
}
|
||||
dnl We expect the number of lines after "Contents of the
|
||||
dnl .debug_ranges" to be the same in the object file and the
|
||||
dnl linked program. If it's not, then we are hitting the linker
|
||||
dnl bug.
|
||||
if test `objdump -W conftest.${ac_objext} 2> /dev/null | debug_ranges_lines` = \
|
||||
`objdump -W conftest${ac_exeext} 2> /dev/null | debug_ranges_lines`; then
|
||||
GC_SECTIONS_BREAKS_DEBUG_RANGES=no
|
||||
else
|
||||
GC_SECTIONS_BREAKS_DEBUG_RANGES=yes
|
||||
fi
|
||||
else
|
||||
dnl We really don't expect to get here, but just in case
|
||||
AC_ERROR([couldn't compile a simple C file])
|
||||
fi
|
||||
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"
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Disable any treating of compile warnings as errors
|
||||
dnl ========================================================
|
||||
|
Loading…
Reference in New Issue
Block a user