diff --git a/CMakeLists.txt b/CMakeLists.txt index 78af990a74a..7002c6ebf12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,9 +167,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang add_definitions("-fdiagnostics-color=always") endif() -if(STATIC_LIBRARY) - add_definitions(-DCHAKRA_STATIC_LIBRARY=1) -endif() if(CLR_CMAKE_PLATFORM_XPLAT) add_definitions(-DFEATURE_PAL) diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 4c9da70b055..d5c2ee294bd 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -1,5 +1,4 @@ +add_subdirectory (ChakraCore) add_subdirectory (GCStress) add_subdirectory (ch) -if(NOT STATIC_LIBRARY) - add_subdirectory (ChakraCore) -endif() + diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index bf3babe80c6..679b6c48559 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -1,4 +1,5 @@ add_library (ChakraCore SHARED + ChakraCoreCommon.cpp ChakraCoreDllFunc.cpp ConfigParserExternals.cpp TestHooks.cpp @@ -13,6 +14,87 @@ target_include_directories ( ${CHAKRACORE_SOURCE_DIR}/lib/Jsrt ) + +if(BuildJIT) + set(chakra_backend_objects $) +endif() + +add_library (ChakraCoreStatic STATIC + ChakraCoreCommon.cpp + ConfigParserExternals.cpp + TestHooks.cpp +# Do not take this in. We need to control the +# linker order because of global constructors +# and cross dependencies among them + $ + $ + $ + ${chakra_backend_objects} + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + ) +unset(chakra_backend_objects CACHE) + +target_compile_options(ChakraCoreStatic PRIVATE "-fPIC") + +target_compile_definitions(ChakraCoreStatic + PUBLIC + -DCHAKRA_STATIC_LIBRARY=1 + ) +target_include_directories ( + ChakraCoreStatic PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CHAKRACORE_SOURCE_DIR}/lib/Common + ${CHAKRACORE_SOURCE_DIR}/lib/Runtime + ${CHAKRACORE_SOURCE_DIR}/lib/Runtime/ByteCode + ${CHAKRACORE_SOURCE_DIR}/lib/Parser + ${CHAKRACORE_SOURCE_DIR}/lib/Jsrt + ${CHAKRACORE_SOURCE_DIR}/lib/JITIDL + ${CHAKRACORE_SOURCE_DIR}/lib/Backend + ) + + +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + target_link_libraries(ChakraCoreStatic + pthread + dl + "-framework CoreFoundation" + "-framework Security" + ) +endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + if(CC_TARGETS_AMD64) + target_link_libraries(ChakraCoreStatic + unwind-x86_64 + ) + endif() + + target_link_libraries(ChakraCoreStatic + gcc_s + pthread + rt + dl + unwind + unwind-generic + ) +endif(CMAKE_SYSTEM_NAME STREQUAL Linux) + + # # Link step for the ChakraCore shared library # @@ -31,17 +113,13 @@ 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 -set(lib_target "${lib_target}" +set(Chakralib_target "${Chakralib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} - Chakra.Pal - Chakra.Common.Core - Chakra.Jsrt + Chakra.Jsrt.Singular ${LINKER_END_GROUP} pthread stdc++ @@ -49,18 +127,29 @@ set(lib_target "${lib_target}" ${ICULIB} ) -if(CMAKE_SYSTEM_NAME STREQUAL Linux) - set(lib_target "${lib_target}" - -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libChakraCoreLib.version + +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(Chakralib_target "${Chakralib_target}" + "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.Singular.a\"" ) endif() if(CC_TARGETS_X86) - set(lib_target "${lib_target} -m32") + set(Chakralib_target "${Chakralib_target} -m32") endif() -target_link_libraries (ChakraCore ${lib_target}) +#target_link_libraries (ChakraCoreStatic ${Chakralib_target}) +add_dependencies(ChakraCoreStatic Chakra.Pal) + +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + set(Chakralib_target "${Chakralib_target}" + -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libChakraCoreLib.version + ) +endif() +target_link_libraries (ChakraCore PRIVATE ${Chakralib_target}) + +unset(lib_target CACHE ) if(NOT CC_XCODE_PROJECT) set(CC_LIB_EXT "so") # Post build step to copy the built shared library @@ -74,4 +163,10 @@ if(NOT CC_XCODE_PROJECT) "${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCore.${CC_LIB_EXT}" ${CHAKRACORE_BINARY_DIR}/ ) + add_custom_command(TARGET ChakraCoreStatic POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a" + ${CHAKRACORE_BINARY_DIR}/ + ) + endif() diff --git a/bin/ChakraCore/ChakraCore.vcxproj b/bin/ChakraCore/ChakraCore.vcxproj index 12ec114a179..7d9191d8ec8 100644 --- a/bin/ChakraCore/ChakraCore.vcxproj +++ b/bin/ChakraCore/ChakraCore.vcxproj @@ -68,6 +68,7 @@ NotUsing + @@ -177,4 +178,4 @@ - \ No newline at end of file + diff --git a/bin/ChakraCore/ChakraCoreCommon.cpp b/bin/ChakraCore/ChakraCoreCommon.cpp new file mode 100644 index 00000000000..7afa62bc5d7 --- /dev/null +++ b/bin/ChakraCore/ChakraCoreCommon.cpp @@ -0,0 +1,154 @@ +//------------------------------------------------------------------------------------------------------- +// Copyright (C) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. +//------------------------------------------------------------------------------------------------------- +#include "JsrtPch.h" +#include "jsrtHelper.h" +#include "Base/ThreadContextTlsEntry.h" +#include "Base/ThreadBoundThreadContextManager.h" +#include "Core/ConfigParser.h" +#include "Core/AtomLockGuids.h" + +#ifdef DYNAMIC_PROFILE_STORAGE +#include "Language/DynamicProfileStorage.h" +#endif + +#ifdef VTUNE_PROFILING +#include "Base/VTuneChakraProfile.h" +#endif + +#ifdef ENABLE_JS_ETW +#include "Base/EtwTrace.h" +#endif + +void ChakraBinaryAutoSystemInfoInit(AutoSystemInfo * autoSystemInfo) +{ + autoSystemInfo->buildDateHash = JsUtil::CharacterBuffer::StaticGetHashCode(__DATE__, _countof(__DATE__)); + autoSystemInfo->buildTimeHash = JsUtil::CharacterBuffer::StaticGetHashCode(__TIME__, _countof(__TIME__)); +} + +// todo: We need an interface for thread/process exit. +// At the moment we do handle thread exit for non main threads on xplat +// However, it could be nice/necessary to provide an interface to make sure +// we cover additional edge cases. + +#ifdef _WIN32 +#if defined(CHAKRA_STATIC_LIBRARY) +static ATOM lockedDll = 0; +#else +extern ATOM lockedDll = 0; +#endif +#else +#include +static pthread_key_t s_threadLocalDummy; +#endif + +THREAD_LOCAL bool s_threadWasEntered = false; + +_NOINLINE void DISPOSE_CHAKRA_CORE_THREAD(void *_) +{ + free(_); + ThreadBoundThreadContextManager::DestroyContextAndEntryForCurrentThread(); +} + +_NOINLINE bool InitializeProcess() +{ + if(s_threadWasEntered) return true; +#if !defined(_WIN32) + pthread_key_create(&s_threadLocalDummy, DISPOSE_CHAKRA_CORE_THREAD); +#endif + +// setup the cleanup +// we do not track the main thread. When it exits do the cleanup below +atexit([]() { + ThreadBoundThreadContextManager::DestroyContextAndEntryForCurrentThread(); + + JsrtRuntime::Uninitialize(); + + // thread-bound entrypoint should be able to get cleanup correctly, however tlsentry + // for current thread might be left behind if this thread was initialized. + ThreadContextTLSEntry::CleanupThread(); + ThreadContextTLSEntry::CleanupProcess(); +}); + +// Attention: shared library is handled under (see ChakraCore/ChakraCoreDllFunc.cpp) +// todo: consolidate similar parts from shared and static library initialization +#ifndef _WIN32 + PAL_InitializeChakraCore(0, NULL); +#endif + + HMODULE mod = GetModuleHandleW(NULL); + + AutoSystemInfo::SaveModuleFileName(mod); + +#if defined(_M_IX86) && !defined(__clang__) + // Enable SSE2 math functions in CRT if SSE2 is available +#pragma prefast(suppress:6031, "We don't require SSE2, but will use it if available") + _set_SSE2_enable(TRUE); +#endif + + { + CmdLineArgsParser parser; + ConfigParser::ParseOnModuleLoad(parser, mod); + } + +#ifdef ENABLE_JS_ETW + EtwTrace::Register(); +#endif + ValueType::Initialize(); + ThreadContext::GlobalInitialize(); + + // Needed to make sure that only ChakraCore is loaded into the process + // This is unnecessary on Linux since there aren't other flavors of + // Chakra binaries that can be loaded into the process +#ifdef _WIN32 + char16 *engine = szChakraCoreLock; + if (::FindAtom(szChakraLock) != 0) + { + AssertMsg(FALSE, "Expecting to load chakracore.dll but process already loaded chakra.dll"); + Binary_Inconsistency_fatal_error(); + } + lockedDll = ::AddAtom(engine); + AssertMsg(lockedDll, "Failed to lock chakracore.dll"); +#endif // _WIN32 + +#ifdef ENABLE_BASIC_TELEMETRY + g_TraceLoggingClient = NoCheckHeapNewStruct(TraceLoggingClient); +#endif + + + return true; +} + +_NOINLINE void VALIDATE_ENTER_CURRENT_THREAD() +{ + +#if defined(CHAKRA_STATIC_LIBRARY) || !defined(_WIN32) + // We do also initialize the process part here + // This is thread safe by the standard + // Let's hope compiler doesn't fail + static bool _has_init = InitializeProcess(); + + if (!_has_init) // do not assert this. + { + abort(); + } + + if (s_threadWasEntered) return; + s_threadWasEntered = true; + +#ifdef DYNAMIC_PROFILE_STORAGE + DynamicProfileStorage::Initialize(); +#endif + +#ifdef HEAP_TRACK_ALLOC + HeapAllocator::InitializeThread(); +#endif + +#ifndef _WIN32 + // put something into key to make sure destructor is going to be called + pthread_setspecific(s_threadLocalDummy, malloc(1)); +#endif +#endif +} + diff --git a/bin/ChakraCore/ChakraCoreDllFunc.cpp b/bin/ChakraCore/ChakraCoreDllFunc.cpp index 86f10ce233f..1b931eeab87 100644 --- a/bin/ChakraCore/ChakraCoreDllFunc.cpp +++ b/bin/ChakraCore/ChakraCoreDllFunc.cpp @@ -33,6 +33,7 @@ extern HANDLE g_hInstance; #ifdef _WIN32 static ATOM lockedDll = 0; #endif +extern THREAD_LOCAL bool s_threadWasEntered; #ifdef _MSC_VER #define EXPORT_FUNC @@ -96,6 +97,8 @@ static BOOL AttachProcess(HANDLE hmod) g_TraceLoggingClient = NoCheckHeapNewStruct(TraceLoggingClient); #endif + s_threadWasEntered = true; + #ifdef DYNAMIC_PROFILE_STORAGE return DynamicProfileStorage::Initialize(); #else @@ -199,12 +202,6 @@ EXTERN_C BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, PVOID pvReserved) } } -void ChakraBinaryAutoSystemInfoInit(AutoSystemInfo * autoSystemInfo) -{ - autoSystemInfo->buildDateHash = JsUtil::CharacterBuffer::StaticGetHashCode(__DATE__, _countof(__DATE__)); - autoSystemInfo->buildTimeHash = JsUtil::CharacterBuffer::StaticGetHashCode(__TIME__, _countof(__TIME__)); -} - #if !ENABLE_NATIVE_CODEGEN EXPORT_FUNC HRESULT JsInitializeJITServer( diff --git a/bin/GCStress/CMakeLists.txt b/bin/GCStress/CMakeLists.txt index 0988349394f..6dc3f389954 100644 --- a/bin/GCStress/CMakeLists.txt +++ b/bin/GCStress/CMakeLists.txt @@ -26,9 +26,7 @@ endif() set(lib_target "${lib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} - Chakra.Common.Core - Chakra.Pal - Chakra.Jsrt + Chakra.Jsrt.Singular ${LINKER_END_GROUP} ) diff --git a/bin/GCStress/StubExternalApi.cpp b/bin/GCStress/StubExternalApi.cpp index d8fbeeff8ed..1ece70e754f 100644 --- a/bin/GCStress/StubExternalApi.cpp +++ b/bin/GCStress/StubExternalApi.cpp @@ -110,4 +110,10 @@ HRESULT MemProtectHeapSynchronizeWithCollector(void * heapHandle) { return E_NOT #if DBG && defined(INTERNAL_MEM_PROTECT_HEAP_ALLOC) void MemProtectHeapSetDisableConcurrentThreadExitedCheck(void * heapHandle) {}; -#endif \ No newline at end of file +#endif + + +_NOINLINE void VALIDATE_ENTER_CURRENT_THREAD() +{ + // Does nothing +} diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index 0a7133fde56..67d96f007f8 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -1,16 +1,15 @@ set(ch_source_files ch.cpp ChakraRtInterface.cpp - CodexAssert.cpp Debugger.cpp Helpers.cpp HostConfigFlags.cpp WScriptJsrt.cpp ) -if (STATIC_LIBRARY) - set(ch_source_files "${ch_source_files}" - ../ChakraCore/TestHooks.cpp +if(NOT STATIC_LIBRARY) + set(ch_source_files ${ch_source_files} + CodexAssert.cpp ) endif() @@ -43,16 +42,16 @@ if(STATIC_LIBRARY) set(LINKER_START_GROUP -Wl,--start-group) set(LINKER_END_GROUP -Wl,--end-group) elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) - set(LINKER_START_GROUP -Wl,-force_load,) + set(LINKER_START_GROUP + "-Wl,-force_load,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"" + ) endif() # common link deps set(lib_target "${lib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} - Chakra.Pal - Chakra.Common.Core - Chakra.Jsrt + ChakraCoreStatic ${LINKER_END_GROUP} pthread stdc++ @@ -73,7 +72,7 @@ if(STATIC_LIBRARY) endif() # Linux ? else() # // shared library below set(lib_target - PRIVATE Chakra.Pal + PRIVATE Chakra.Pal.Singular PRIVATE Chakra.Common.Codex.Singular PRIVATE Chakra.Runtime.PlatformAgnostic.Singular ) diff --git a/lib/Common/Core/CMakeLists.txt b/lib/Common/Core/CMakeLists.txt index f8cfefb5514..3642d3a893b 100644 --- a/lib/Common/Core/CMakeLists.txt +++ b/lib/Common/Core/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library (Chakra.Common.Core STATIC + +add_library (Chakra.Common.Core OBJECT Api.cpp BinaryFeatureControl.cpp CmdParser.cpp @@ -22,3 +23,4 @@ add_library (Chakra.Common.Core STATIC target_include_directories ( Chakra.Common.Core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + diff --git a/lib/Jsrt/CMakeLists.txt b/lib/Jsrt/CMakeLists.txt index ac3dc0d28c7..eb5824aea24 100644 --- a/lib/Jsrt/CMakeLists.txt +++ b/lib/Jsrt/CMakeLists.txt @@ -1,8 +1,10 @@ +project(CHAKRA_JSRT) + if(BuildJIT) set(chakra_backend_objects $) endif() -add_library (Chakra.Jsrt STATIC +add_library (Chakra.Jsrt OBJECT Jsrt.cpp JsrtDebugUtils.cpp JsrtDebugManager.cpp @@ -17,6 +19,11 @@ add_library (Chakra.Jsrt STATIC JsrtRuntime.cpp JsrtSourceHolder.cpp JsrtThreadService.cpp + ) + +add_library (Chakra.Jsrt.Singular STATIC + $ + $ $ ${chakra_backend_objects} # Do not take this in. We need to control the @@ -38,6 +45,7 @@ add_library (Chakra.Jsrt STATIC $ $ $ + $ ) add_subdirectory(Core) @@ -52,3 +60,41 @@ target_include_directories ( ../Runtime/Debug ../Parser ) + +target_include_directories ( + Chakra.Jsrt.Singular PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + ../Backend + ../JITIDL + ../Runtime + ../Runtime/Base + ../Runtime/ByteCode + ../Runtime/Debug + ../Parser + ) + +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + target_link_libraries(Chakra.Jsrt.Singular + pthread + dl + "-framework CoreFoundation" + "-framework Security" + ) +endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + if(CC_TARGETS_AMD64) + target_link_libraries(Chakra.Jsrt.Singular + unwind-x86_64 + ) + endif() + + target_link_libraries(Chakra.Jsrt.Singular + gcc_s + pthread + rt + dl + unwind + unwind-generic + ) +endif(CMAKE_SYSTEM_NAME STREQUAL Linux) + diff --git a/lib/Jsrt/JsrtHelper.cpp b/lib/Jsrt/JsrtHelper.cpp index e369495c1c3..8a61b050199 100644 --- a/lib/Jsrt/JsrtHelper.cpp +++ b/lib/Jsrt/JsrtHelper.cpp @@ -10,30 +10,6 @@ #include "Language/DynamicProfileStorage.h" #endif -#ifdef CHAKRA_STATIC_LIBRARY -#include "Core/ConfigParser.h" - -void ChakraBinaryAutoSystemInfoInit(AutoSystemInfo * autoSystemInfo) -{ - autoSystemInfo->buildDateHash = JsUtil::CharacterBuffer::StaticGetHashCode(__DATE__, _countof(__DATE__)); - autoSystemInfo->buildTimeHash = JsUtil::CharacterBuffer::StaticGetHashCode(__TIME__, _countof(__TIME__)); -} - -bool ConfigParserAPI::FillConsoleTitle(__ecount(cchBufferSize) LPWSTR buffer, size_t cchBufferSize, __in LPWSTR moduleName) -{ - return false; -} - -void ConfigParserAPI::DisplayInitialOutput(__in LPWSTR moduleName) -{ -} - -LPCWSTR JsUtil::ExternalApi::GetFeatureKeyName() -{ - return _u(""); -} -#endif - JsrtCallbackState::JsrtCallbackState(ThreadContext* currentThreadContext) { if (currentThreadContext == nullptr) @@ -78,122 +54,4 @@ void JsrtCallbackState::ObjectBeforeCallectCallbackWrapper(JsObjectBeforeCollect callback(object, callbackState); } -// todo: We need an interface for thread/process exit. -// At the moment we do handle thread exit for non main threads on xplat -// However, it could be nice/necessary to provide an interface to make sure -// we cover additional edge cases. -#if defined(CHAKRA_STATIC_LIBRARY) || !defined(_WIN32) - #include "Core/ConfigParser.h" - #include "Base/ThreadBoundThreadContextManager.h" - -#ifndef _WIN32 - #include - static pthread_key_t s_threadLocalDummy; -#endif - - static THREAD_LOCAL bool s_threadWasEntered = false; - - _NOINLINE void DISPOSE_CHAKRA_CORE_THREAD(void *_) - { - free(_); - ThreadBoundThreadContextManager::DestroyContextAndEntryForCurrentThread(); - } - - _NOINLINE bool InitializeProcess() - { -#if !defined(_WIN32) - pthread_key_create(&s_threadLocalDummy, DISPOSE_CHAKRA_CORE_THREAD); -#endif - -#if defined(CHAKRA_STATIC_LIBRARY) - - // setup the cleanup - // we do not track the main thread. When it exits do the cleanup below - atexit([]() { - ThreadBoundThreadContextManager::DestroyContextAndEntryForCurrentThread(); - - JsrtRuntime::Uninitialize(); - // thread-bound entrypoint should be able to get cleanup correctly, however tlsentry - // for current thread might be left behind if this thread was initialized. - ThreadContextTLSEntry::CleanupThread(); - ThreadContextTLSEntry::CleanupProcess(); - }); - - // Attention: shared library is handled under (see ChakraCore/ChakraCoreDllFunc.cpp) - // todo: consolidate similar parts from shared and static library initialization -#ifndef _WIN32 - PAL_InitializeChakraCore(0, NULL); -#endif - - HMODULE mod = GetModuleHandleW(NULL); - - AutoSystemInfo::SaveModuleFileName(mod); - - #if defined(_M_IX86) && !defined(__clang__) - // Enable SSE2 math functions in CRT if SSE2 is available - #pragma prefast(suppress:6031, "We don't require SSE2, but will use it if available") - _set_SSE2_enable(TRUE); - #endif - - { - CmdLineArgsParser parser; - ConfigParser::ParseOnModuleLoad(parser, mod); - } - - #ifdef ENABLE_JS_ETW - EtwTrace::Register(); - #endif - ValueType::Initialize(); - ThreadContext::GlobalInitialize(); - - // Needed to make sure that only ChakraCore is loaded into the process - // This is unnecessary on Linux since there aren't other flavors of - // Chakra binaries that can be loaded into the process - #ifdef _WIN32 - char16 *engine = szChakraCoreLock; - if (::FindAtom(szChakraLock) != 0) - { - AssertMsg(FALSE, "Expecting to load chakracore.dll but process already loaded chakra.dll"); - Binary_Inconsistency_fatal_error(); - } - lockedDll = ::AddAtom(engine); - AssertMsg(lockedDll, "Failed to lock chakracore.dll"); - #endif // _WIN32 - - #ifdef ENABLE_BASIC_TELEMETRY - g_TraceLoggingClient = NoCheckHeapNewStruct(TraceLoggingClient); - #endif - - #ifdef DYNAMIC_PROFILE_STORAGE - DynamicProfileStorage::Initialize(); - #endif -#endif // STATIC_LIBRARY - return true; - } - - _NOINLINE void VALIDATE_ENTER_CURRENT_THREAD() - { - // We do also initialize the process part here - // This is thread safe by the standard - // Let's hope compiler doesn't fail - static bool _has_init = InitializeProcess(); - - if (!_has_init) // do not assert this. - { - abort(); - } - - if (s_threadWasEntered) return; - s_threadWasEntered = true; - - #ifdef HEAP_TRACK_ALLOC - HeapAllocator::InitializeThread(); - #endif - -#ifndef _WIN32 - // put something into key to make sure destructor is going to be called - pthread_setspecific(s_threadLocalDummy, malloc(1)); -#endif - } -#endif diff --git a/lib/Jsrt/jsrtHelper.h b/lib/Jsrt/jsrtHelper.h index f55830e52d3..5a30908052a 100644 --- a/lib/Jsrt/jsrtHelper.h +++ b/lib/Jsrt/jsrtHelper.h @@ -15,9 +15,6 @@ class JsrtCallbackState JsrtContext* originalJsrtContext; }; -#if defined(CHAKRA_STATIC_LIBRARY) || !defined(_WIN32) + _NOINLINE void VALIDATE_ENTER_CURRENT_THREAD(); -#else -// Windows Shared Library: DllMain is responsible from handling all these stuff -#define VALIDATE_ENTER_CURRENT_THREAD() -#endif + diff --git a/pal/src/CMakeLists.txt b/pal/src/CMakeLists.txt index 920efba116a..84d397e2000 100644 --- a/pal/src/CMakeLists.txt +++ b/pal/src/CMakeLists.txt @@ -161,14 +161,19 @@ set(SOURCES ) add_library(Chakra.Pal - STATIC + OBJECT ${SOURCES} ${PLATFORM_SOURCES} ${ARCH_SOURCES} ) +add_library(Chakra.Pal.Singular + STATIC + $ +) + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) - target_link_libraries(Chakra.Pal + target_link_libraries(Chakra.Pal.Singular pthread dl "-framework CoreFoundation" @@ -178,12 +183,12 @@ endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) if(CMAKE_SYSTEM_NAME STREQUAL Linux) if(CC_TARGETS_AMD64) - target_link_libraries(Chakra.Pal + target_link_libraries(Chakra.Pal.Singular unwind-x86_64 ) endif() - target_link_libraries(Chakra.Pal + target_link_libraries(Chakra.Pal.Singular gcc_s pthread rt @@ -194,4 +199,4 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) endif(CMAKE_SYSTEM_NAME STREQUAL Linux) # Install the static PAL library for VS -install (TARGETS Chakra.Pal DESTINATION lib) +install (TARGETS Chakra.Pal.Singular DESTINATION lib) diff --git a/test/native-tests/test-char/Platform.js b/test/native-tests/test-char/Platform.js index 125c89a8c72..04cc8b26c58 100644 --- a/test/native-tests/test-char/Platform.js +++ b/test/native-tests/test-char/Platform.js @@ -20,9 +20,8 @@ if (!isStaticBuild) { \n\ LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ -LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ - $(LIBRARY_PATH)/Common/Core/libChakra.Common.Core.a \ - $(LIBRARY_PATH)/Jsrt/libChakra.Jsrt.a \n\ +LDIR=" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ +\n\ \n\ ifeq (darwin, ${PLATFORM})\n\ \tICU4C_LIBRARY_PATH ?= /usr/local/opt/icu4c\n\ diff --git a/test/native-tests/test-char16/Platform.js b/test/native-tests/test-char16/Platform.js index 125c89a8c72..dc4e98ed88f 100644 --- a/test/native-tests/test-char16/Platform.js +++ b/test/native-tests/test-char16/Platform.js @@ -20,9 +20,7 @@ if (!isStaticBuild) { \n\ LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ -LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ - $(LIBRARY_PATH)/Common/Core/libChakra.Common.Core.a \ - $(LIBRARY_PATH)/Jsrt/libChakra.Jsrt.a \n\ +LDIR=" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ ifeq (darwin, ${PLATFORM})\n\ \tICU4C_LIBRARY_PATH ?= /usr/local/opt/icu4c\n\ diff --git a/test/native-tests/test-static-native/Platform.js b/test/native-tests/test-static-native/Platform.js index 125c89a8c72..dc4e98ed88f 100644 --- a/test/native-tests/test-static-native/Platform.js +++ b/test/native-tests/test-static-native/Platform.js @@ -20,9 +20,7 @@ if (!isStaticBuild) { \n\ LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ -LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ - $(LIBRARY_PATH)/Common/Core/libChakra.Common.Core.a \ - $(LIBRARY_PATH)/Jsrt/libChakra.Jsrt.a \n\ +LDIR=" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ ifeq (darwin, ${PLATFORM})\n\ \tICU4C_LIBRARY_PATH ?= /usr/local/opt/icu4c\n\ diff --git a/test/runtests.sh b/test/runtests.sh index f9d887c4017..ebef6fc9369 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -41,7 +41,7 @@ else # TEST flags are not enabled for release build # however we would like to test if the compiled binary # works or not - RES=$($test_path/../BuildLinux/${binary_path}/ch $test_path/basics/hello.js) + RES=$($test_path/../BuildLinux/${binary_path}/ch $test_path/Basics/hello.js) if [[ $RES =~ "Error :" ]]; then echo "FAILED" exit 1