Bug 683127 part 2 - Build system glue for the new linker. r=khuey
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 11 Jan 2012 11:10:59 +0100
changeset 86699 85c7cdc1a91601eaf43562b736bd65b768d64d14
parent 86698 12f6fad6692480cf9273698fb4029672834d250c
child 86700 ea78ef72f47fe254cd6beea23425417af9d83490
push id674
push userffxbld
push dateTue, 13 Mar 2012 21:17:50 +0000
treeherdermozilla-beta@e3c4c92dec31 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs683127
milestone12.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 683127 part 2 - Build system glue for the new linker. r=khuey
allmakefiles.sh
config/autoconf.mk.in
configure.in
mozglue/Makefile.in
mozglue/android/Makefile.in
mozglue/build/Makefile.in
other-licenses/android/Makefile.in
--- a/allmakefiles.sh
+++ b/allmakefiles.sh
@@ -85,16 +85,21 @@ if [ ! "$LIBXUL_SDK" ]; then
   fi
   if [ "$MOZ_WIDGET_TOOLKIT" = "android" ]; then
     add_makefiles "
       other-licenses/android/Makefile
       other-licenses/skia-npapi/Makefile
       mozglue/android/Makefile
     "
   fi
+  if [ "$MOZ_LINKER" ]; then
+    add_makefiles "
+      mozglue/linker/Makefile
+    "
+  fi
 fi
 
 if [ "$OS_ARCH" = "WINNT" ]; then
   add_makefiles "
     build/win32/Makefile
     build/win32/crashinjectdll/Makefile
   "
 fi
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -116,16 +116,18 @@ MOZ_ENABLE_PROFILER_SPS = @MOZ_ENABLE_PR
 MOZ_JPROF       = @MOZ_JPROF@
 MOZ_SHARK       = @MOZ_SHARK@
 MOZ_CALLGRIND   = @MOZ_CALLGRIND@
 MOZ_VTUNE       = @MOZ_VTUNE@
 MOZ_ETW         = @MOZ_ETW@
 MOZ_TRACE_JSCALLS = @MOZ_TRACE_JSCALLS@
 DEHYDRA_PATH    = @DEHYDRA_PATH@
 
+MOZ_LINKER = @MOZ_LINKER@
+MOZ_OLD_LINKER = @MOZ_OLD_LINKER@
 NS_TRACE_MALLOC = @NS_TRACE_MALLOC@
 USE_ELF_DYNSTR_GC = @USE_ELF_DYNSTR_GC@
 USE_ELF_HACK = @USE_ELF_HACK@
 STDCXX_COMPAT = @STDCXX_COMPAT@
 MOZ_LIBSTDCXX_TARGET_VERSION=@MOZ_LIBSTDCXX_TARGET_VERSION@
 MOZ_LIBSTDCXX_HOST_VERSION=@MOZ_LIBSTDCXX_HOST_VERSION@
 INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
 MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
--- a/configure.in
+++ b/configure.in
@@ -2460,16 +2460,17 @@ ia64*-hpux*)
 
 *-android*|*-linuxandroid*)
     AC_DEFINE(NO_PW_GECOS)
     no_x=yes
     if test -n "$gonkdir"; then
         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
     else
         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
+        MOZ_LINKER=1
     fi
     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
 
     MOZ_GFX_OPTIMIZE_MOBILE=1
     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
     ;;
 
 *-*linux*)
@@ -2894,16 +2895,18 @@ ia64*-hpux*)
     ;;
 
 *-os2*)
     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
     ;;
 
 esac
 
+AC_SUBST(MOZ_LINKER)
+
 dnl Only one oddball right now (QNX), but this gives us flexibility
 dnl if any other platforms need to override this in the future.
 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
 
 dnl ========================================================
 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
 dnl by now will not have any way to link most binaries (tests
 dnl as well as viewer, apprunner, etc.), because some symbols
@@ -4054,17 +4057,18 @@ fi
 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
 AC_CACHE_CHECK(for __thread keyword for TLS variables,
                ac_cv_thread_keyword,
                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
                             [return tlsIsMainThread;],
                             ac_cv_thread_keyword=yes,
                             ac_cv_thread_keyword=no)])
 LDFLAGS=$_SAVE_LDFLAGS
-if test "$ac_cv_thread_keyword" = yes; then
+# The custom dynamic linker doesn't support TLS variables
+if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
   # mips builds fail with TLS variables because of a binutils bug.
   # See bug 528687
   case "${target}" in
     mips*-*)
       :
       ;;
     *-android*|*-linuxandroid*)
       :
@@ -4427,16 +4431,20 @@ CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
 if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$SYSTEM_ZLIB" = 1; then
     ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
     ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
 fi
 
+if test "$MOZ_LINKER" = 1 -a "$SYSTEM_ZLIB" != 1; then
+    AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
+fi
+
 dnl system BZIP2 Support
 dnl ========================================================
 MOZ_ARG_WITH_STRING(system-bz2,
 [  --with-system-bz2[=PFX]
                           Use system libbz2 [installed at prefix PFX]],
     BZ2_DIR=$withval)
 
 _SAVE_CFLAGS=$CFLAGS
@@ -4889,30 +4897,32 @@ cairo-uikit)
 cairo-android)
     AC_DEFINE(MOZ_WIDGET_ANDROID)
     MOZ_WIDGET_TOOLKIT=android
     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
     TK_LIBS='$(MOZ_CAIRO_LIBS)'
     MOZ_WEBGL=1
     MOZ_PDF_PRINTING=1
     MOZ_INSTRUMENT_EVENT_LOOP=1
+    MOZ_OLD_LINKER=1
     ;;
 
 cairo-gonk)
     AC_DEFINE(MOZ_WIDGET_GONK)
     MOZ_WIDGET_TOOLKIT=gonk
     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
     TK_LIBS='$(MOZ_CAIRO_LIBS)'
     MOZ_WEBGL=1
     MOZ_PDF_PRINTING=1
     MOZ_B2G_RIL=1
     ;;
 
 esac
 
+AC_SUBST(MOZ_OLD_LINKER)
 AC_SUBST(MOZ_PDF_PRINTING)
 if test "$MOZ_PDF_PRINTING"; then
    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
    AC_DEFINE(MOZ_PDF_PRINTING)
 fi
 
 if test "$MOZ_ENABLE_XREMOTE"; then
     AC_DEFINE(MOZ_ENABLE_XREMOTE)
@@ -7231,17 +7241,20 @@ AC_SUBST(WIN32_CRT_LIBS)
 dnl Need to set this for make because NSS doesn't have configure
 AC_SUBST(DLLFLAGS)
 
 dnl We need to wrap dlopen and related functions on Android because we use
 dnl our own linker.
 if test "$OS_TARGET" = Android; then
     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
     if test "$MOZ_WIDGET_TOOLKIT" = android; then
-        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
+        if test -n "$MOZ_OLD_LINKER"; then
+            WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
+        fi
+        WRAP_LDFLAGS="${WRAP_LDFLAGS} --wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
     fi
 fi
 
 dnl ========================================================
 dnl = Use malloc wrapper lib
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
--- a/mozglue/Makefile.in
+++ b/mozglue/Makefile.in
@@ -38,15 +38,20 @@
 DEPTH		= ..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 DIRS =
+
+ifdef MOZ_LINKER
+DIRS += linker
+endif
+
 ifeq (android,$(MOZ_WIDGET_TOOLKIT))
 DIRS += android
 endif
 
 DIRS += build
 
 include $(topsrcdir)/config/rules.mk
--- a/mozglue/android/Makefile.in
+++ b/mozglue/android/Makefile.in
@@ -51,16 +51,18 @@ DEFINES += \
   $(NULL)
 
 CPPSRCS = \
   nsGeckoUtils.cpp \
   APKOpen.cpp \
   $(NULL)
 
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/components/startup
+ifdef MOZ_OLD_LINKER
 LOCAL_INCLUDES += -I$(topsrcdir)/other-licenses/android
 ifeq ($(CPU_ARCH),arm)
 DEFINES += -DANDROID_ARM_LINKER
 endif
+endif
 
 EXPORTS = APKOpen.h
 
 include $(topsrcdir)/config/rules.mk
--- a/mozglue/build/Makefile.in
+++ b/mozglue/build/Makefile.in
@@ -76,22 +76,27 @@ LDFLAGS += -ENTRY:DllMain
 
 ifneq (,$(filter -DEFAULTLIB:mozcrt,$(MOZ_GLUE_LDFLAGS)))
 # Don't install the import library if we use mozcrt
 NO_INSTALL_IMPORT_LIBRARY = 1
 endif
 endif
 
 ifeq (android, $(MOZ_WIDGET_TOOLKIT))
-# Add Android linker
+# Add Android specific code
 EXTRA_DSO_LDOPTS += $(ZLIB_LIBS)
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,$(DEPTH)/other-licenses/android)
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,../android)
 endif
 
+ifdef MOZ_LINKER
+# Add custom dynamic linker
+SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,linker,../linker)
+endif
+
 ifeq (Android, $(OS_TARGET))
 WRAP_LDFLAGS =
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_MEMORY
 ifeq (Darwin,$(OS_TARGET))
--- a/other-licenses/android/Makefile.in
+++ b/other-licenses/android/Makefile.in
@@ -41,49 +41,56 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE           = android
 LIBRARY_NAME     = android
 FORCE_STATIC_LIB = 1
 
+CSRCS =
+
+ifdef MOZ_OLD_LINKER
 DEFINES += \
   -DLINKER_DEBUG=0 \
   -DMOZ_LINKER \
   -DLINKER_TEXT_BASE=0xB0001000 \
   -DLINKER_AREA_SIZE=0x01000000 \
   $(NULL)
 
 ifeq ($(CPU_ARCH),arm)
 DEFINES += -DANDROID_ARM_LINKER
 else
 ifeq ($(CPU_ARCH),x86)
 DEFINES += -DANDROID_X86_LINKER
 endif
 endif
 
-CSRCS = \
+CSRCS += \
   ba.c \
   debugger.c \
   dlfcn.c \
+  linker.c \
+  linker_format.c \
+  rt.c \
+  $(NULL)
+endif
+
+CSRCS += \
   ev_streams.c \
   ev_timers.c \
   getaddrinfo.c \
-  linker.c \
-  linker_format.c \
   ns_name.c \
   ns_netint.c \
   ns_parse.c \
   ns_print.c \
   ns_samedomain.c \
   ns_ttl.c \
   res_comp.c \
   res_data.c \
   res_debug.c \
   res_init.c \
   res_mkquery.c \
   res_send.c \
   res_state.c \
-  rt.c \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk