Skip to content

Commit c320a5c

Browse files
committed
cross-platform: Compile into module blocks
- Combines static libraries from sub projects. (Linux, macOS) ChakraCore consumer now links to 3 libs instead of 18. - Defines AutoSystemInfo etc. initializers builtin for ease of embedding
1 parent e201dbd commit c320a5c

26 files changed

Lines changed: 141 additions & 199 deletions

File tree

bin/ChakraCore/CMakeLists.txt

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,78 +16,43 @@ target_include_directories (
1616
#
1717
# Link step for the ChakraCore shared library
1818
#
19-
# This requires that the library have no undefined
20-
# symbols after linking
21-
# Chakra.Jsrt and Chakra.Jsrt.Core have their archives
22-
# imported wholesale since all functions used in these
23-
# libraries are considered to be used by Chakra
24-
#
2519
# External libraries we link with are the following:
2620
# pthread: For threading
2721
# stdc++/gcc_s: C++ runtime code
2822
# dl: For shared library loading related functions
2923
# icuuc: For the ICU (xplat-todo: Make this optional)
3024
#
3125
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
32-
set(lib_target
33-
-Wl,--no-undefined
26+
set(LINKER_START_GROUP
3427
-Wl,--start-group
3528
-Wl,--whole-archive
36-
Chakra.Jsrt
37-
Chakra.Jsrt.Core
38-
-Wl,--no-whole-archive
39-
Chakra.Pal
40-
)
41-
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
42-
set(lib_target
43-
-Wl,-undefined,error
44-
Chakra.Jsrt
45-
Chakra.Jsrt.Core
46-
Chakra.Pal
4729
)
48-
else()
49-
message("This platform is not yet supported")
50-
endif() # Linux ?
5130

52-
# make sure to include Common.Core before others
53-
# this will help linker on some platforms for correct
54-
# initialization order
55-
set(lib_target "${lib_target}"
56-
Chakra.Common.Core
57-
)
31+
set(LINKER_END_GROUP
32+
-Wl,--no-whole-archive
33+
-Wl,--end-group
34+
)
35+
endif()
5836

5937
# common link deps
6038
set(lib_target "${lib_target}"
61-
Chakra.Runtime.Types
62-
Chakra.Runtime.Math
63-
Chakra.Runtime.Library
64-
Chakra.Runtime.Language
65-
Chakra.Runtime.Debug
66-
Chakra.Runtime.ByteCode
67-
Chakra.Runtime.PlatformAgnostic
68-
Chakra.Runtime.Base
69-
Chakra.Parser
70-
Chakra.Common.Util
71-
Chakra.Common.Memory
72-
Chakra.Common.Common
73-
Chakra.Common.DataStructures
74-
Chakra.Common.Exceptions
75-
Chakra.Common.Codex
39+
-Wl,-undefined,error
40+
${LINKER_START_GROUP}
41+
Chakra.Pal
42+
Chakra.Common.Core
43+
Chakra.Jsrt
44+
${LINKER_END_GROUP}
45+
pthread
46+
stdc++
47+
dl
7648
)
7749

7850
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
7951
set(lib_target "${lib_target}"
80-
-Wl,--end-group
81-
pthread
82-
stdc++
83-
dl
8452
icuuc
8553
)
8654
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
8755
set(lib_target "${lib_target}"
88-
pthread
89-
stdc++
90-
dl
9156
icucore
9257
)
9358
endif() # Linux ?

bin/GCStress/CMakeLists.txt

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ add_executable (GCStress
33
RecyclerTestObject.cpp
44
stdafx.cpp
55
StubExternalApi.cpp
6-
)
6+
)
77

88
include_directories(..)
99

@@ -13,46 +13,19 @@ target_include_directories (GCStress
1313
$<BUILD_INTERFACE:${ROOT_SOURCE_DIR}/lib/Common/Memory>
1414
)
1515

16-
set(LINK_FLAGS ${LINK_FLAGS} "-Wl,-whole-archive")
17-
1816
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
19-
set(lib_target
20-
-Wl,--no-undefined
21-
-Wl,--start-group
22-
)
23-
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
24-
set(lib_target
25-
-Wl,-undefined,error
26-
)
27-
else()
28-
message("This platform is not yet supported")
29-
endif() # Linux ?
30-
31-
# make sure to include Common.Core before others
32-
# this will help linker on some platforms for correct
33-
# initialization order
34-
set(lib_target "${lib_target}"
35-
Chakra.Common.Core
36-
)
17+
set(LINKER_START_GROUP -Wl,--start-group)
18+
set(LINKER_END_GROUP -Wl,--end-group)
19+
endif()
3720

3821
# common link deps
3922
set(lib_target "${lib_target}"
40-
Chakra.Common.Memory
41-
Chakra.Runtime.PlatformAgnostic
42-
Chakra.Common.Common
43-
Chakra.Common.DataStructures
44-
Chakra.Common.Exceptions
23+
-Wl,-undefined,error
24+
${LINKER_START_GROUP}
25+
Chakra.Common.Core
26+
Chakra.Pal
27+
Chakra.Jsrt
28+
${LINKER_END_GROUP}
4529
)
4630

47-
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
48-
set(lib_target "${lib_target}"
49-
-Wl,--end-group
50-
Chakra.Pal
51-
)
52-
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
53-
set(lib_target "${lib_target}"
54-
Chakra.Pal
55-
)
56-
endif() # Linux ?
57-
5831
target_link_libraries (GCStress ${lib_target})

bin/ch/CMakeLists.txt

Lines changed: 29 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ target_include_directories (ch
2828
../ChakraCore
2929
../../lib/Common
3030
../../lib/Jsrt
31+
../../lib/Runtime
32+
../../lib/Parser
3133
)
3234

3335
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE")
@@ -38,73 +40,40 @@ endif()
3840

3941
if(STATIC_LIBRARY)
4042
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
41-
set(lib_target
42-
-Wl,--no-undefined
43-
-Wl,--start-group
44-
-Wl,--whole-archive
45-
Chakra.Jsrt
46-
Chakra.Jsrt.Core
47-
-Wl,--no-whole-archive
48-
Chakra.Pal
49-
)
50-
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
51-
set(lib_target
52-
-Wl,-undefined,error
53-
Chakra.Jsrt
54-
Chakra.Jsrt.Core
55-
Chakra.Pal
56-
)
57-
else()
58-
message("This platform is not yet supported")
59-
endif() # Linux ?
60-
61-
# make sure to include Common.Core before others
62-
# this will help linker on some platforms for correct
63-
# initialization order
64-
set(lib_target "${lib_target}"
65-
Chakra.Common.Core
66-
)
43+
set(LINKER_START_GROUP -Wl,--start-group)
44+
set(LINKER_END_GROUP -Wl,--end-group)
45+
endif()
6746

6847
# common link deps
6948
set(lib_target "${lib_target}"
70-
Chakra.Runtime.Types
71-
Chakra.Runtime.Math
72-
Chakra.Runtime.Library
73-
Chakra.Runtime.Language
74-
Chakra.Runtime.Debug
75-
Chakra.Runtime.ByteCode
76-
Chakra.Runtime.PlatformAgnostic
77-
Chakra.Runtime.Base
78-
Chakra.Parser
79-
Chakra.Common.Util
80-
Chakra.Common.Memory
81-
Chakra.Common.Common
82-
Chakra.Common.DataStructures
83-
Chakra.Common.Exceptions
84-
Chakra.Common.Codex
85-
)
49+
-Wl,-undefined,error
50+
${LINKER_START_GROUP}
51+
Chakra.Pal
52+
Chakra.Common.Core
53+
Chakra.Jsrt
54+
${LINKER_END_GROUP}
55+
pthread
56+
stdc++
57+
dl
58+
)
8659

87-
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
88-
set(lib_target "${lib_target}"
89-
-Wl,--end-group
90-
pthread
91-
stdc++
92-
dl
93-
icuuc
94-
)
95-
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
96-
set(lib_target "${lib_target}"
97-
pthread
98-
stdc++
99-
dl
100-
icucore
101-
)
102-
endif() # Linux ?
60+
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
61+
set(lib_target "${lib_target}"
62+
icuuc
63+
unwind-x86_64
64+
)
65+
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
66+
set(lib_target "${lib_target}"
67+
icucore
68+
"-framework CoreFoundation"
69+
"-framework Security"
70+
)
71+
endif() # Linux ?
10372
else() # // !from shared library
10473
set(lib_target
10574
PRIVATE Chakra.Pal
106-
PRIVATE Chakra.Common.Codex
107-
PRIVATE Chakra.Runtime.PlatformAgnostic
75+
PRIVATE Chakra.Common.Codex.Singular
76+
PRIVATE Chakra.Runtime.PlatformAgnostic.Singular
10877
)
10978
endif()
11079

bin/ch/ch.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,6 @@
44
//-------------------------------------------------------------------------------------------------------
55
#include "stdafx.h"
66
#include "Core/AtomLockGuids.h"
7-
#ifdef CHAKRA_STATIC_LIBRARY
8-
#include "Runtime.h"
9-
#include "Core/ConfigParser.h"
10-
#include "Base/ThreadContextTlsEntry.h"
11-
#include "Base/ThreadBoundThreadContextManager.h"
12-
#ifdef DYNAMIC_PROFILE_STORAGE
13-
#include "Language/DynamicProfileStorage.h"
14-
#endif
15-
#include "JsrtContext.h"
16-
#include "../ChakraCore/TestHooks.h"
17-
18-
void ChakraBinaryAutoSystemInfoInit(AutoSystemInfo * autoSystemInfo)
19-
{
20-
autoSystemInfo->buildDateHash = JsUtil::CharacterBuffer<char>::StaticGetHashCode(__DATE__, _countof(__DATE__));
21-
autoSystemInfo->buildTimeHash = JsUtil::CharacterBuffer<char>::StaticGetHashCode(__TIME__, _countof(__TIME__));
22-
}
23-
24-
bool ConfigParserAPI::FillConsoleTitle(__ecount(cchBufferSize) LPWSTR buffer, size_t cchBufferSize, __in LPWSTR moduleName)
25-
{
26-
return false;
27-
}
28-
29-
void ConfigParserAPI::DisplayInitialOutput(__in LPWSTR moduleName)
30-
{
31-
}
32-
33-
LPCWSTR JsUtil::ExternalApi::GetFeatureKeyName()
34-
{
35-
return _u("");
36-
}
37-
#endif
387

398
unsigned int MessageBase::s_messageCount = 0;
409
Debugger* Debugger::debugger = nullptr;

lib/Common/Codex/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
add_library (Chakra.Common.Codex STATIC
1+
if(NOT STATIC_LIBRARY)
2+
# CH has a direct dependency to this project
3+
add_library (Chakra.Common.Codex.Singular STATIC
4+
Utf8Codex.cpp)
5+
target_include_directories (
6+
Chakra.Common.Codex.Singular PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
7+
endif()
8+
add_library (Chakra.Common.Codex OBJECT
29
Utf8Codex.cpp)
310

411
target_include_directories (

lib/Common/Common/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_library (Chakra.Common.Common STATIC
1+
add_library (Chakra.Common.Common OBJECT
22
Api.cpp
33
CfgLogger.cpp
44
CommonCommonPch.cpp

lib/Common/DataStructures/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_library (Chakra.Common.DataStructures STATIC
1+
add_library (Chakra.Common.DataStructures OBJECT
22
BigInt.cpp
33
BufferBuilder.cpp
44
CommonDataStructuresPch.cpp

lib/Common/Exceptions/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_library (Chakra.Common.Exceptions STATIC
1+
add_library (Chakra.Common.Exceptions OBJECT
22
# CommonExceptionsPch.cpp
33
ExceptionCheck.cpp
44
ExceptionBase.cpp

lib/Common/Memory/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_library (Chakra.Common.Memory STATIC
1+
add_library (Chakra.Common.Memory OBJECT
22
# xplat-todo: Include platform\XDataAllocator.cpp
33
# Needed on windows, need a replacement for linux to do
44
# amd64 stack walking

lib/Common/Util/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_library (Chakra.Common.Util STATIC
1+
add_library (Chakra.Common.Util OBJECT
22
Pinned.cpp)
33

44
target_include_directories (

0 commit comments

Comments
 (0)