Bug 1067893 - Detect OTOOL in configure. r=glandium
authorGeorg Koppen <gk@torproject.org>
Tue, 25 Nov 2014 05:12:00 -0500
changeset 244063 9f67efecf1b42b529fe1c65779895008b0de56df
parent 244062 a770fca02a0ecc9fb2fd49a686de89df98552c33
child 244064 b6e09893ea97f0de1f6152bbf035091e8ae7aea6
push id660
push userraliiev@mozilla.com
push dateWed, 18 Feb 2015 20:30:48 +0000
treeherdermozilla-release@49e493494178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1067893
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1067893 - Detect OTOOL in configure. r=glandium
build/autoconf/toolchain.m4
build/macosx/universal/mozconfig.common
build/unix/rewrite_asan_dylib.py
configure.in
toolkit/library/dependentlibs.py
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -156,16 +156,17 @@ unset ac_cv_prog_CXX
 AC_PROG_CXX
 
 AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", :)
 AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", :)
 MOZ_PATH_PROGS(AS, "${target_alias}-as" "${target}-as", :)
 AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", :)
 AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", :)
 AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", :)
+AC_CHECK_PROGS(OTOOL, "${target_alias}-otool" "${target}-otool", :)
 AC_DEFINE(CROSS_COMPILE)
 CROSS_COMPILE=1
 
 dnl If we cross compile for ppc on Mac OS X x86, cross_compiling will
 dnl dnl have erroneously been set to "no", because the x86 build host is
 dnl dnl able to run ppc code in a translated environment, making a cross
 dnl dnl compiler appear native.  So we override that here.
 cross_compiling=yes
--- a/build/macosx/universal/mozconfig.common
+++ b/build/macosx/universal/mozconfig.common
@@ -37,17 +37,18 @@ if test "$MOZ_BUILD_APP" = "i386" -o "$M
   CXX="$CXX -arch $TARGET_CPU"
 
   # These must be set for cross builds, and don't hurt straight builds.
   RANLIB=ranlib
   AR=ar
   AS=$CC
   LD=ld
   STRIP="strip"
+  OTOOL="otool"
 
   # Each per-CPU build should be entirely oblivious to the fact that a
   # universal binary will be produced.  The exception is packager.mk, which
   # needs to know to look for universal bits when building the .dmg.
   UNIVERSAL_BINARY=1
 
-  export CC CXX HOST_CC HOST_CXX RANLIB AR AS LD STRIP
+  export CC CXX HOST_CC HOST_CXX RANLIB AR AS LD STRIP OTOOL
 fi
 fi
--- a/build/unix/rewrite_asan_dylib.py
+++ b/build/unix/rewrite_asan_dylib.py
@@ -1,16 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import sys
 import os
 import subprocess
 import shutil
+from buildconfig import substs
 
 '''
 Scans the given directories for binaries referencing the AddressSanitizer
 runtime library, copies it to the main directory and rewrites binaries to not
 reference it with absolute paths but with @executable_path instead.
 '''
 
 # This is the dylib we're looking for
@@ -23,17 +24,17 @@ def scan_directory(path):
         for filename in files:
             filename = os.path.join(root, filename)
 
             # Skip all files that aren't either dylibs or executable
             if not (filename.endswith('.dylib') or os.access(filename, os.X_OK)):
                 continue
 
             try:
-                otoolOut = subprocess.check_output(['otool', '-L', filename])
+                otoolOut = subprocess.check_output([substs['OTOOL'], '-L', filename])
             except:
                 # Errors are expected on non-mach executables, ignore them and continue
                 continue
 
             for line in otoolOut.splitlines():
                 if line.find(DYLIB_NAME) != -1:
                     absDylibPath = line.split()[0]
 
--- a/configure.in
+++ b/configure.in
@@ -365,16 +365,17 @@ else
     esac
     AC_PROG_CXX
     AC_PROG_RANLIB
     MOZ_PATH_PROGS(AS, $AS as, $CC)
     AC_CHECK_PROGS(AR, ar, :)
     AC_CHECK_PROGS(LD, ld, :)
     AC_CHECK_PROGS(STRIP, strip, :)
     AC_CHECK_PROGS(WINDRES, windres, :)
+    AC_CHECK_PROGS(OTOOL, otool, :)
     if test -z "$HOST_CC"; then
         HOST_CC="$CC"
     fi
     if test -z "$HOST_CFLAGS"; then
         HOST_CFLAGS="$CFLAGS"
     fi
     if test -z "$HOST_CXX"; then
         HOST_CXX="$CXX"
@@ -7168,22 +7169,22 @@ elif test -n "$MOZ_REPLACE_MALLOC"; then
             ac_cv_weak_dynamic_linking,
             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
                 test -s conftest${DLL_SUFFIX}; then
                  dnl There are several ways the linker can put link edit rules in a binary:
                  dnl - classic info only (for OSX < 10.6)
                  dnl - dyld info only
                  dnl - both
-                 if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
+                 if "$OTOOL" -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
                      _CLASSIC_INFO=
                  else
                      _CLASSIC_INFO=1
                  fi
-                 if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
+                 if "$OTOOL" -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
                      _DYLD_INFO=1
                  else
                      _DYLD_INFO=
                  fi
                  dnl With classic info, we need to build with -flat_namespace.
                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
                  dnl forgets to set the weak flag in the dyld info.
--- a/toolkit/library/dependentlibs.py
+++ b/toolkit/library/dependentlibs.py
@@ -12,16 +12,17 @@ import re
 import fnmatch
 import subprocess
 import sys
 from mozpack.executables import (
     get_type,
     ELF,
     MACHO,
 )
+from buildconfig import substs
 
 TOOLCHAIN_PREFIX = ''
 
 def dependentlibs_dumpbin(lib):
     '''Returns the list of dependencies declared in the given DLL'''
     try:
         proc = subprocess.Popen(['dumpbin', '-dependents', lib], stdout = subprocess.PIPE)
     except OSError:
@@ -66,17 +67,17 @@ def dependentlibs_readelf(lib):
             match = re.search('\[(.*)\]', tmp[3])
             if match:
                 deps.append(match.group(1))
     proc.wait()
     return deps
 
 def dependentlibs_otool(lib):
     '''Returns the list of dependencies declared in the given MACH-O dylib'''
-    proc = subprocess.Popen(['otool', '-l', lib], stdout = subprocess.PIPE)
+    proc = subprocess.Popen([substs['OTOOL'], '-l', lib], stdout = subprocess.PIPE)
     deps= []
     cmd = None
     for line in proc.stdout:
         # otool -l output contains many different things. The interesting data
         # is under "Load command n" sections, with the content:
         #           cmd LC_LOAD_DYLIB
         #       cmdsize 56
         #          name libname (offset 24)