Bug 638149 - Need a way to disable -dead_strip on OS X; r=ted
☠☠ backed out by 224477bd4b3c ☠ ☠
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Wed, 02 Mar 2011 21:29:00 -0500
changeset 64036 eb6edf77b7c8979df539d1bf2caafb4d0d1dcbb3
parent 64035 7b9f40070259da7a35dc9338c7d5fda196ff4c5c
child 64037 224477bd4b3cd848f3b77489babd53251a2d7583
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/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
@@ -1977,16 +1977,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
@@ -2078,19 +2080,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
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