From 76de6a283a37ed2d23cfa2dc056b07bedc5b5cbb Mon Sep 17 00:00:00 2001 From: Taras Glek Date: Fri, 13 Aug 2010 21:18:05 -0700 Subject: [PATCH] Bug 580407 - Link js statically r=bsmedberg+khuey a=bsmedberg --- browser/installer/package-manifest.in | 2 ++ config/autoconf.mk.in | 2 ++ config/config.mk | 3 +++ configure.in | 37 ++++++++++++++++++++++++--- js/src/Makefile.in | 3 +++ js/src/config/autoconf.mk.in | 2 ++ js/src/config/config.mk | 3 +++ js/src/configure.in | 13 ++++++++++ js/src/jsapi.cpp | 2 +- js/src/jstypes.h | 2 +- js/src/xpconnect/shell/Makefile.in | 8 ++++-- 11 files changed, 70 insertions(+), 7 deletions(-) diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index c0a5c60cbab0..a355aea99233 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -38,7 +38,9 @@ [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@ diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index bc96ded7eaab..5d6ce2c5ae08 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -678,3 +678,5 @@ ANDROID_PLATFORM = @ANDROID_PLATFORM@ ANDROID_SDK = @ANDROID_SDK@ ANDROID_TOOLS = @ANDROID_TOOLS@ ANDROID_VERSION = @ANDROID_VERSION@ + +JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@ diff --git a/config/config.mk b/config/config.mk index 33f15cd4589b..ee0bd17ae0f7 100644 --- a/config/config.mk +++ b/config/config.mk @@ -391,6 +391,9 @@ DEFINES += \ -DIMPL_THEBES \ $(NULL) +ifndef JS_SHARED_LIBRARY +DEFINES += -DSTATIC_EXPORTABLE_JS_API +endif ifndef MOZ_NATIVE_ZLIB DEFINES += -DZLIB_INTERNAL endif diff --git a/configure.in b/configure.in index 6c9b151252b3..d6d2fc160d3f 100644 --- a/configure.in +++ b/configure.in @@ -74,6 +74,18 @@ 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 = @@ -1221,7 +1233,11 @@ 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' @@ -2268,7 +2284,11 @@ ia64*-hpux*) 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' @@ -2328,7 +2348,11 @@ ia64*-hpux*) 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' @@ -2374,7 +2398,11 @@ ia64*-hpux*) 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' @@ -9222,6 +9250,9 @@ 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'" diff --git a/js/src/Makefile.in b/js/src/Makefile.in index c1eb41ad15bb..8f57d58fd351 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -119,8 +119,11 @@ endif # 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) diff --git a/js/src/config/autoconf.mk.in b/js/src/config/autoconf.mk.in index 84ecc9f7609b..dcc4abb26196 100644 --- a/js/src/config/autoconf.mk.in +++ b/js/src/config/autoconf.mk.in @@ -340,4 +340,6 @@ 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@ diff --git a/js/src/config/config.mk b/js/src/config/config.mk index 33f15cd4589b..ee0bd17ae0f7 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -391,6 +391,9 @@ DEFINES += \ -DIMPL_THEBES \ $(NULL) +ifndef JS_SHARED_LIBRARY +DEFINES += -DSTATIC_EXPORTABLE_JS_API +endif ifndef MOZ_NATIVE_ZLIB DEFINES += -DZLIB_INTERNAL endif diff --git a/js/src/configure.in b/js/src/configure.in index 169ac8414587..a779d0b542bf 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -206,6 +206,19 @@ MOZ_ARG_ENABLE_BOOL(compile-environment, 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 diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index b5c76978f5c5..952edd20757b 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -5657,7 +5657,7 @@ JS_SetGCZeal(JSContext *cx, uint8 zeal) /************************************************************************/ -#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 diff --git a/js/src/jstypes.h b/js/src/jstypes.h index 14c3b03051fb..f0f845ad6608 100644 --- a/js/src/jstypes.h +++ b/js/src/jstypes.h @@ -169,7 +169,7 @@ # 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) diff --git a/js/src/xpconnect/shell/Makefile.in b/js/src/xpconnect/shell/Makefile.in index aa98c7c07eb2..bcceb01759b4 100644 --- a/js/src/xpconnect/shell/Makefile.in +++ b/js/src/xpconnect/shell/Makefile.in @@ -57,10 +57,14 @@ 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