Bug 580407 - Link js statically r=bsmedberg+khuey a=bsmedberg
authorTaras Glek <tglek@mozilla.com>
Fri, 13 Aug 2010 21:18:05 -0700
changeset 50577 b6c7ed5a29223eb18b84ed4c76a88800a266568f
parent 50576 d5d9ca9a444597a37b24a4a927f7e9f37a381e0d
child 50578 f3d4f656d43994255803474664e29ad1e6ca5218
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, bsmedberg
bugs580407
milestone2.0b4pre
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 580407 - Link js statically r=bsmedberg+khuey a=bsmedberg
browser/installer/package-manifest.in
config/autoconf.mk.in
config/config.mk
configure.in
js/src/Makefile.in
js/src/config/autoconf.mk.in
js/src/config/config.mk
js/src/configure.in
js/src/jsapi.cpp
js/src/jstypes.h
js/src/xpconnect/shell/Makefile.in
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -33,17 +33,19 @@
 #ifdef XP_WIN32
 #ifndef WINCE
 @BINPATH@/uninstall/helper.exe
 #endif
 #endif
 
 [xpcom]
 @BINPATH@/dependentlibs.list
+#ifndef MOZ_STATIC_JS
 @BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
+#endif
 @BINPATH@/@DLL_PREFIX@plc4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@plds4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@xpcom@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
 #ifdef XP_MACOSX
 @BINPATH@/XUL
 #else
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -673,8 +673,10 @@ HAVE_CLOCK_MONOTONIC = @HAVE_CLOCK_MONOT
 REALTIME_LIBS = @REALTIME_LIBS@
 
 ANDROID_NDK       = @ANDROID_NDK@
 ANDROID_TOOLCHAIN = @ANDROID_TOOLCHAIN@
 ANDROID_PLATFORM  = @ANDROID_PLATFORM@
 ANDROID_SDK       = @ANDROID_SDK@
 ANDROID_TOOLS     = @ANDROID_TOOLS@
 ANDROID_VERSION   = @ANDROID_VERSION@
+
+JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@
--- a/config/config.mk
+++ b/config/config.mk
@@ -386,16 +386,19 @@ DEFINES += \
 		-DEXPORT_XPTC_API \
 		-D_IMPL_NS_GFX \
 		-D_IMPL_NS_WIDGET \
 		-DIMPL_XREAPI \
 		-DIMPL_NS_NET \
 		-DIMPL_THEBES \
 		$(NULL)
 
+ifndef JS_SHARED_LIBRARY
+DEFINES += -DSTATIC_EXPORTABLE_JS_API
+endif
 ifndef MOZ_NATIVE_ZLIB
 DEFINES += -DZLIB_INTERNAL
 endif
 endif
 endif
 
 # Force _all_ exported methods to be |_declspec(dllexport)| when we're
 # building them into the executable.
--- a/configure.in
+++ b/configure.in
@@ -69,16 +69,28 @@ AC_CANONICAL_SYSTEM
 TARGET_CPU="${target_cpu}"
 TARGET_VENDOR="${target_vendor}"
 TARGET_OS="${target_os}"
 
 
 MOZ_DEB_TIMESTAMP=`date +"%a, %d  %b %Y %T %z"   2>&1` 
 AC_SUBST(MOZ_DEB_TIMESTAMP)
 
+MOZ_ARG_ENABLE_BOOL(shared-js,
+[  --enable-shared-js
+                          Create a shared JavaScript library.],
+    ENABLE_SHARED_JS=1,
+    ENABLE_SHARED_JS=0)
+
+if test "$ENABLE_SHARED_JS" = "1" ; then
+  JS_SHARED_LIBRARY=1
+else
+  AC_DEFINE(MOZ_STATIC_JS)
+fi
+AC_SUBST(JS_SHARED_LIBRARY)
 
 dnl ========================================================
 dnl =
 dnl = Don't change the following two lines.  Doing so breaks:
 dnl =
 dnl = CFLAGS="-foo" ./configure
 dnl =
 dnl ========================================================
@@ -1216,17 +1228,21 @@ MOZ_JPEG_CFLAGS=
 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/jpeg)'
 MOZ_ZLIB_CFLAGS=
 MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)'
 MOZ_BZ2_CFLAGS=
 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
 MOZ_PNG_CFLAGS=
 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/modules/libimg/png)'
 
+if test -z "$JS_SHARED_LIBRARY" ; then
+MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -ljs_static'
+else
 MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs'
+fi
 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
 
 MOZ_FS_LAYOUT=unix
@@ -2263,17 +2279,21 @@ ia64*-hpux*)
     MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
     MKSHLIB_FORCE_ALL=
     MKSHLIB_UNFORCE_ALL=
     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
     MOZ_DEBUG_FLAGS='-Zi'
     MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
     MOZ_FIX_LINK_PATHS=
-    MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
+    if test -z "$JS_SHARED_LIBRARY" ; then
+       MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/js_static.lib'
+    else
+       MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
+    fi
     OBJ_SUFFIX=obj
     RANLIB='echo not_ranlib'
     STRIP='echo not_strip'
     TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
     UNZIP=unzip
     XARGS=xargs
     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
     ZIP=zip
@@ -2323,17 +2343,21 @@ ia64*-hpux*)
         DSO_LDOPTS='-shared'
         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
         RC='$(WINDRES)'
         # Use temp file for windres (bug 213281)
         RCFLAGS='-O coff --use-temp-file'
         # mingw doesn't require kernel32, user32, and advapi32 explicitly
         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32"
-        MOZ_JS_LIBS='-L$(LIBXUL_DIST)/lib -lmozjs'
+        if test -z "$JS_SHARED_LIBRARY" ; then
+           MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -ljs_static'
+        else
+           MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs'
+        fi
         MOZ_FIX_LINK_PATHS=
         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
         DLL_PREFIX=
         IMPORT_LIB_SUFFIX=dll.a
         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
     else
         TARGET_COMPILER_ABI=msvc
@@ -2369,17 +2393,21 @@ ia64*-hpux*)
         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
         CXXFLAGS="$CXXFLAGS -wd4800" # disable warning "forcing value to bool"
         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
         MOZ_DEBUG_FLAGS='-Zi'
         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
         WARNINGS_AS_ERRORS='-WX'
     	MOZ_OPTIMIZE_FLAGS='-O1'
-        MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
+        if test -z "$JS_SHARED_LIBRARY" ; then
+           MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/js_static.lib'
+        else
+           MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
+        fi
         MOZ_FIX_LINK_PATHS=
         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
         if test $_MSC_VER -ge 1400; then
             LDFLAGS="$LDFLAGS -NXCOMPAT"
             dnl For profile-guided optimization
@@ -9217,16 +9245,19 @@ fi
 # Run the SpiderMonkey 'configure' script.
 dist=$MOZ_BUILD_ROOT/dist
 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
 ac_configure_args="$ac_configure_args --enable-threadsafe"
 if test "$BUILD_CTYPES"; then
     # Build js-ctypes on the platforms we can.
     ac_configure_args="$ac_configure_args --enable-ctypes"
 fi
+if test -z "$JS_SHARED_LIBRARY" ; then
+    ac_configure_args="$ac_configure_args --disable-shared-js"
+fi
 if test -z "$MOZ_NATIVE_NSPR"; then
     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
 fi
 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
 ac_configure_args="$ac_configure_args --prefix=$dist"
 ac_configure_args="$ac_configure_args --with-sync-build-files=$_topsrcdir"
 if test "$MOZ_MEMORY"; then
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -114,18 +114,21 @@ endif
 # JavaScript must be built shared, even for static builds, as it is used by
 # other modules which are always built shared. Failure to do so results in
 # the js code getting copied into xpinstall and jsd as well as mozilla-bin,
 # and then the static data cells used for locking no longer work.
 #
 # In fact, we now build both a static and a shared library, as the
 # JS shell would like to link to the static library.
 
+ifdef JS_SHARED_LIBRARY
 FORCE_SHARED_LIB = 1
+endif
 FORCE_STATIC_LIB = 1
+DIST_INSTALL = 1
 
 VPATH		= $(srcdir)
 
 CPPSRCS		= \
 		jsapi.cpp \
 		jsarena.cpp \
 		jsarray.cpp \
 		jsatom.cpp \
--- a/js/src/config/autoconf.mk.in
+++ b/js/src/config/autoconf.mk.in
@@ -335,9 +335,11 @@ UNIVERSAL_BINARY= @UNIVERSAL_BINARY@
 HAVE_DTRACE= @HAVE_DTRACE@
 
 VISIBILITY_FLAGS = @VISIBILITY_FLAGS@
 WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCLUDES@
 
 ENABLE_TRACEJIT = @ENABLE_TRACEJIT@
 NANOJIT_ARCH = @NANOJIT_ARCH@
 HAVE_ARM_SIMD= @HAVE_ARM_SIMD@
+
+JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@
 HAVE_LINUX_PERF_EVENT_H = @HAVE_LINUX_PERF_EVENT_H@
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -386,16 +386,19 @@ DEFINES += \
 		-DEXPORT_XPTC_API \
 		-D_IMPL_NS_GFX \
 		-D_IMPL_NS_WIDGET \
 		-DIMPL_XREAPI \
 		-DIMPL_NS_NET \
 		-DIMPL_THEBES \
 		$(NULL)
 
+ifndef JS_SHARED_LIBRARY
+DEFINES += -DSTATIC_EXPORTABLE_JS_API
+endif
 ifndef MOZ_NATIVE_ZLIB
 DEFINES += -DZLIB_INTERNAL
 endif
 endif
 endif
 
 # Force _all_ exported methods to be |_declspec(dllexport)| when we're
 # building them into the executable.
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -201,16 +201,29 @@ fi
 
 COMPILE_ENVIRONMENT=1
 MOZ_ARG_ENABLE_BOOL(compile-environment,
 [  --disable-compile-environment
                           Disable compiler/library checks.],
     COMPILE_ENVIRONMENT=1,
     COMPILE_ENVIRONMENT= )
 
+MOZ_ARG_ENABLE_BOOL(shared-js,
+[  --disable-shared-js
+                          Do not create a shared library.],
+    DISABLE_SHARED_JS=0,
+    DISABLE_SHARED_JS=1)
+
+if test "$DISABLE_SHARED_JS" = "1" ; then
+  AC_DEFINE(STATIC_EXPORTABLE_JS_API)
+else
+  JS_SHARED_LIBRARY=1
+fi
+AC_SUBST(JS_SHARED_LIBRARY)
+
 dnl ========================================================
 dnl = Android uses a very custom (hacky) toolchain; we need to do this
 dnl = here, so that the compiler checks can succeed
 dnl ========================================================
 
 MOZ_ARG_WITH_STRING(android-ndk,
 [  --with-android-ndk=DIR  location where the Android NDK can be found],
     android_ndk=$withval)
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -5652,17 +5652,17 @@ JS_PUBLIC_API(void)
 JS_SetGCZeal(JSContext *cx, uint8 zeal)
 {
     cx->runtime->gcZeal = zeal;
 }
 #endif
 
 /************************************************************************/
 
-#if !defined(STATIC_JS_API) && defined(XP_WIN) && !defined (WINCE)
+#if !defined(STATIC_EXPORTABLE_JS_API) && !defined(STATIC_JS_API) && defined(XP_WIN) && !defined (WINCE)
 
 #include <windows.h>
 
 /*
  * Initialization routine for the JS DLL.
  */
 BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
 {
--- a/js/src/jstypes.h
+++ b/js/src/jstypes.h
@@ -164,17 +164,17 @@
  * interpreter should define EXPORT_JS_API whereas any client of the library
  * should not. STATIC_JS_API is used to build JS as a static library.
  */
 #if defined(STATIC_JS_API)
 
 # define JS_PUBLIC_API(t)   t
 # define JS_PUBLIC_DATA(t)  t
 
-#elif defined(EXPORT_JS_API)
+#elif defined(EXPORT_JS_API) || defined(STATIC_EXPORTABLE_JS_API)
 
 # define JS_PUBLIC_API(t)   JS_EXPORT_API(t)
 # define JS_PUBLIC_DATA(t)  JS_EXPORT_DATA(t)
 
 #else
 
 # define JS_PUBLIC_API(t)   JS_IMPORT_API(t)
 # define JS_PUBLIC_DATA(t)  JS_IMPORT_DATA(t)
--- a/js/src/xpconnect/shell/Makefile.in
+++ b/js/src/xpconnect/shell/Makefile.in
@@ -52,20 +52,24 @@ CPPSRCS		= xpcshell.cpp
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CMMSRCS += xpcshellMacUtils.mm
 endif
 
 LIBS		= \
 		$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
 		$(LIBXUL_LIBS) \
 		$(XPCOM_LIBS) \
-		$(MOZ_JS_LIBS) \
-		$(NSPR_LIBS) \
 		$(NULL)
 
+ifdef JS_SHARED_LIBRARY
+LIBS +=	$(MOZ_JS_LIBS)
+endif
+
+LIBS +=	$(NSPR_LIBS)
+
 NSDISTMODE = copy
 
 ifdef _MSC_VER
 ifdef WINCE
 WIN32_EXE_LDFLAGS += -ENTRY:mainWCRTStartup
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre/
 endif
 endif