Bug 638149 - Need a way to disable -dead_strip on OS X. r=ted
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Sat, 09 Apr 2011 05:23:27 +1000
changeset 67706 f858cc85724a1ae4d4a4ca8f0dae1867c21b7207
parent 67705 877127eae177507f65bc689347f26e28789524bb
child 67707 352ebc13e54645934749205638ff4ebc6515cc85
child 68543 dd0f92e2ea923fe998685eed2fb61cec1708a147
push idunknown
push userunknown
push dateunknown
reviewersted
bugs638149
milestone2.2a1pre
Bug 638149 - Need a way to disable -dead_strip on OS X. r=ted
aclocal.m4
build/autoconf/lto.m4
configure.in
js/src/aclocal.m4
js/src/build/autoconf/lto.m4
js/src/configure.in
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -9,16 +9,17 @@ builtin(include, build/autoconf/nspr.m4)
 builtin(include, build/autoconf/nss.m4)dnl
 builtin(include, build/autoconf/pkg.m4)dnl
 builtin(include, build/autoconf/freetype2.m4)dnl
 builtin(include, build/autoconf/codeset.m4)dnl
 builtin(include, build/autoconf/altoptions.m4)dnl
 builtin(include, build/autoconf/mozprog.m4)dnl
 builtin(include, build/autoconf/mozheader.m4)dnl
 builtin(include, build/autoconf/acwinpaths.m4)dnl
+builtin(include, build/autoconf/lto.m4)dnl
 
 MOZ_PROG_CHECKMSYS()
 
 # Read the user's .mozconfig script.  We can't do this in
 # configure.in: autoconf puts the argument parsing code above anything
 # expanded from configure.in, and we need to get the configure options
 # from .mozconfig in place before that argument parsing code.
 MOZ_READ_MOZCONFIG(.)
new file mode 100644
--- /dev/null
+++ b/build/autoconf/lto.m4
@@ -0,0 +1,15 @@
+dnl check if the build is using lto. This is really primitive and only detects llvm based
+dnl compilers right now.
+AC_DEFUN(MOZ_DOING_LTO,
+[
+  cat > conftest.c <<EOF
+                  int foo = 1;
+EOF
+  $1=no
+  if ${CC-cc} ${CFLAGS} -S conftest.c -o conftest.s >/dev/null 2>&1; then
+    if grep '^target triple =' conftest.s; then
+      $1=yes
+    fi
+  fi
+  rm -f conftest.[cs]
+])
--- a/configure.in
+++ b/configure.in
@@ -2002,16 +2002,18 @@ FIREFOX_VERSION=`cat $_topsrcdir/browser
 
 if test -z "$FIREFOX_VERSION"; then
     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
 fi
 
 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
 
+MOZ_DOING_LTO(lto_is_enabled)
+
 dnl ========================================================
 dnl System overrides of the defaults for target
 dnl ========================================================
 
 case "$target" in
 *-aix*)
     AC_DEFINE(AIX)
     if test ! "$GNU_CC"; then
@@ -2103,19 +2105,21 @@ case "$target" in
     STRIP="$STRIP -x -S"
     _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
     # The ExceptionHandling framework is needed for Objective-C exception
     # logging code in nsObjCExceptions.h. Currently we only use that in debug
     # builds.
     MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"
 
+    if test "x$lto_is_enabled" = "xyes"; then
+        echo "Skipping -dead_strip because lto is enabled."
     dnl DTrace and -dead_strip don't interact well. See bug 403132.
     dnl ===================================================================
-    if test "x$enable_dtrace" = "xyes"; then
+    elif test "x$enable_dtrace" = "xyes"; then
         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
     else
         dnl check for the presence of the -dead_strip linker flag
         AC_MSG_CHECKING([for -dead_strip option to ld])
         _SAVE_LDFLAGS=$LDFLAGS
         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
         if test -n "$_HAVE_DEAD_STRIP" ; then
--- a/js/src/aclocal.m4
+++ b/js/src/aclocal.m4
@@ -4,10 +4,11 @@ dnl The contents of this file are under 
 dnl 
 
 builtin(include, build/autoconf/pkg.m4)dnl
 builtin(include, build/autoconf/nspr.m4)dnl
 builtin(include, build/autoconf/altoptions.m4)dnl
 builtin(include, build/autoconf/moznbytetype.m4)dnl
 builtin(include, build/autoconf/mozprog.m4)dnl
 builtin(include, build/autoconf/acwinpaths.m4)dnl
+builtin(include, build/autoconf/lto.m4)dnl
 
 MOZ_PROG_CHECKMSYS()
new file mode 100644
--- /dev/null
+++ b/js/src/build/autoconf/lto.m4
@@ -0,0 +1,15 @@
+dnl check if the build is using lto. This is really primitive and only detects llvm based
+dnl compilers right now.
+AC_DEFUN(MOZ_DOING_LTO,
+[
+  cat > conftest.c <<EOF
+                  int foo = 1;
+EOF
+  $1=no
+  if ${CC-cc} ${CFLAGS} -S conftest.c -o conftest.s >/dev/null 2>&1; then
+    if grep '^target triple =' conftest.s; then
+      $1=yes
+    fi
+  fi
+  rm -f conftest.[cs]
+])
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -1881,16 +1881,18 @@ changequote(,)
 $PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1] or sys.version[:2] != '2.')" $PYTHON_VERSION
 _python_res=$?
 changequote([,])
 if test "$_python_res" != 0; then
     AC_MSG_ERROR([Python $PYTHON_VERSION or higher (but not Python 3.x) is required.])
 fi
 AC_MSG_RESULT([yes])
 
+MOZ_DOING_LTO(lto_is_enabled)
+
 dnl ========================================================
 dnl System overrides of the defaults for target
 dnl ========================================================
 
 case "$target" in
 *-aix*)
     AC_DEFINE(AIX)
     if test ! "$GNU_CC"; then
@@ -1985,19 +1987,21 @@ case "$target" in
     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
     # The ExceptionHandling framework is needed for Objective-C exception
     # logging code in nsObjCExceptions.h. Currently we only use that in debug
     # builds.
     MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"
 
+    if test "x$lto_is_enabled" = "xyes"; then
+        echo "Skipping -dead_strip because lto is enabled."
     dnl DTrace and -dead_strip don't interact well. See bug 403132.
     dnl ===================================================================
-    if test "x$enable_dtrace" = "xyes"; then
+    elif test "x$enable_dtrace" = "xyes"; then
         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
     else
         dnl check for the presence of the -dead_strip linker flag
         AC_MSG_CHECKING([for -dead_strip option to ld])
         _SAVE_LDFLAGS=$LDFLAGS
         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
         if test -n "$_HAVE_DEAD_STRIP" ; then