Skip to content

Commit

Permalink
Bug 915735 - Build ICU as a shared library where JS is built as a sha…
Browse files Browse the repository at this point in the history
…red library; r=glandium
  • Loading branch information
ehsan committed Dec 6, 2013
1 parent 72782eb commit 0ba2748
Show file tree
Hide file tree
Showing 20 changed files with 361 additions and 58 deletions.
1 change: 1 addition & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/linux.m4)dnl
builtin(include, build/autoconf/python-virtualenv.m4)dnl
builtin(include, build/autoconf/winsdk.m4)dnl
builtin(include, build/autoconf/icu.m4)dnl

MOZ_PROG_CHECKMSYS()

Expand Down
5 changes: 5 additions & 0 deletions browser/installer/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ BINPATH = bin
endif
DEFINES += -DBINPATH=$(BINPATH)

DEFINES += -DMOZ_ICU_VERSION=$(MOZ_ICU_VERSION)
ifdef MOZ_SHARED_ICU
DEFINES += -DMOZ_SHARED_ICU
endif

libs::
$(MAKE) -C $(DEPTH)/browser/locales langpack

Expand Down
21 changes: 21 additions & 0 deletions browser/installer/package-manifest.in
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,27 @@
#endif
#endif
#endif
#ifdef MOZ_SHARED_ICU
#ifdef XP_WIN
#ifdef MOZ_DEBUG
@BINPATH@/icudtd@[email protected]
@BINPATH@/icuind@[email protected]
@BINPATH@/icuucd@[email protected]
#else
@BINPATH@/icudt@[email protected]
@BINPATH@/icuin@[email protected]
@BINPATH@/icuuc@[email protected]
#endif
#elif defined(XP_MACOSX)
@BINPATH@/libicudata.@[email protected]
@BINPATH@/libicui18n.@[email protected]
@BINPATH@/libicuuc.@[email protected]
#elif defined(XP_UNIX)
@BINPATH@/libicudata.so.@MOZ_ICU_VERSION@
@BINPATH@/libicui18n.so.@MOZ_ICU_VERSION@
@BINPATH@/libicuuc.so.@MOZ_ICU_VERSION@
#endif
#endif

[browser]
; [Base Browser Files]
Expand Down
31 changes: 31 additions & 0 deletions build/autoconf/icu.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.

dnl Set the MOZ_ICU_VERSION variable to denote the current version of the
dnl ICU library, and also the MOZ_SHARED_ICU which would be true if we are
dnl linking against a shared library of ICU, either one that we build from
dnl our copy of ICU or the system provided library.

AC_DEFUN([MOZ_CONFIG_ICU], [
icudir="$_topsrcdir/intl/icu/source"
if test ! -d "$icudir"; then
icudir="$_topsrcdir/../../intl/icu/source"
if test ! -d "$icudir"; then
AC_MSG_ERROR([Cannot find the ICU directory])
fi
fi
version=`sed -n 's/^[[:space:]]*#[[:space:]]*define[[:space:]][[:space:]]*U_ICU_VERSION_MAJOR_NUM[[:space:]][[:space:]]*\([0-9][0-9]*\)[[:space:]]*$/\1/p' "$icudir/common/unicode/uvernum.h"`
if test x"$version" = x; then
AC_MSG_ERROR([cannot determine icu version number from uvernum.h header file $lineno])
fi
MOZ_ICU_VERSION="$version"
if test -n "${JS_SHARED_LIBRARY}${MOZ_NATIVE_ICU}"; then
MOZ_SHARED_ICU=1
fi
AC_SUBST(MOZ_ICU_VERSION)
AC_SUBST(MOZ_SHARED_ICU)
])
3 changes: 3 additions & 0 deletions config/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ if CONFIG['HOST_OS_ARCH'] != 'WINNT':

if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
DEFINES['GKMEDIAS_SHARED_LIBRARY'] = True

if CONFIG['MOZ_SHARED_ICU']:
DEFINES['MOZ_SHARED_ICU'] = True
2 changes: 1 addition & 1 deletion config/system-headers
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ kvm.h
spawn.h
err.h
xlocale.h
#if MOZ_NATIVE_ICU==1
#ifdef MOZ_SHARED_ICU
unicode/locid.h
unicode/numsys.h
unicode/ucal.h
Expand Down
120 changes: 87 additions & 33 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -3896,6 +3896,17 @@ if test -n "$MOZ_NATIVE_FFI"; then
MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
fi

# split JS out by default to avoid VS2005 PGO crash (bug 591836).
if test "$OS_ARCH" = "WINNT"; then
JS_SHARED_LIBRARY=1
fi

MOZ_ARG_ENABLE_BOOL(shared-js,
[ --enable-shared-js
Create a shared JavaScript library.],
JS_SHARED_LIBRARY=1,
JS_SHARED_LIBRARY=)

dnl ========================================================
dnl System ICU Support
dnl ========================================================
Expand Down Expand Up @@ -7727,19 +7738,7 @@ dnl =
dnl ========================================================
MOZ_ARG_HEADER(Static build options)

# split JS out by default to avoid VS2005 PGO crash (bug 591836).
if test "$OS_ARCH" = "WINNT"; then
ENABLE_SHARED_JS=1
fi

MOZ_ARG_ENABLE_BOOL(shared-js,
[ --enable-shared-js
Create a shared JavaScript library.],
ENABLE_SHARED_JS=1,
ENABLE_SHARED_JS=)

if test -n "$ENABLE_SHARED_JS"; then
JS_SHARED_LIBRARY=1
if test -n "$JS_SHARED_LIBRARY"; then
MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
else
MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
Expand Down Expand Up @@ -8788,6 +8787,81 @@ HAVE_SYS_MOUNT_H

AC_SUBST(STLPORT_LIBS)

MOZ_ARG_WITH_STRING(intl-api,
[ --with-intl-api, --with-intl-api=build, --without-intl-api
Determine the status of the ECMAScript Internationalization API. The first
(or lack of any of these) builds and exposes the API. The second builds it
but doesn't use ICU or expose the API to script. The third doesn't build
ICU at all.],
_INTL_API=$withval,
_INTL_API=yes)

WITH_INTL="--with-intl-api=$_INTL_API"
ENABLE_INTL_API=
case "$_INTL_API" in
no)
;;
build)
ENABLE_INTL_API=1
;;
yes)
ENABLE_INTL_API=1
;;
*)
AC_MSG_ERROR([Invalid value passed to --with-intl-api: $_INTL_API])
;;
esac

if test -n "$ENABLE_INTL_API"; then
if test "$MOZ_BUILD_APP" = "browser"; then
WITH_INTL="--with-intl-api"
else
# Internationalization isn't built or exposed by default in non-desktop
# builds. Bugs to enable:
#
# Android: bug 864843
# B2G: bug 866301
WITH_INTL="--without-intl-api"
ENABLE_INTL_API=
fi
fi

dnl Settings for the implementation of the ECMAScript Internationalization API
if test -n "$ENABLE_INTL_API"; then
AC_DEFINE(ENABLE_INTL_API)

MOZ_CONFIG_ICU()

dnl Build ICU as a shared library for shared js builds.
if test -z "$MOZ_NATIVE_ICU" -a -n "$JS_SHARED_LIBRARY"; then
case "$OS_TARGET" in
WINNT)
ICU_LIB_NAMES="icuin icuuc icudt"
DBG_SUFFIX=
if test -n "$MOZ_DEBUG"; then
DBG_SUFFIX=d
fi
MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/js/src/intl/icu/target/lib/$(LIB_PREFIX)$(lib)$(DBG_SUFFIX).$(LIB_SUFFIX))'
;;
Darwin)
ICU_LIB_NAMES="icui18n icuuc icudata"
MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/js/src/intl/icu/target/lib/$(DLL_PREFIX)$(lib).$(MOZ_ICU_VERSION)$(DLL_SUFFIX))'
;;
Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
ICU_LIB_NAMES="icui18n icuuc icudata"
MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/js/src/intl/icu/target/lib/$(DLL_PREFIX)$(lib)$(DLL_SUFFIX).$(MOZ_ICU_VERSION))'
;;
*)
AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform])
esac
fi
fi

AC_SUBST(DBG_SUFFIX)
AC_SUBST(ENABLE_INTL_API)
AC_SUBST(ICU_LIB_NAMES)
AC_SUBST(MOZ_ICU_LIBS)

export WRITE_MOZINFO=1
AC_OUTPUT()
unset WRITE_MOZINFO
Expand Down Expand Up @@ -9161,26 +9235,6 @@ dist=$MOZ_BUILD_ROOT/dist
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
ac_configure_args="$ac_configure_args --enable-threadsafe"

MOZ_ARG_WITH_STRING(intl-api,
[ --with-intl-api, --with-intl-api=build, --without-intl-api
Determine the status of the ECMAScript Internationalization API. The first
(or lack of any of these) builds and exposes the API. The second builds it
but doesn't use ICU or expose the API to script. The third doesn't build
ICU at all.],
WITH_INTL="--with-intl-api=$withval"
)
if test -z "$WITH_INTL"; then
if test "$MOZ_BUILD_APP" = "browser"; then
WITH_INTL="--with-intl-api"
else
# Internationalization isn't built or exposed by default in non-desktop
# builds. Bugs to enable:
#
# Android: bug 864843
# B2G: bug 866301
WITH_INTL="--without-intl-api"
fi
fi
ac_configure_args="$ac_configure_args $WITH_INTL"

if test "$BUILD_CTYPES"; then
Expand Down
29 changes: 29 additions & 0 deletions intl/icu-patches/bug-915735
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Bug 915735 - Fix linking the ICU libraries on Mac

diff --git a/intl/icu/source/config/mh-darwin b/intl/icu/source/config/mh-darwin
index 97d6bfc..fe1490e 100644
--- a/intl/icu/source/config/mh-darwin
+++ b/intl/icu/source/config/mh-darwin
@@ -23,21 +23,17 @@ ARFLAGS += -c
COMPILE.c= $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -fno-common -c
COMPILE.cc= $(CXX) $(DEFS) $(CPPFLAGS) $(CXXFLAGS) -fno-common -c

## Commands to make a shared library
SHLIB.c= $(CC) -dynamiclib -dynamic $(CFLAGS) $(LDFLAGS) $(LD_SOOPTIONS)
SHLIB.cc= $(CXX) -dynamiclib -dynamic $(CXXFLAGS) $(LDFLAGS) $(LD_SOOPTIONS)

## Compiler switches to embed a library name and version information
-ifeq ($(ENABLE_RPATH),YES)
-LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(libdir)/$(notdir $(MIDDLE_SO_TARGET))
-else
-LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(notdir $(MIDDLE_SO_TARGET))
-endif
+LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name @executable_path/$(notdir $(MIDDLE_SO_TARGET))

## Compiler switch to embed a runtime search path
LD_RPATH=
LD_RPATH_PRE= -Wl,-rpath,

## Environment variable to set a runtime search path
LDLIBRARYPATH_ENVVAR = DYLD_LIBRARY_PATH

6 changes: 1 addition & 5 deletions intl/icu/source/config/mh-darwin
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ SHLIB.c= $(CC) -dynamiclib -dynamic $(CFLAGS) $(LDFLAGS) $(LD_SOOPTIONS)
SHLIB.cc= $(CXX) -dynamiclib -dynamic $(CXXFLAGS) $(LDFLAGS) $(LD_SOOPTIONS)

## Compiler switches to embed a library name and version information
ifeq ($(ENABLE_RPATH),YES)
LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(libdir)/$(notdir $(MIDDLE_SO_TARGET))
else
LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(notdir $(MIDDLE_SO_TARGET))
endif
LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name @executable_path/$(notdir $(MIDDLE_SO_TARGET))

## Compiler switch to embed a runtime search path
LD_RPATH=
Expand Down
63 changes: 54 additions & 9 deletions js/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,44 @@ jsconfig_FILES = $(export_files)
jsconfig_DEST = $(DIST)/include
jsconfig_TARGET := export

# Ensure that this happens before using $(MOZ_PSEUDO_DERECURSE)
include $(topsrcdir)/config/config.mk

# Ensure that this happens before including rules.mk
ifdef ENABLE_INTL_API
ifndef MOZ_NATIVE_ICU
ifeq ($(OS_ARCH),WINNT)
# Library names: On Windows, ICU uses modified library names for static
# and debug libraries.
ifdef MOZ_DEBUG
ICU_LIB_SUFFIX=d
endif
ifdef JS_SHARED_LIBRARY
ICU_FILES := $(foreach libname,$(ICU_LIB_NAMES),intl/icu/target/lib/$(libname)$(ICU_LIB_SUFFIX)$(MOZ_ICU_VERSION).dll)
else
ICU_LIB_RENAME = $(foreach libname,$(ICU_LIB_NAMES),\
cp -p intl/icu/target/lib/s$(libname)$(ICU_LIB_SUFFIX).lib intl/icu/target/lib/$(libname).lib;)
endif
else
ifeq ($(OS_ARCH),Darwin)
ifdef JS_SHARED_LIBRARY
ICU_FILES := $(foreach libname,$(ICU_LIB_NAMES),intl/icu/target/lib/$(DLL_PREFIX)$(libname).$(MOZ_ICU_VERSION)$(DLL_SUFFIX))
endif
else
ifdef JS_SHARED_LIBRARY
ICU_FILES := $(foreach libname,$(ICU_LIB_NAMES),intl/icu/target/lib/$(DLL_PREFIX)$(libname)$(DLL_SUFFIX).$(MOZ_ICU_VERSION))
endif
endif
endif
ifdef ICU_FILES
ICU_DEST := $(DIST)/bin
INSTALL_TARGETS += ICU
$(ICU_FILES): buildicu
ICU_TARGET := $(if $(MOZ_PSEUDO_DERECURSE),compile,export)
endif
endif
endif

include $(topsrcdir)/config/rules.mk

.PHONY: buildffi buildicu
Expand Down Expand Up @@ -155,14 +193,21 @@ endif
ifdef ENABLE_INTL_API
ifndef MOZ_NATIVE_ICU

ifeq ($(OS_ARCH),WINNT)
# Library names: On Windows, ICU uses modified library names for static
# and debug libraries.
ifdef MOZ_DEBUG
ICU_LIB_SUFFIX=d
endif
ICU_LIB_RENAME = $(foreach libname,$(ICU_LIB_NAMES),\
cp -p intl/icu/target/lib/s$(libname)$(ICU_LIB_SUFFIX).lib intl/icu/target/lib/$(libname).lib;)
ifdef _MSC_VER
OS_LIBS += $(call EXPAND_LIBNAME,delayimp)
ifdef MOZ_DEBUG
EXTRA_DSO_LDOPTS += \
-DELAYLOAD:icudtd$(MOZ_ICU_VERSION).dll \
-DELAYLOAD:icuind$(MOZ_ICU_VERSION).dll \
-DELAYLOAD:icuucd$(MOZ_ICU_VERSION).dll \
$(NULL)
else
EXTRA_DSO_LDOPTS += \
-DELAYLOAD:icudt$(MOZ_ICU_VERSION).dll \
-DELAYLOAD:icuin$(MOZ_ICU_VERSION).dll \
-DELAYLOAD:icuuc$(MOZ_ICU_VERSION).dll \
$(NULL)
endif
endif

ifdef .PYMAKE
Expand Down Expand Up @@ -323,7 +368,7 @@ ifneq (,$(MOZ_ZLIB_LIBS)$(MOZ_GLUE_LDFLAGS))
DEFINES += -DUSE_ZLIB
endif

ifdef MOZ_NATIVE_ICU
ifdef MOZ_SHARED_ICU
EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS)
else
SHARED_LIBRARY_LIBS += $(MOZ_ICU_LIBS)
Expand Down
1 change: 1 addition & 0 deletions js/src/aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/linux.m4)dnl
builtin(include, build/autoconf/python-virtualenv.m4)dnl
builtin(include, build/autoconf/winsdk.m4)dnl
builtin(include, build/autoconf/icu.m4)dnl

MOZ_PROG_CHECKMSYS()
Loading

0 comments on commit 0ba2748

Please sign in to comment.