From 1042cb4dd3a4adbd5faa3a5426aec0eccfd3f8ed Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Fri, 2 Dec 2016 23:40:21 -0600 Subject: [PATCH 01/14] xplat: ChakraCore should forceload all static archives. This forces all symbols of each of the static libraries to load into libChakraCore.dylib. This will increase runtime size a little, but should hopefully prevent linker errors. --- bin/ChakraCore/CMakeLists.txt | 10 +++++++--- lib/Jsrt/CMakeLists.txt | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index bf3babe80c6..f04b4053cce 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -31,9 +31,7 @@ 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() +endif # common link deps set(lib_target "${lib_target}" @@ -53,6 +51,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) set(lib_target "${lib_target}" -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libChakraCoreLib.version ) +elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(lib_target "${lib_target}" + "-Wl,-force_load,${chakrapal_BINARY_DIR}/libChakra.Pal.a" + "-Wl,-force_load,${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a" + "-Wl,-force_load,${CHAKRA_JSRT_BINARY_DIR}/Core/libChakra.Jsrt.a" + ) endif() if(CC_TARGETS_X86) diff --git a/lib/Jsrt/CMakeLists.txt b/lib/Jsrt/CMakeLists.txt index ac3dc0d28c7..da2a051e683 100644 --- a/lib/Jsrt/CMakeLists.txt +++ b/lib/Jsrt/CMakeLists.txt @@ -1,3 +1,5 @@ +project(CHAKRA_JSRT) + if(BuildJIT) set(chakra_backend_objects $) endif() From 8135c7a3a607acabfe5a406ad7ac8933ce272bcc Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 13:05:17 -0600 Subject: [PATCH 02/14] xplat: Reduce Static/Shared Library differences. This will greatly reduce time required to rebuild and switch between static and shared libraries. Note: for Xcode/IOS, the force_load parameter is only good for the next library mentioned. This patch forces all of the existing libraries to get loaded into a single library libChakraCoreStatic, and hopefully also will make it to where libChakraCore has all the required symbols too. --- CMakeLists.txt | 3 - bin/CMakeLists.txt | 5 +- bin/ChakraCore/CMakeLists.txt | 56 ++++++++-- bin/ChakraCore/ChakraCore.vcxproj | 3 +- bin/ChakraCore/ChakraCoreCommon.cpp | 154 +++++++++++++++++++++++++++ bin/ChakraCore/ChakraCoreDllFunc.cpp | 9 +- bin/GCStress/StubExternalApi.cpp | 8 +- bin/ch/CMakeLists.txt | 14 ++- lib/Jsrt/JsrtHelper.cpp | 142 ------------------------ lib/Jsrt/jsrtHelper.h | 7 +- 10 files changed, 221 insertions(+), 180 deletions(-) create mode 100644 bin/ChakraCore/ChakraCoreCommon.cpp 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 f04b4053cce..29218682f23 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,26 @@ target_include_directories ( ${CHAKRACORE_SOURCE_DIR}/lib/Jsrt ) + + +add_library (ChakraCoreStatic STATIC + ChakraCoreCommon.cpp + ConfigParserExternals.cpp + TestHooks.cpp + ) +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/Parser + ${CHAKRACORE_SOURCE_DIR}/lib/Jsrt + ) # # Link step for the ChakraCore shared library # @@ -31,10 +52,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) -Wl,--no-whole-archive -Wl,--end-group ) -endif +endif() # common link deps -set(lib_target "${lib_target}" +set(Chakralib_target "${Chakralib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} Chakra.Pal @@ -47,24 +68,31 @@ 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 - ) -elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) - set(lib_target "${lib_target}" + +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(Chakralib_target "${Chakralib_target}" "-Wl,-force_load,${chakrapal_BINARY_DIR}/libChakra.Pal.a" - "-Wl,-force_load,${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a" + "-Wl-force_load,${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a" "-Wl,-force_load,${CHAKRA_JSRT_BINARY_DIR}/Core/libChakra.Jsrt.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 PRIVATE ${Chakralib_target}) + + +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 @@ -78,4 +106,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/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..4ad19a987b5 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,15 @@ 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++ 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 + From b16a4b90b205826850f39c0e5ce177090b8da04e Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 13:25:29 -0600 Subject: [PATCH 03/14] xplat: fix non-test linker errors. Cmake currently does not allow for merging of multiple static libraries together unless someone uses objects. This should greatly improve --- bin/ChakraCore/CMakeLists.txt | 7 +++++-- bin/ch/CMakeLists.txt | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index 29218682f23..c4d039651bd 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -31,8 +31,11 @@ target_include_directories ( ${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 ) # # Link step for the ChakraCore shared library @@ -81,8 +84,8 @@ if(CC_TARGETS_X86) set(Chakralib_target "${Chakralib_target} -m32") endif() -target_link_libraries (ChakraCoreStatic PRIVATE ${Chakralib_target}) - +#target_link_libraries (ChakraCoreStatic ${Chakralib_target}) +add_dependencies(ChakraCoreStatic Chakra.Pal Chakra.Common.Core Chakra.Jsrt) if(CMAKE_SYSTEM_NAME STREQUAL Linux) diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index 4ad19a987b5..f38dc52cd5e 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -50,6 +50,9 @@ if(STATIC_LIBRARY) set(lib_target "${lib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} + Chakra.Common.Core + Chakra.Pal + Chakra.Jsrt ChakraCoreStatic ${LINKER_END_GROUP} pthread From 259c5ec2b62e476c6edd039dc665ce145e416616 Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 13:30:25 -0600 Subject: [PATCH 04/14] xplat: Fix Basic runtime test. Not all platforms work well with case insensitive file paths. This fixes runtime on Linux partitions. --- test/runtests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From a35449b38f932b98002db53ebc4ba267d0ad7086 Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 13:31:23 -0600 Subject: [PATCH 05/14] xplat: fix tests broken by new object. --- test/native-tests/test-char/Platform.js | 4 +++- test/native-tests/test-char16/Platform.js | 3 ++- test/native-tests/test-static-native/Platform.js | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/native-tests/test-char/Platform.js b/test/native-tests/test-char/Platform.js index 125c89a8c72..88cf58ce052 100644 --- a/test/native-tests/test-char/Platform.js +++ b/test/native-tests/test-char/Platform.js @@ -22,7 +22,9 @@ 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\ + $(LIBRARY_PATH)/Jsrt/libChakra.Jsrt.a \ +" + binaryPath + "/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..6f132aada27 100644 --- a/test/native-tests/test-char16/Platform.js +++ b/test/native-tests/test-char16/Platform.js @@ -22,7 +22,8 @@ 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\ + $(LIBRARY_PATH)/Jsrt/libChakra.Jsrt.a \ +" + binaryPath + "/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..6f132aada27 100644 --- a/test/native-tests/test-static-native/Platform.js +++ b/test/native-tests/test-static-native/Platform.js @@ -22,7 +22,8 @@ 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\ + $(LIBRARY_PATH)/Jsrt/libChakra.Jsrt.a \ +" + binaryPath + "/libChakraCoreStatic.a\n \ \n\ ifeq (darwin, ${PLATFORM})\n\ \tICU4C_LIBRARY_PATH ?= /usr/local/opt/icu4c\n\ From cb3dfa1127cd405be8184e042a8120248e05619a Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 13:41:47 -0600 Subject: [PATCH 06/14] xplat: fix typo on force_load arguments. A minor typo lead to the compile error. This should resolve the issue. --- bin/ChakraCore/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index c4d039651bd..716782a3b97 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -74,9 +74,9 @@ set(Chakralib_target "${Chakralib_target}" if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(Chakralib_target "${Chakralib_target}" - "-Wl,-force_load,${chakrapal_BINARY_DIR}/libChakra.Pal.a" - "-Wl-force_load,${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a" - "-Wl,-force_load,${CHAKRA_JSRT_BINARY_DIR}/Core/libChakra.Jsrt.a" + "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" + "-Wl-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\"" + "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\"" ) endif() From bd9f27832072f1805c859a4918c77158ebf6b984 Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 13:50:47 -0600 Subject: [PATCH 07/14] xplat: Fix Native test linker libs. This should fix the Native linker targets for xplat. --- test/native-tests/test-char/Platform.js | 2 +- test/native-tests/test-char16/Platform.js | 2 +- test/native-tests/test-static-native/Platform.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/native-tests/test-char/Platform.js b/test/native-tests/test-char/Platform.js index 88cf58ce052..45675bedc2f 100644 --- a/test/native-tests/test-char/Platform.js +++ b/test/native-tests/test-char/Platform.js @@ -23,7 +23,7 @@ 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 \ -" + binaryPath + "/libChakraCoreStatic.a\n \ +" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ \n\ ifeq (darwin, ${PLATFORM})\n\ diff --git a/test/native-tests/test-char16/Platform.js b/test/native-tests/test-char16/Platform.js index 6f132aada27..241ef87681b 100644 --- a/test/native-tests/test-char16/Platform.js +++ b/test/native-tests/test-char16/Platform.js @@ -23,7 +23,7 @@ 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 \ -" + binaryPath + "/libChakraCoreStatic.a\n \ +" + 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 6f132aada27..241ef87681b 100644 --- a/test/native-tests/test-static-native/Platform.js +++ b/test/native-tests/test-static-native/Platform.js @@ -23,7 +23,7 @@ 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 \ -" + binaryPath + "/libChakraCoreStatic.a\n \ +" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ ifeq (darwin, ${PLATFORM})\n\ \tICU4C_LIBRARY_PATH ?= /usr/local/opt/icu4c\n\ From f5100ea400bb1d3794aec9f6008c592389621062 Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 22:31:21 -0600 Subject: [PATCH 08/14] xplat: yet some more osx linker typo fixes. This should help prevent errors by ensuring that the complete static library is loaded and that no typos exist in the arguments. --- bin/ChakraCore/CMakeLists.txt | 6 +++--- bin/ch/CMakeLists.txt | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index 716782a3b97..df9d4cc0ea5 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -74,9 +74,9 @@ set(Chakralib_target "${Chakralib_target}" if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(Chakralib_target "${Chakralib_target}" - "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" - "-Wl-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\"" - "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\"" + "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\" " + "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\" " + "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\" " ) endif() diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index f38dc52cd5e..d32c66e2a7f 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -42,8 +42,12 @@ 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,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"") - + set(LINKER_START_GROUP + "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\" " + "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\" " + "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\" " + "-Wl,-force_load,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"") + ) endif() # common link deps From e30b9ec3d05c20804825e7f7e67d10f4ae4da77f Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 22:37:43 -0600 Subject: [PATCH 09/14] cmake: fix yet another typo. There was an extra parenthisis in one of the cmake files that lead to build failure on OSX. --- bin/ch/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index d32c66e2a7f..28c7f3cceeb 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -46,7 +46,7 @@ if(STATIC_LIBRARY) "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\" " "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\" " "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\" " - "-Wl,-force_load,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"") + "-Wl,-force_load,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"" ) endif() From 5ca1afe3cd2904a67b245a6a43f2dc5500e24fff Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 22:41:23 -0600 Subject: [PATCH 10/14] cmake: fix CMP0004 warnings. In future versions of CMake the leading/trailing whitespace will cause errors since the behavior is deprecated. --- bin/ChakraCore/CMakeLists.txt | 6 +++--- bin/ch/CMakeLists.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index df9d4cc0ea5..72a4b470562 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -74,9 +74,9 @@ set(Chakralib_target "${Chakralib_target}" if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(Chakralib_target "${Chakralib_target}" - "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\" " - "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\" " - "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\" " + "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" + "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\"" + "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\"" ) endif() diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index 28c7f3cceeb..39f6f3cf68f 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -43,9 +43,9 @@ if(STATIC_LIBRARY) set(LINKER_END_GROUP -Wl,--end-group) elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(LINKER_START_GROUP - "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\" " - "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\" " - "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\" " + "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" + "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\"" + "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\"" "-Wl,-force_load,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"" ) endif() From c147b54e63c2a5495c4c381afc9a3333ae47fab0 Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sat, 3 Dec 2016 23:40:36 -0600 Subject: [PATCH 11/14] xplat: merge Chakra.Jsrt into libChakraCoreStatic. This merges Chakra.Jsrt into libChakraCoreStatic, and adds a new static library for GCStress called Chakra.Jsrt.Singular. This new library is simply the old method for linking Chakra.Jsrt under a new name. --- bin/ChakraCore/CMakeLists.txt | 33 +++++++++++++++++-- bin/GCStress/CMakeLists.txt | 2 +- bin/ch/CMakeLists.txt | 2 -- lib/Jsrt/CMakeLists.txt | 31 ++++++++++++++++- test/native-tests/test-char/Platform.js | 1 - test/native-tests/test-char16/Platform.js | 1 - .../test-static-native/Platform.js | 1 - 7 files changed, 61 insertions(+), 10 deletions(-) diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index 72a4b470562..3a4b6e36261 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -15,12 +15,39 @@ target_include_directories ( ) +if(BuildJIT) + set(chakra_backend_objects $) +endif() add_library (ChakraCoreStatic STATIC ChakraCoreCommon.cpp ConfigParserExternals.cpp TestHooks.cpp + $ + ${chakra_backend_objects} +# Do not take this in. We need to control the +# linker order because of global constructors +# and cross dependencies among them +# $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ ) +unset(chakra_backend_objects CACHE) + target_compile_options(ChakraCoreStatic PRIVATE "-fPIC") target_compile_definitions(ChakraCoreStatic PUBLIC @@ -63,7 +90,7 @@ set(Chakralib_target "${Chakralib_target}" ${LINKER_START_GROUP} Chakra.Pal Chakra.Common.Core - Chakra.Jsrt + Chakra.Jsrt.Singular ${LINKER_END_GROUP} pthread stdc++ @@ -76,7 +103,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(Chakralib_target "${Chakralib_target}" "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\"" - "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\"" + "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.Singular.a\"" ) endif() @@ -85,7 +112,7 @@ if(CC_TARGETS_X86) endif() #target_link_libraries (ChakraCoreStatic ${Chakralib_target}) -add_dependencies(ChakraCoreStatic Chakra.Pal Chakra.Common.Core Chakra.Jsrt) +add_dependencies(ChakraCoreStatic Chakra.Pal Chakra.Common.Core) if(CMAKE_SYSTEM_NAME STREQUAL Linux) diff --git a/bin/GCStress/CMakeLists.txt b/bin/GCStress/CMakeLists.txt index 0988349394f..35ff1383d6c 100644 --- a/bin/GCStress/CMakeLists.txt +++ b/bin/GCStress/CMakeLists.txt @@ -28,7 +28,7 @@ set(lib_target "${lib_target}" ${LINKER_START_GROUP} Chakra.Common.Core Chakra.Pal - Chakra.Jsrt + Chakra.Jsrt.Singular ${LINKER_END_GROUP} ) diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index 39f6f3cf68f..faa91dd718a 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -45,7 +45,6 @@ if(STATIC_LIBRARY) set(LINKER_START_GROUP "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\"" - "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.a\"" "-Wl,-force_load,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"" ) endif() @@ -56,7 +55,6 @@ if(STATIC_LIBRARY) ${LINKER_START_GROUP} Chakra.Common.Core Chakra.Pal - Chakra.Jsrt ChakraCoreStatic ${LINKER_END_GROUP} pthread diff --git a/lib/Jsrt/CMakeLists.txt b/lib/Jsrt/CMakeLists.txt index da2a051e683..579b1897ef7 100644 --- a/lib/Jsrt/CMakeLists.txt +++ b/lib/Jsrt/CMakeLists.txt @@ -4,7 +4,24 @@ if(BuildJIT) set(chakra_backend_objects $) endif() -add_library (Chakra.Jsrt STATIC +add_library (Chakra.Jsrt OBJECT + Jsrt.cpp + JsrtDebugUtils.cpp + JsrtDebugManager.cpp + JsrtDebuggerObject.cpp + JsrtDiag.cpp + JsrtContext.cpp + JsrtExternalArrayBuffer.cpp + JsrtExternalObject.cpp + JsrtDebugEventObject.cpp + JsrtHelper.cpp + JsrtPch.cpp + JsrtRuntime.cpp + JsrtSourceHolder.cpp + JsrtThreadService.cpp + ) + +add_library (Chakra.Jsrt.Singular STATIC Jsrt.cpp JsrtDebugUtils.cpp JsrtDebugManager.cpp @@ -54,3 +71,15 @@ 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 + ) + diff --git a/test/native-tests/test-char/Platform.js b/test/native-tests/test-char/Platform.js index 45675bedc2f..9f78e949d69 100644 --- a/test/native-tests/test-char/Platform.js +++ b/test/native-tests/test-char/Platform.js @@ -22,7 +22,6 @@ 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 \ " + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ \n\ diff --git a/test/native-tests/test-char16/Platform.js b/test/native-tests/test-char16/Platform.js index 241ef87681b..bb24a7e3a18 100644 --- a/test/native-tests/test-char16/Platform.js +++ b/test/native-tests/test-char16/Platform.js @@ -22,7 +22,6 @@ 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 \ " + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ ifeq (darwin, ${PLATFORM})\n\ diff --git a/test/native-tests/test-static-native/Platform.js b/test/native-tests/test-static-native/Platform.js index 241ef87681b..bb24a7e3a18 100644 --- a/test/native-tests/test-static-native/Platform.js +++ b/test/native-tests/test-static-native/Platform.js @@ -22,7 +22,6 @@ 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 \ " + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ ifeq (darwin, ${PLATFORM})\n\ From 05917db49a0a647f174084d47295f2fac0c8b17d Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sun, 4 Dec 2016 12:08:04 -0600 Subject: [PATCH 12/14] xplat: make Chakra.Common.Core an object. This object is Consumed by the various other static libraries, and reduces the number of overall libraries lying around the build directory. --- bin/ChakraCore/CMakeLists.txt | 5 ++--- bin/GCStress/CMakeLists.txt | 1 - bin/ch/CMakeLists.txt | 2 -- lib/Common/Core/CMakeLists.txt | 4 +++- lib/Jsrt/CMakeLists.txt | 16 ++-------------- 5 files changed, 7 insertions(+), 21 deletions(-) diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index 3a4b6e36261..306ef7fa1ed 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -23,6 +23,7 @@ add_library (ChakraCoreStatic STATIC ChakraCoreCommon.cpp ConfigParserExternals.cpp TestHooks.cpp + $ $ ${chakra_backend_objects} # Do not take this in. We need to control the @@ -89,7 +90,6 @@ set(Chakralib_target "${Chakralib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} Chakra.Pal - Chakra.Common.Core Chakra.Jsrt.Singular ${LINKER_END_GROUP} pthread @@ -102,7 +102,6 @@ set(Chakralib_target "${Chakralib_target}" if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(Chakralib_target "${Chakralib_target}" "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" - "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\"" "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.Singular.a\"" ) endif() @@ -112,7 +111,7 @@ if(CC_TARGETS_X86) endif() #target_link_libraries (ChakraCoreStatic ${Chakralib_target}) -add_dependencies(ChakraCoreStatic Chakra.Pal Chakra.Common.Core) +add_dependencies(ChakraCoreStatic Chakra.Pal) if(CMAKE_SYSTEM_NAME STREQUAL Linux) diff --git a/bin/GCStress/CMakeLists.txt b/bin/GCStress/CMakeLists.txt index 35ff1383d6c..765831ecc26 100644 --- a/bin/GCStress/CMakeLists.txt +++ b/bin/GCStress/CMakeLists.txt @@ -26,7 +26,6 @@ endif() set(lib_target "${lib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} - Chakra.Common.Core Chakra.Pal Chakra.Jsrt.Singular ${LINKER_END_GROUP} diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index faa91dd718a..8c061a3976a 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -44,7 +44,6 @@ if(STATIC_LIBRARY) elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(LINKER_START_GROUP "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" - "-Wl,-force_load,\"${CHAKRA_COMMON_BINARY_DIR}/Core/libChakra.Common.Core.a\"" "-Wl,-force_load,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"" ) endif() @@ -53,7 +52,6 @@ if(STATIC_LIBRARY) set(lib_target "${lib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} - Chakra.Common.Core Chakra.Pal ChakraCoreStatic ${LINKER_END_GROUP} 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 579b1897ef7..2c1b6f30219 100644 --- a/lib/Jsrt/CMakeLists.txt +++ b/lib/Jsrt/CMakeLists.txt @@ -22,20 +22,7 @@ add_library (Chakra.Jsrt OBJECT ) add_library (Chakra.Jsrt.Singular STATIC - Jsrt.cpp - JsrtDebugUtils.cpp - JsrtDebugManager.cpp - JsrtDebuggerObject.cpp - JsrtDiag.cpp - JsrtContext.cpp - JsrtExternalArrayBuffer.cpp - JsrtExternalObject.cpp - JsrtDebugEventObject.cpp - JsrtHelper.cpp - JsrtPch.cpp - JsrtRuntime.cpp - JsrtSourceHolder.cpp - JsrtThreadService.cpp + $ $ ${chakra_backend_objects} # Do not take this in. We need to control the @@ -57,6 +44,7 @@ add_library (Chakra.Jsrt.Singular STATIC $ $ $ + $ ) add_subdirectory(Core) From d640673bf97d90484f3612581b5bbba4ad7feb01 Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sun, 4 Dec 2016 12:19:33 -0600 Subject: [PATCH 13/14] tests: fix test break caused by making Chakra.Common.Core an object. --- test/native-tests/test-char/Platform.js | 1 - test/native-tests/test-char16/Platform.js | 1 - test/native-tests/test-static-native/Platform.js | 1 - 3 files changed, 3 deletions(-) diff --git a/test/native-tests/test-char/Platform.js b/test/native-tests/test-char/Platform.js index 9f78e949d69..da716b20f98 100644 --- a/test/native-tests/test-char/Platform.js +++ b/test/native-tests/test-char/Platform.js @@ -21,7 +21,6 @@ if (!isStaticBuild) { LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ - $(LIBRARY_PATH)/Common/Core/libChakra.Common.Core.a \ " + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ \n\ diff --git a/test/native-tests/test-char16/Platform.js b/test/native-tests/test-char16/Platform.js index bb24a7e3a18..ae73b1cd378 100644 --- a/test/native-tests/test-char16/Platform.js +++ b/test/native-tests/test-char16/Platform.js @@ -21,7 +21,6 @@ if (!isStaticBuild) { LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ - $(LIBRARY_PATH)/Common/Core/libChakra.Common.Core.a \ " + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ ifeq (darwin, ${PLATFORM})\n\ diff --git a/test/native-tests/test-static-native/Platform.js b/test/native-tests/test-static-native/Platform.js index bb24a7e3a18..ae73b1cd378 100644 --- a/test/native-tests/test-static-native/Platform.js +++ b/test/native-tests/test-static-native/Platform.js @@ -21,7 +21,6 @@ if (!isStaticBuild) { LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ - $(LIBRARY_PATH)/Common/Core/libChakra.Common.Core.a \ " + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ ifeq (darwin, ${PLATFORM})\n\ From 697fc08f10bd7c5d58a63ad6f313a3db4e099686 Mon Sep 17 00:00:00 2001 From: Kenney Phillis Jr Date: Sun, 4 Dec 2016 13:12:51 -0600 Subject: [PATCH 14/14] xplat: convert Chakra.Pal to an Object. This gets rid of the Chakra.Pal object all together. --- bin/ChakraCore/CMakeLists.txt | 40 ++++++++++++++++--- bin/GCStress/CMakeLists.txt | 1 - bin/ch/CMakeLists.txt | 4 +- lib/Jsrt/CMakeLists.txt | 27 +++++++++++++ pal/src/CMakeLists.txt | 15 ++++--- test/native-tests/test-char/Platform.js | 3 +- test/native-tests/test-char16/Platform.js | 3 +- .../test-static-native/Platform.js | 3 +- 8 files changed, 75 insertions(+), 21 deletions(-) diff --git a/bin/ChakraCore/CMakeLists.txt b/bin/ChakraCore/CMakeLists.txt index 306ef7fa1ed..679b6c48559 100644 --- a/bin/ChakraCore/CMakeLists.txt +++ b/bin/ChakraCore/CMakeLists.txt @@ -23,13 +23,13 @@ add_library (ChakraCoreStatic STATIC ChakraCoreCommon.cpp ConfigParserExternals.cpp TestHooks.cpp - $ - $ - ${chakra_backend_objects} # Do not take this in. We need to control the # linker order because of global constructors # and cross dependencies among them -# $ + $ + $ + $ + ${chakra_backend_objects} $ $ $ @@ -50,6 +50,7 @@ add_library (ChakraCoreStatic STATIC unset(chakra_backend_objects CACHE) target_compile_options(ChakraCoreStatic PRIVATE "-fPIC") + target_compile_definitions(ChakraCoreStatic PUBLIC -DCHAKRA_STATIC_LIBRARY=1 @@ -65,6 +66,35 @@ target_include_directories ( ${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 # @@ -89,7 +119,6 @@ endif() set(Chakralib_target "${Chakralib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} - Chakra.Pal Chakra.Jsrt.Singular ${LINKER_END_GROUP} pthread @@ -101,7 +130,6 @@ set(Chakralib_target "${Chakralib_target}" if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(Chakralib_target "${Chakralib_target}" - "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" "-Wl,-force_load,\"${CHAKRA_JSRT_BINARY_DIR}/libChakra.Jsrt.Singular.a\"" ) endif() diff --git a/bin/GCStress/CMakeLists.txt b/bin/GCStress/CMakeLists.txt index 765831ecc26..6dc3f389954 100644 --- a/bin/GCStress/CMakeLists.txt +++ b/bin/GCStress/CMakeLists.txt @@ -26,7 +26,6 @@ endif() set(lib_target "${lib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} - Chakra.Pal Chakra.Jsrt.Singular ${LINKER_END_GROUP} ) diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index 8c061a3976a..67d96f007f8 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -43,7 +43,6 @@ if(STATIC_LIBRARY) set(LINKER_END_GROUP -Wl,--end-group) elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(LINKER_START_GROUP - "-Wl,-force_load,\"${chakrapal_BINARY_DIR}/libChakra.Pal.a\"" "-Wl,-force_load,\"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCoreStatic.a\"" ) endif() @@ -52,7 +51,6 @@ if(STATIC_LIBRARY) set(lib_target "${lib_target}" -Wl,-undefined,error ${LINKER_START_GROUP} - Chakra.Pal ChakraCoreStatic ${LINKER_END_GROUP} pthread @@ -74,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/Jsrt/CMakeLists.txt b/lib/Jsrt/CMakeLists.txt index 2c1b6f30219..eb5824aea24 100644 --- a/lib/Jsrt/CMakeLists.txt +++ b/lib/Jsrt/CMakeLists.txt @@ -22,6 +22,7 @@ add_library (Chakra.Jsrt OBJECT ) add_library (Chakra.Jsrt.Singular STATIC + $ $ $ ${chakra_backend_objects} @@ -71,3 +72,29 @@ target_include_directories ( ../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/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 da716b20f98..04cc8b26c58 100644 --- a/test/native-tests/test-char/Platform.js +++ b/test/native-tests/test-char/Platform.js @@ -20,8 +20,7 @@ if (!isStaticBuild) { \n\ LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ -LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ -" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ +LDIR=" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ \n\ ifeq (darwin, ${PLATFORM})\n\ diff --git a/test/native-tests/test-char16/Platform.js b/test/native-tests/test-char16/Platform.js index ae73b1cd378..dc4e98ed88f 100644 --- a/test/native-tests/test-char16/Platform.js +++ b/test/native-tests/test-char16/Platform.js @@ -20,8 +20,7 @@ if (!isStaticBuild) { \n\ LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ -LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ -" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.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 ae73b1cd378..dc4e98ed88f 100644 --- a/test/native-tests/test-static-native/Platform.js +++ b/test/native-tests/test-static-native/Platform.js @@ -20,8 +20,7 @@ if (!isStaticBuild) { \n\ LIBRARY_PATH=" + binaryPath + "/lib\n\ PLATFORM=" + platform + "\n\ -LDIR=$(LIBRARY_PATH)/../pal/src/libChakra.Pal.a \ -" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ +LDIR=" + binaryPath + "/bin/ChakraCore/libChakraCoreStatic.a \n \ \n\ ifeq (darwin, ${PLATFORM})\n\ \tICU4C_LIBRARY_PATH ?= /usr/local/opt/icu4c\n\