Bug 1110760 - Build and Package Chromium Sandbox wow_helper. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 24 Dec 2014 17:13:42 +0900
changeset 222577 c2845100484dfbeb1063bc3c22f3fca715d366b6
parent 222576 7df8d663997106d269d07c31d535824cbc585c8d
child 222578 51e4e9fcde248895ce6713cdb52cb7e2713f9425
push id28068
push usercbook@mozilla.com
push dateThu, 08 Jan 2015 13:16:34 +0000
treeherdermozilla-central@2880e05d5e32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1110760
milestone37.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 1110760 - Build and Package Chromium Sandbox wow_helper. r=gps
browser/installer/Makefile.in
browser/installer/package-manifest.in
security/sandbox/moz.build
security/sandbox/win/wow_helper/Makefile.in
security/sandbox/win/wow_helper/moz.build
--- a/browser/installer/Makefile.in
+++ b/browser/installer/Makefile.in
@@ -142,16 +142,24 @@ DEFINES += -DMOZ_JEMALLOC3
 endif
 DEFINES += -DMOZ_ICU_DBG_SUFFIX=$(MOZ_ICU_DBG_SUFFIX)
 ifdef CLANG_CXX
 DEFINES += -DCLANG_CXX
 endif
 ifdef CLANG_CL
 DEFINES += -DCLANG_CL
 endif
+ifeq (x86,$(CPU_ARCH))
+ifdef _MSC_VER
+ifndef CLANG_CL
+DEFINES += -DWOW_HELPER
+endif
+endif
+endif
+
 
 libs::
 	$(MAKE) -C $(DEPTH)/browser/locales langpack
 
 ifeq (WINNT,$(OS_ARCH))
 PKGCOMP_FIND_OPTS =
 else
 PKGCOMP_FIND_OPTS = -L
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -778,16 +778,19 @@
 @RESPATH@/components/pipboot.xpt
 @RESPATH@/components/pipnss.xpt
 @RESPATH@/components/pippki.xpt
 
 ; For process sandboxing
 #if defined(MOZ_SANDBOX)
 #if defined(XP_WIN)
 @BINPATH@/@DLL_PREFIX@sandboxbroker@DLL_SUFFIX@
+#if defined(WOW_HELPER)
+@BINPATH@/wow_helper.exe
+#endif
 #endif
 #endif
 
 ; for Solaris SPARC
 #ifdef SOLARIS
 bin/libfreebl_32fpu_3.so
 bin/libfreebl_32int_3.so
 bin/libfreebl_32int64_3.so
--- a/security/sandbox/moz.build
+++ b/security/sandbox/moz.build
@@ -13,16 +13,20 @@ elif CONFIG['OS_ARCH'] == 'WINNT':
     FORCE_STATIC_LIB = True
 
     DIRS += [
         'staticruntime',
         'win/src/sandboxbroker',
         'win/src/sandboxtarget',
     ]
 
+    if (CONFIG['CPU_ARCH'] == 'x86' and CONFIG['_MSC_VER'] and not
+            CONFIG['CLANG_CL']):
+        DIRS += ['win/wow_helper']
+
     EXPORTS.mozilla.sandboxing += [
         'win/src/logging/loggingCallbacks.h',
         'win/src/logging/loggingTypes.h',
         'win/src/logging/sandboxLogging.h',
     ]
 
     include('objs.mozbuild')
     SOURCES += security_sandbox_cppsrcs
new file mode 100644
--- /dev/null
+++ b/security/sandbox/win/wow_helper/Makefile.in
@@ -0,0 +1,42 @@
+# 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/.
+
+# We need to build a 64-bits binary during a 32-bits build. This requires
+# a different compiler and different library paths. Until the build system
+# supports this natively.
+
+# Some Make magic to avoid CXX and LIB being evaluated when nothing
+# is built in this directory
+lazy = $(if $(___$(1)),,$(eval ___$(1) := $(2)))$(___$(1))
+
+# We could use the `which` python module, but it needs more code to handle
+# the situation where CXX points to an absolute path. But using the shell
+# which returns a msys path, while we need a windows path. So force msys
+# to do the conversion for us by calling python with an environment variable
+# with the result of the call to `which`. Then munge that path to add the
+# x64 cross-compiler path.
+ifdef MOZ_USING_COMPILER_WRAPPER
+ORIG_CXX := cl
+else
+ORIG_CXX := $(CXX)
+endif
+CXX = $(call lazy,CXX,"$$(subst amd64_x86/x86_amd64/,amd64/,$$(shell CL=`which "$(ORIG_CXX)"` $(PYTHON) -c 'import os; print os.path.dirname(os.environ["CL"])')/x86_amd64/cl.exe)")
+
+MOZ_WINCONSOLE = 0
+
+include $(topsrcdir)/config/config.mk
+
+# Munge the LIB variable to contain paths to the x64 CRT and system libraries.
+# Unconveniently, none of the paths have the same convention, including the
+# compiler path above.
+LIB = $(call lazy,LIB,$$(shell python -c 'import os; print ";".join(s.lower().replace(os.sep, "/").replace("/vc/lib", "/vc/lib/amd64").replace("/um/x86", "/um/x64") for s in os.environ["LIB"].split(";"))'))
+
+CXXFLAGS := $(filter-out -arch:IA32,$(CXXFLAGS))
+
+# OS_COMPILE_CXXFLAGS includes mozilla-config.h, which contains x86-specific
+# defines breaking the build.
+OS_COMPILE_CXXFLAGS :=
+
+# LNK1246: '/SAFESEH' not compatible with 'x64' target machine
+LDFLAGS := $(filter-out -SAFESEH,$(LDFLAGS))
new file mode 100644
--- /dev/null
+++ b/security/sandbox/win/wow_helper/moz.build
@@ -0,0 +1,30 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+Program('wow_helper')
+
+SOURCES += [ '../../chromium/sandbox/win/wow_helper/' + f for f in (
+    'service64_resolver.cc',
+    'target_code.cc',
+    'wow_helper.cc',
+)]
+
+LOCAL_INCLUDES += [
+    '../../',
+    '../../../',
+    '../../chromium/',
+]
+
+DISABLE_STL_WRAPPING = True
+
+DEFINES['UNICODE'] = True
+
+USE_STATIC_LIBS = True
+
+# The rules in Makefile.in only force the use of the 64-bits compiler, not
+# the 64-bits linker, and the 32-bits linker can't do 64-bits compilation for
+# PGO, so disable PGO, which is not interesting for this small binary anyways.
+NO_PGO = True