diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index 231508d7e04..c8e4395e812 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -32,6 +32,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) -Wl,--no-whole-archive -Wl,--end-group ) +elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(LINKER_START_GROUP -Wl,-force_load,) endif() # common link deps diff --git a/bin/ChakraCore/ChakraCoreDllFunc.cpp b/bin/ChakraCore/ChakraCoreDllFunc.cpp index 87bfea78470..562b6a2b01d 100644 --- a/bin/ChakraCore/ChakraCoreDllFunc.cpp +++ b/bin/ChakraCore/ChakraCoreDllFunc.cpp @@ -16,6 +16,16 @@ #include "Base/VTuneChakraProfile.h" #endif +#ifdef __APPLE__ +// dummy usage of JSRT to force export JSRT on dylib +#include "ChakraCore.h" +void DummyJSRTCall() { + JsRuntimeHandle *runtime; + JsRuntimeAttributes attr; + JsCreateRuntime(attr, nullptr, runtime); +} +#endif + extern HANDLE g_hInstance; #ifdef _WIN32 static ATOM lockedDll = 0; @@ -61,7 +71,7 @@ static BOOL AttachProcess(HANDLE hmod) #endif #ifdef VTUNE_PROFILING VTuneChakraProfile::Register(); -#endif +#endif ValueType::Initialize(); ThreadContext::GlobalInitialize(); @@ -166,7 +176,7 @@ EXTERN_C BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, PVOID pvReserved) #endif #ifdef VTUNE_PROFILING VTuneChakraProfile::UnRegister(); -#endif +#endif // don't do anything if we are in forceful shutdown // try to clean up handles in graceful shutdown diff --git a/lib/Jsrt/ChakraCommon.h b/lib/Jsrt/ChakraCommon.h index a598b54614f..72706e92edc 100644 --- a/lib/Jsrt/ChakraCommon.h +++ b/lib/Jsrt/ChakraCommon.h @@ -61,10 +61,16 @@ typedef BYTE* ChakraBytePtr; #define CHAKRA_CALLBACK #endif // __i386__ +#ifndef _WIN32 +#define SET_API_VISIBILITY __attribute__((visibility("default"))) +#else +#define SET_API_VISIBILITY +#endif + #ifdef __cplusplus -#define CHAKRA_API extern "C" JsErrorCode +#define CHAKRA_API SET_API_VISIBILITY extern "C" JsErrorCode #else -#define CHAKRA_API JsErrorCode +#define CHAKRA_API SET_API_VISIBILITY extern JsErrorCode #endif #include // for size_t