diff --git a/config/config.mk b/config/config.mk index 6360fe2605c..02460d7bd7a 100644 --- a/config/config.mk +++ b/config/config.mk @@ -256,7 +256,9 @@ endif endif # WINNT && !GNU_CC -ifndef MOZ_GLUE_PROGRAM_LDFLAGS +ifdef MOZ_GLUE_PROGRAM_LDFLAGS +DEFINES += -DMOZ_GLUE_IN_PROGRAM +else MOZ_GLUE_PROGRAM_LDFLAGS=$(MOZ_GLUE_LDFLAGS) endif @@ -810,3 +812,21 @@ OBJ_SUFFIX := i_o endif endif endif + +# EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo) +# expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker +# arguments syntax. Should only be used for system libraries + +# EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir) +# expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX) + +# EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo) +# expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX) + +ifdef GNU_CC +EXPAND_LIBNAME = $(addprefix -l,$(1)) +else +EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) +endif +EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) +EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) diff --git a/config/rules.mk b/config/rules.mk index f06a7ba789b..991052d1fe9 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -92,24 +92,6 @@ ifdef LIBXUL_SDK VPATH += $(LIBXUL_SDK)/lib endif -# EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo) -# expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker -# arguments syntax. Should only be used for system libraries - -# EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir) -# expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX) - -# EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo) -# expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX) - -ifdef GNU_CC -EXPAND_LIBNAME = $(addprefix -l,$(1)) -else -EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) -endif -EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) -EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) - ifdef EXTRA_DSO_LIBS EXTRA_DSO_LIBS := $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS)) endif diff --git a/configure.in b/configure.in index 51069133670..d983a02ff42 100644 --- a/configure.in +++ b/configure.in @@ -9127,12 +9127,12 @@ ac_configure_args="$ac_configure_args --prefix=$dist" ac_configure_args="$ac_configure_args --with-sync-build-files=$_topsrcdir" if test "$MOZ_MEMORY"; then ac_configure_args="$ac_configure_args --enable-jemalloc" - if test -n "$MOZ_GLUE_LDFLAGS"; then - export MOZ_GLUE_LDFLAGS - fi - if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then - export MOZ_GLUE_PROGRAM_LDFLAGS - fi +fi +if test -n "$MOZ_GLUE_LDFLAGS"; then + export MOZ_GLUE_LDFLAGS +fi +if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then + export MOZ_GLUE_PROGRAM_LDFLAGS fi export MOZ_APP_NAME AC_OUTPUT_SUBDIRS(js/src) diff --git a/js/src/Makefile.in b/js/src/Makefile.in index 28ffcb92db6..1abd09f1621 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -367,8 +367,7 @@ VPATH += $(srcdir)/assembler \ $(srcdir)/yarr \ $(NONE) -CPPSRCS += Assertions.cpp \ - ExecutableAllocator.cpp \ +CPPSRCS += ExecutableAllocator.cpp \ ARMAssembler.cpp \ MacroAssemblerARM.cpp \ MacroAssemblerX86Common.cpp \ @@ -490,6 +489,13 @@ endif include $(topsrcdir)/config/config.mk +ifeq (,$(MOZ_GLUE_PROGRAM_LDFLAGS)) +# When building standalone, we need to include mfbt sources, and to declare +# "exported" mfbt symbols on its behalf when we use its headers. +include $(srcdir)/../../mfbt/sources.mk +DEFINES += -DIMPL_MFBT +endif + EXTRA_DSO_LDOPTS += $(NSPR_LIBS) ifndef BUILD_OPT @@ -669,11 +675,6 @@ distclean:: DEFINES += -DEXPORT_JS_API -# mfbt is always packed with us, so if we're building a shared object, -# we need to declare "exported" mfbt symbols on its behalf when we use -# its headers. -DEFINES += -DIMPL_MFBT - INCLUDES += -I$(srcdir) ifdef JS_THREADSAFE diff --git a/js/src/assembler/assembler/MacroAssemblerX86Common.h b/js/src/assembler/assembler/MacroAssemblerX86Common.h index 373d3cad102..d3e84cc5782 100644 --- a/js/src/assembler/assembler/MacroAssemblerX86Common.h +++ b/js/src/assembler/assembler/MacroAssemblerX86Common.h @@ -91,9 +91,11 @@ public: DoubleLessThanOrUnordered = X86Assembler::ConditionB, DoubleLessThanOrEqualOrUnordered = X86Assembler::ConditionBE }; - COMPILE_ASSERT( - !((X86Assembler::ConditionE | X86Assembler::ConditionNE | X86Assembler::ConditionA | X86Assembler::ConditionAE | X86Assembler::ConditionB | X86Assembler::ConditionBE) & DoubleConditionBits), - DoubleConditionBits_should_not_interfere_with_X86Assembler_Condition_codes); + static void staticAsserts() { + COMPILE_ASSERT( + !((X86Assembler::ConditionE | X86Assembler::ConditionNE | X86Assembler::ConditionA | X86Assembler::ConditionAE | X86Assembler::ConditionB | X86Assembler::ConditionBE) & DoubleConditionBits), + DoubleConditionBits_should_not_interfere_with_X86Assembler_Condition_codes); + } static const RegisterID stackPointerRegister = X86Registers::esp; diff --git a/js/src/assembler/wtf/Assertions.h b/js/src/assembler/wtf/Assertions.h index 6c9da1e2e8f..537737a5b82 100644 --- a/js/src/assembler/wtf/Assertions.h +++ b/js/src/assembler/wtf/Assertions.h @@ -26,6 +26,18 @@ #ifndef WTF_Assertions_h #define WTF_Assertions_h +#include "Platform.h" +#include "mozilla/Assertions.h" + +#define ASSERT(assertion) MOZ_ASSERT(assertion) +#define ASSERT_UNUSED(variable, assertion) ASSERT(assertion) +#define ASSERT_NOT_REACHED() MOZ_NOT_REACHED("") +#define CRASH() MOZ_Crash() +#define COMPILE_ASSERT(exp, name) MOZ_STATIC_ASSERT(exp, #name) + +#endif + +#if 0 /* no namespaces because this file has to be includable from C and Objective-C diff --git a/js/src/config/config.mk b/js/src/config/config.mk index 6360fe2605c..02460d7bd7a 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -256,7 +256,9 @@ endif endif # WINNT && !GNU_CC -ifndef MOZ_GLUE_PROGRAM_LDFLAGS +ifdef MOZ_GLUE_PROGRAM_LDFLAGS +DEFINES += -DMOZ_GLUE_IN_PROGRAM +else MOZ_GLUE_PROGRAM_LDFLAGS=$(MOZ_GLUE_LDFLAGS) endif @@ -810,3 +812,21 @@ OBJ_SUFFIX := i_o endif endif endif + +# EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo) +# expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker +# arguments syntax. Should only be used for system libraries + +# EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir) +# expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX) + +# EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo) +# expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX) + +ifdef GNU_CC +EXPAND_LIBNAME = $(addprefix -l,$(1)) +else +EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) +endif +EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) +EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index f06a7ba789b..991052d1fe9 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -92,24 +92,6 @@ ifdef LIBXUL_SDK VPATH += $(LIBXUL_SDK)/lib endif -# EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo) -# expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker -# arguments syntax. Should only be used for system libraries - -# EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir) -# expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX) - -# EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo) -# expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX) - -ifdef GNU_CC -EXPAND_LIBNAME = $(addprefix -l,$(1)) -else -EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) -endif -EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) -EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) - ifdef EXTRA_DSO_LIBS EXTRA_DSO_LIBS := $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS)) endif diff --git a/js/src/jsapi-tests/Makefile.in b/js/src/jsapi-tests/Makefile.in index 525e0cea540..b871ff7a9a2 100644 --- a/js/src/jsapi-tests/Makefile.in +++ b/js/src/jsapi-tests/Makefile.in @@ -105,6 +105,9 @@ CSRCS = \ # $(NULL) DEFINES += -DEXPORT_JS_API +# Building against js_static requires that we declare mfbt sybols "exported" +# on its behalf. +DEFINES += -DIMPL_MFBT LIBS = $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) $(NSPR_LIBS) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 4a019656b41..be49e1784d1 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -6601,7 +6601,7 @@ JS_AbortIfWrongThread(JSRuntime *rt) { #ifdef JS_THREADSAFE if (!rt->onOwnerThread()) - JS_Assert("rt->onOwnerThread()", __FILE__, __LINE__); + MOZ_Assert("rt->onOwnerThread()", __FILE__, __LINE__); #endif } diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 4663d11d1dd..ee62f0b05bb 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -70,6 +70,8 @@ /************************************************************************/ +#define JS_Assert MOZ_Assert + #ifdef __cplusplus namespace JS { diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index 707a6bfcb68..6b7c1fb075b 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -349,7 +349,7 @@ types::TypeFailure(JSContext *cx, const char *fmt, ...) cx->compartment->types.print(cx, true); /* Always active, even in release builds */ - JS_Assert(msgbuf, __FILE__, __LINE__); + MOZ_Assert(msgbuf, __FILE__, __LINE__); *((volatile int *)NULL) = 0; /* Should never be reached */ } diff --git a/js/src/jsutil.cpp b/js/src/jsutil.cpp index 42578441dfb..5968e70e71c 100644 --- a/js/src/jsutil.cpp +++ b/js/src/jsutil.cpp @@ -69,35 +69,6 @@ JS_PUBLIC_DATA(uint32_t) OOM_counter = 0; */ JS_STATIC_ASSERT(sizeof(void *) == sizeof(void (*)())); -static JS_NEVER_INLINE void -CrashInJS() -{ - /* - * We write 123 here so that the machine code for this function is - * unique. Otherwise the linker, trying to be smart, might use the - * same code for CrashInJS and for some other function. That - * messes up the signature in minidumps. - */ - -#if defined(WIN32) - /* - * We used to call DebugBreak() on Windows, but amazingly, it causes - * the MSVS 2010 debugger not to be able to recover a call stack. - */ - *((volatile int *) NULL) = 123; - exit(3); -#elif defined(__APPLE__) - /* - * On Mac OS X, Breakpad ignores signals. Only real Mach exceptions are - * trapped. - */ - *((volatile int *) NULL) = 123; /* To continue from here in GDB: "return" then "continue". */ - raise(SIGABRT); /* In case above statement gets nixed by the optimizer. */ -#else - raise(SIGABRT); /* To continue from here in GDB: "signal 0". */ -#endif -} - /* * |JS_Assert| historically took |JSIntn ln| as its last argument. We've * boiled |JSIntn ln| down to simply |int ln| so that mfbt may declare the @@ -106,14 +77,6 @@ CrashInJS() */ JS_STATIC_ASSERT((tl::IsSameType::result)); -JS_PUBLIC_API(void) -JS_Assert(const char *s, const char *file, int ln) -{ - fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln); - fflush(stderr); - CrashInJS(); -} - #ifdef JS_BASIC_STATS #include diff --git a/js/src/jsutil.h b/js/src/jsutil.h index a602dc01885..c20fbf14333 100644 --- a/js/src/jsutil.h +++ b/js/src/jsutil.h @@ -331,9 +331,9 @@ inline __attribute__ ((unused)) void MUST_FLOW_THROUGH(const char *label) {} #ifdef JS_CRASH_DIAGNOSTICS # define JS_POISON(p, val, size) memset((p), (val), (size)) # define JS_OPT_ASSERT(expr) \ - ((expr) ? (void)0 : JS_Assert(#expr, __FILE__, __LINE__)) + ((expr) ? (void)0 : MOZ_Assert(#expr, __FILE__, __LINE__)) # define JS_OPT_ASSERT_IF(cond, expr) \ - ((!(cond) || (expr)) ? (void)0 : JS_Assert(#expr, __FILE__, __LINE__)) + ((!(cond) || (expr)) ? (void)0 : MOZ_Assert(#expr, __FILE__, __LINE__)) #else # define JS_POISON(p, val, size) ((void) 0) # define JS_OPT_ASSERT(expr) ((void) 0) diff --git a/js/src/shell/Makefile.in b/js/src/shell/Makefile.in index 4df10ed2ff9..cf27c4dc2af 100644 --- a/js/src/shell/Makefile.in +++ b/js/src/shell/Makefile.in @@ -53,6 +53,9 @@ CPPSRCS = \ $(NULL) DEFINES += -DEXPORT_JS_API +# Building against js_static requires that we declare mfbt sybols "exported" +# on its behalf. +DEFINES += -DIMPL_MFBT LIBS = $(NSPR_LIBS) $(EDITLINE_LIBS) $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) ifdef MOZ_NATIVE_FFI diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index 82d1b8eb730..b410abf9d31 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -1052,7 +1052,7 @@ CrashIfInvalidSlot(StackFrame *fp, Value *vp) if (vp < fp->slots() || vp >= fp->slots() + fp->script()->nslots) { JS_ASSERT(false && "About to dereference invalid slot"); *(int *)0xbad = 0; // show up nicely in crash-stats - JS_Assert("About to dereference invalid slot", __FILE__, __LINE__); + MOZ_Assert("About to dereference invalid slot", __FILE__, __LINE__); } } diff --git a/mfbt/Assertions.cpp b/mfbt/Assertions.cpp new file mode 100644 index 00000000000..5259eb7217d --- /dev/null +++ b/mfbt/Assertions.cpp @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99 ft=cpp: + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Code. + * + * The Initial Developer of the Original Code is + * The Mozilla Foundation + * Portions created by the Initial Developer are Copyright (C) 2012 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Mike Hommey + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "mozilla/Attributes.h" +#include "mozilla/Types.h" + +#include +#include +#ifndef WIN32 +#include +#endif + +/* Implementations of runtime and static assertion macros for C and C++. */ + +extern "C" { + +MOZ_EXPORT_API(void) +MOZ_Crash() +{ + /* + * We write 123 here so that the machine code for this function is + * unique. Otherwise the linker, trying to be smart, might use the + * same code for MOZ_Crash and for some other function. That + * messes up the signature in minidumps. + */ + +#if defined(WIN32) + /* + * We used to call DebugBreak() on Windows, but amazingly, it causes + * the MSVS 2010 debugger not to be able to recover a call stack. + */ + *((volatile int *) NULL) = 123; + exit(3); +#elif defined(__APPLE__) + /* + * On Mac OS X, Breakpad ignores signals. Only real Mach exceptions are + * trapped. + */ + *((volatile int *) NULL) = 123; /* To continue from here in GDB: "return" then "continue". */ + raise(SIGABRT); /* In case above statement gets nixed by the optimizer. */ +#else + raise(SIGABRT); /* To continue from here in GDB: "signal 0". */ +#endif +} + +MOZ_EXPORT_API(void) +MOZ_Assert(const char* s, const char* file, int ln) +{ + fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln); + fflush(stderr); + MOZ_Crash(); +} + +} diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h index 43cd4e9d34a..097914fc821 100644 --- a/mfbt/Assertions.h +++ b/mfbt/Assertions.h @@ -126,26 +126,15 @@ #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) -/* - * XXX: we're cheating here in order to avoid creating object files - * for mfbt /just/ to provide a function like FatalError() to be used - * by MOZ_ASSERT(). (It'll happen eventually, but for just ASSERT() - * it isn't worth the pain.) JS_Assert(), although unfortunately - * named, is part of SpiderMonkey's stable, external API, so this - * isn't quite as bad as it seems. - * - * Once mfbt needs object files, this unholy union with JS_Assert() - * will be broken. - * - * JS_Assert is present even in release builds, for the benefit of applications - * that build DEBUG and link against a non-DEBUG SpiderMonkey library. - */ #ifdef __cplusplus extern "C" { #endif extern MFBT_API(void) -JS_Assert(const char* s, const char* file, int ln); +MOZ_Crash(void); + +extern MFBT_API(void) +MOZ_Assert(const char* s, const char* file, int ln); #ifdef __cplusplus } /* extern "C" */ @@ -186,10 +175,10 @@ JS_Assert(const char* s, const char* file, int ln); #ifdef DEBUG /* First the single-argument form. */ # define MOZ_ASSERT_HELPER1(expr) \ - ((expr) ? ((void)0) : JS_Assert(#expr, __FILE__, __LINE__)) + ((expr) ? ((void)0) : MOZ_Assert(#expr, __FILE__, __LINE__)) /* Now the two-argument form. */ # define MOZ_ASSERT_HELPER2(expr, explain) \ - ((expr) ? ((void)0) : JS_Assert(#expr " (" explain ")", __FILE__, __LINE__)) + ((expr) ? ((void)0) : MOZ_Assert(#expr " (" explain ")", __FILE__, __LINE__)) /* And now, helper macrology up the wazoo. */ /* Count the number of arguments passed to MOZ_ASSERT. */ # define MOZ_COUNT_ASSERT_ARGS(...) \ @@ -239,7 +228,7 @@ JS_Assert(const char* s, const char* file, int ln); * } */ #ifdef DEBUG -# define MOZ_NOT_REACHED(reason) JS_Assert(reason, __FILE__, __LINE__) +# define MOZ_NOT_REACHED(reason) MOZ_Assert(reason, __FILE__, __LINE__) #else # define MOZ_NOT_REACHED(reason) ((void)0) #endif diff --git a/mfbt/GuardObjects.h b/mfbt/GuardObjects.h index 7a134d65591..2e50405b062 100644 --- a/mfbt/GuardObjects.h +++ b/mfbt/GuardObjects.h @@ -100,7 +100,7 @@ namespace detail { * For more details, and examples of using these macros, see * https://developer.mozilla.org/en/Using_RAII_classes_in_Mozilla */ -class MFBT_API(GuardObjectNotifier) +class MOZ_EXPORT_API(GuardObjectNotifier) { private: bool* statementDone; @@ -117,7 +117,7 @@ class MFBT_API(GuardObjectNotifier) } }; -class MFBT_API(GuardObjectNotificationReceiver) +class MOZ_EXPORT_API(GuardObjectNotificationReceiver) { private: bool statementDone; diff --git a/mfbt/Makefile.in b/mfbt/Makefile.in index 9a0b26cf79a..4755f42632d 100644 --- a/mfbt/Makefile.in +++ b/mfbt/Makefile.in @@ -42,6 +42,11 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk +MODULE = mozglue +LIBRARY_NAME = mfbt +FORCE_STATIC_LIB = 1 +STL_FLAGS = + DIRS = # exported_headers.mk defines the headers exported by mfbt. It is included by @@ -49,4 +54,11 @@ DIRS = # work to install mfbt's exported headers itself. include $(srcdir)/exported_headers.mk +# sources.mk defines the source files built for mfbt. It is included by mfbt +# itself and by the JS engine, which, when built standalone, must do the work +# to build mfbt sources itself. +include $(srcdir)/sources.mk + +DEFINES += -DIMPL_MFBT + include $(topsrcdir)/config/rules.mk diff --git a/mfbt/Types.h b/mfbt/Types.h index 17de4d9841e..7a122890662 100644 --- a/mfbt/Types.h +++ b/mfbt/Types.h @@ -129,8 +129,17 @@ # define MFBT_API(type) MOZ_EXPORT_API(type) # define MFBT_DATA(type) MOZ_EXPORT_DATA(type) #else -# define MFBT_API(type) MOZ_IMPORT_API(type) -# define MFBT_DATA(type) MOZ_IMPORT_DATA(type) + /* + * When mozglue is linked in the program, we need the MFBT API symbols + * to be weak. + */ +# if defined(MOZ_GLUE_IN_PROGRAM) +# define MFBT_API(type) __attribute__((weak)) MOZ_IMPORT_API(type) +# define MFBT_DATA(type) __attribute__((weak)) MOZ_IMPORT_DATA(type) +# else +# define MFBT_API(type) MOZ_IMPORT_API(type) +# define MFBT_DATA(type) MOZ_IMPORT_DATA(type) +# endif #endif /* diff --git a/mfbt/sources.mk b/mfbt/sources.mk new file mode 100644 index 00000000000..747a8b3861d --- /dev/null +++ b/mfbt/sources.mk @@ -0,0 +1,3 @@ +CPPSRCS += \ + Assertions.cpp \ + $(NULL) diff --git a/mozglue/build/Makefile.in b/mozglue/build/Makefile.in index 07702ff470b..986a6c5e452 100644 --- a/mozglue/build/Makefile.in +++ b/mozglue/build/Makefile.in @@ -93,6 +93,8 @@ ifdef MOZ_LINKER SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,linker,../linker) endif +SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,mfbt,$(DEPTH)/mfbt) + ifeq (Android, $(OS_TARGET)) WRAP_LDFLAGS = endif