bug 748797 - support MOZ_LINKER_EXTRACT=1 as a configure option to turn on linker extraction all the time. r=glandium,blassey, a=android-only
authorTed Mielczarek <ted.mielczarek@gmail.com>
Wed, 02 May 2012 07:15:07 -0400
changeset 92815 7e182328da46f489b9cac28ada0b9825df44f367
parent 92814 78e104d007e04ad20b205b844c0cd98a97a5bd11
child 92816 b60dc9ae8aae63fa003416c7d57e5a583cc76678
push id8889
push usertmielczarek@mozilla.com
push dateWed, 02 May 2012 14:07:22 +0000
treeherdermozilla-inbound@7e182328da46 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium, blassey, android-only
bugs748797
milestone15.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 748797 - support MOZ_LINKER_EXTRACT=1 as a configure option to turn on linker extraction all the time. r=glandium,blassey, a=android-only CLOSED TREE
config/autoconf.mk.in
configure.in
mobile/android/base/App.java.in
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoAppShell.java
mobile/android/base/Makefile.in
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -710,16 +710,18 @@ ANDROID_PACKAGE_NAME = @ANDROID_PACKAGE_
 JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@
 
 MOZ_INSTRUMENT_EVENT_LOOP = @MOZ_INSTRUMENT_EVENT_LOOP@
 
 MOZ_SYSTEM_PLY = @MOZ_SYSTEM_PLY@
 
 MOZ_PACKAGE_JSSHELL = @MOZ_PACKAGE_JSSHELL@
 
+MOZ_LINKER_EXTRACT = @MOZ_LINKER_EXTRACT@
+
 # We only want to do the pymake sanity on Windows, other os's can cope
 ifeq ($(HOST_OS_ARCH),WINNT)
 # Ensure invariants between GNU Make and pymake
 # Checked here since we want the sane error in a file that
 # actually can be found regardless of path-style.
 ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
 $(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
 endif
--- a/configure.in
+++ b/configure.in
@@ -8485,16 +8485,17 @@ AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
 
 AC_SUBST(USE_DEPENDENT_LIBS)
 
 AC_SUBST(MOZ_BUILD_ROOT)
 AC_SUBST(MOZ_OS2_TOOLS)
 
 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
+AC_SUBST(MOZ_LINKER_EXTRACT)
 
 dnl ========================================================
 dnl = Mac bundle name prefix
 dnl ========================================================
 MOZ_ARG_WITH_STRING(macbundlename-prefix,
 [  --with-macbundlename-prefix=prefix
                           Prefix for MOZ_MACBUNDLE_NAME],
 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
--- a/mobile/android/base/App.java.in
+++ b/mobile/android/base/App.java.in
@@ -74,10 +74,17 @@ public class App extends GeckoApp {
 #ifdef MOZ_PROFILING
         if (item.getItemId() == R.id.toggle_profiling) {
             GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("ToggleProfiling", null));
             return true;
         }
 #endif
         return super.onOptionsItemSelected(item);
     }
+
+#ifdef MOZ_LINKER_EXTRACT
+    @Override
+    public boolean linkerExtract() {
+        return true;
+    }
+#endif
 };
 
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -2826,9 +2826,13 @@ abstract public class GeckoApp
             public boolean onTouch(View view, MotionEvent event) {
                 if (event == null)
                     return true;
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createMotionEvent(event));
                 return true;
             }
         });
     }
+
+    public boolean linkerExtract() {
+        return false;
+    }
 }
\ No newline at end of file
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -305,31 +305,36 @@ public class GeckoAppShell
 
         // The package data lib directory isn't placed in ld.so's
         // search path, so we have to manually load libraries that
         // libxul will depend on.  Not ideal.
         GeckoProfile profile = GeckoProfile.get(context);
 
         File cacheFile = getCacheDir(context);
         putenv("GRE_HOME=" + getGREDir(context).getPath());
-        File[] files = cacheFile.listFiles();
-        if (files != null) {
-            Iterator<File> cacheFiles = Arrays.asList(files).iterator();
-            while (cacheFiles.hasNext()) {
-                File libFile = cacheFiles.next();
-                if (libFile.getName().endsWith(".so"))
-                    libFile.delete();
+
+        // setup the libs cache
+        String linkerCache = System.getenv("MOZ_LINKER_CACHE");
+        if (linkerCache == null) {
+            linkerCache = cacheFile.getPath();
+            GeckoAppShell.putenv("MOZ_LINKER_CACHE=" + linkerCache);
+        }
+
+        if (GeckoApp.mAppContext != null &&
+            GeckoApp.mAppContext.linkerExtract()) {
+            GeckoAppShell.putenv("MOZ_LINKER_EXTRACT=1");
+            // Ensure that the cache dir is world-writable
+            File cacheDir = new File(linkerCache);
+            if (cacheDir.isDirectory()) {
+                cacheDir.setWritable(true, false);
+                cacheDir.setExecutable(true, false);
+                cacheDir.setReadable(true, false);
             }
         }
 
-        // setup the libs cache
-        String linkerCache = System.getenv("MOZ_LINKER_CACHE");
-        if (System.getenv("MOZ_LINKER_CACHE") == null) {
-            GeckoAppShell.putenv("MOZ_LINKER_CACHE=" + cacheFile.getPath());
-        }
         sLibsSetup = true;
     }
 
     private static void setupPluginEnvironment(GeckoApp context) {
         // setup plugin path directories
         try {
             String[] dirs = context.getPluginDirectories();
             StringBuffer pluginSearchPath = new StringBuffer();
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -207,16 +207,20 @@ DEFINES += \
   -DMOZ_CHILD_PROCESS_NAME=$(MOZ_CHILD_PROCESS_NAME) \
   -DMOZ_MIN_CPU_VERSION=$(MIN_CPU_VERSION) \
   -DMOZ_CRASHREPORTER=$(MOZ_CRASHREPORTER) \
   -DANDROID_VERSION_CODE=$(ANDROID_VERSION_CODE) \
   -DMOZILLA_OFFICIAL=$(MOZILLA_OFFICIAL) \
   -DUA_BUILDID=$(UA_BUILDID) \
   $(NULL)
 
+ifdef MOZ_LINKER_EXTRACT
+DEFINES += -DMOZ_LINKER_EXTRACT=1
+endif
+
 GARBAGE += \
   AndroidManifest.xml  \
   classes.dex  \
   $(FENNEC_PP_JAVA_FILES) \
   $(SYNC_PP_JAVA_FILES) \
   gecko.ap_  \
   res/values/strings.xml \
   R.java \