Skip to content

Commit 8c91291

Browse files
committed
xplat: make sure linker doesn't pass gluing sub libs
- remove unused definitions and fix mixing empty object file (context) - make sure sub libs (static) are combined (use an empty object file)
1 parent a4b51b4 commit 8c91291

File tree

15 files changed

+175
-307
lines changed

15 files changed

+175
-307
lines changed

bin/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ if(NOT CC_TARGET_OS_ANDROID)
33
endif()
44

55
add_subdirectory (ch)
6-
add_subdirectory (ChakraCore)
6+
7+
if (NOT STATIC_LIBRARY)
8+
add_subdirectory (ChakraCore)
9+
endif()

bin/ChakraCore/CMakeLists.txt

Lines changed: 59 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,11 @@
1-
if(BuildJIT)
2-
set(chakra_backend_objects $<TARGET_OBJECTS:Chakra.Backend>)
3-
endif()
4-
5-
if(CC_TARGETS_AMD64)
6-
set(wasm_objects $<TARGET_OBJECTS:Chakra.WasmReader>)
7-
set(wasm_includes ${CHAKRACORE_SOURCE_DIR}/lib/WasmReader)
8-
endif()
9-
10-
add_library (ChakraCoreStatic STATIC
11-
$<TARGET_OBJECTS:Chakra.Pal>
12-
$<TARGET_OBJECTS:Chakra.Common.Core>
13-
$<TARGET_OBJECTS:Chakra.Jsrt>
14-
$<TARGET_OBJECTS:Chakra.Jsrt.Core>
15-
${chakra_backend_objects}
16-
$<TARGET_OBJECTS:Chakra.Common.Common>
17-
$<TARGET_OBJECTS:Chakra.Common.Codex>
18-
$<TARGET_OBJECTS:Chakra.Common.DataStructures>
19-
$<TARGET_OBJECTS:Chakra.Common.Exceptions>
20-
$<TARGET_OBJECTS:Chakra.Common.Memory>
21-
$<TARGET_OBJECTS:Chakra.Common.Util>
22-
$<TARGET_OBJECTS:Chakra.Runtime.Base>
23-
$<TARGET_OBJECTS:Chakra.Runtime.ByteCode>
24-
$<TARGET_OBJECTS:Chakra.Runtime.Debug>
25-
$<TARGET_OBJECTS:Chakra.Runtime.Language>
26-
$<TARGET_OBJECTS:Chakra.Runtime.Library>
27-
$<TARGET_OBJECTS:Chakra.Runtime.Math>
28-
$<TARGET_OBJECTS:Chakra.Runtime.Types>
29-
$<TARGET_OBJECTS:Chakra.Runtime.PlatformAgnostic>
30-
$<TARGET_OBJECTS:Chakra.Parser>
31-
${wasm_objects}
1+
add_library (ChakraCore SHARED
2+
ChakraCoreShared.cpp
3+
ConfigParserExternals.cpp
4+
TestHooks.cpp
325
)
336

34-
if(CC_TARGET_OS_OSX)
35-
target_link_libraries(ChakraCoreStatic
36-
"-framework CoreFoundation"
37-
"-framework Security"
38-
)
39-
else()
40-
if (NOT CC_TARGET_OS_ANDROID)
41-
set(PTHREAD "pthread")
42-
endif()
43-
44-
target_link_libraries(ChakraCoreStatic
45-
${CC_LTO_ENABLED}
46-
${PTHREAD}
47-
"dl"
48-
)
49-
endif()
50-
517
target_include_directories (
52-
ChakraCoreStatic PUBLIC
8+
ChakraCore PUBLIC
539
${CMAKE_CURRENT_SOURCE_DIR}
5410
${CHAKRACORE_SOURCE_DIR}/lib/Backend
5511
${CHAKRACORE_SOURCE_DIR}/lib/Common
@@ -60,74 +16,66 @@ target_include_directories (
6016
${wasm_includes}
6117
)
6218

63-
if (NOT STATIC_LIBRARY)
64-
add_library (ChakraCore SHARED
65-
ChakraCoreShared.cpp
66-
ConfigParserExternals.cpp
67-
TestHooks.cpp
68-
)
19+
#
20+
# Link step for the ChakraCore shared library
21+
#
22+
# External libraries we link with are the following:
23+
# pthread: For threading
24+
# stdc++/gcc_s: C++ runtime code
25+
# dl: For shared library loading related functions
26+
#
27+
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)
28+
set(LINKER_START_GROUP
29+
-fPIC
30+
-Wl,--start-group
31+
-Wl,--whole-archive
32+
)
6933

70-
#
71-
# Link step for the ChakraCore shared library
72-
#
73-
# External libraries we link with are the following:
74-
# pthread: For threading
75-
# stdc++/gcc_s: C++ runtime code
76-
# dl: For shared library loading related functions
77-
#
78-
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)
79-
set(LINKER_START_GROUP
80-
-fPIC
81-
-Wl,--start-group
82-
-Wl,--whole-archive
83-
)
34+
set(LINKER_END_GROUP
35+
-Wl,--no-whole-archive
36+
-Wl,--end-group
37+
-static-libstdc++
38+
)
39+
elseif(CC_TARGET_OS_OSX)
40+
set(LINKER_START_GROUP -Wl,-force_load,)
41+
endif()
8442

85-
set(LINKER_END_GROUP
86-
-Wl,--no-whole-archive
87-
-Wl,--end-group
88-
-static-libstdc++
89-
)
90-
elseif(CC_TARGET_OS_OSX)
91-
set(LINKER_START_GROUP -Wl,-force_load,)
92-
endif()
43+
# common link deps
44+
set(lib_target "${lib_target}"
45+
-Wl,-undefined,error
46+
${LINKER_START_GROUP}
47+
ChakraCoreStatic
48+
${LINKER_END_GROUP}
49+
pthread
50+
dl
51+
${ICULIB}
52+
)
9353

94-
# common link deps
54+
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)
9555
set(lib_target "${lib_target}"
96-
-Wl,-undefined,error
97-
${LINKER_START_GROUP}
98-
ChakraCoreStatic
99-
${LINKER_END_GROUP}
100-
pthread
101-
dl
102-
${ICULIB}
56+
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libChakraCoreLib.version
57+
# reduce link time memory usage
58+
-Xlinker --no-keep-memory
10359
)
104-
105-
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)
106-
set(lib_target "${lib_target}"
107-
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libChakraCoreLib.version
108-
# reduce link time memory usage
109-
-Xlinker --no-keep-memory
110-
)
111-
elseif(CC_TARGET_OS_OSX)
112-
if(CC_TARGETS_X86)
113-
set(lib_target "${lib_target} -arch i386")
114-
elseif(CC_TARGETS_ARM)
115-
set(lib_target "${lib_target} -arch arm")
116-
endif()
60+
elseif(CC_TARGET_OS_OSX)
61+
if(CC_TARGETS_X86)
62+
set(lib_target "${lib_target} -arch i386")
63+
elseif(CC_TARGETS_ARM)
64+
set(lib_target "${lib_target} -arch arm")
11765
endif()
66+
endif()
11867

119-
target_link_libraries (ChakraCore
120-
${lib_target}
121-
${CC_LTO_ENABLED}
122-
)
68+
target_link_libraries (ChakraCore
69+
${lib_target}
70+
${CC_LTO_ENABLED}
71+
)
12372

124-
if(NOT CC_XCODE_PROJECT)
125-
# Post build step to copy the built shared library
126-
# to out/{BUILD_TYPE}/ (or whatever the CMakeBuildDir is)
127-
add_custom_command(TARGET ChakraCore POST_BUILD
128-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
129-
"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCore.${DYN_LIB_EXT}"
130-
${CHAKRACORE_BINARY_DIR}/
131-
)
132-
endif()
73+
if(NOT CC_XCODE_PROJECT)
74+
# Post build step to copy the built shared library
75+
# to out/{BUILD_TYPE}/ (or whatever the CMakeBuildDir is)
76+
add_custom_command(TARGET ChakraCore POST_BUILD
77+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
78+
"${CHAKRACORE_BINARY_DIR}/bin/ChakraCore/libChakraCore.${DYN_LIB_EXT}"
79+
${CHAKRACORE_BINARY_DIR}/
80+
)
13381
endif()

lib/CMakeLists.txt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,68 @@
11
add_compile_options(-fPIC)
22

3+
if(BuildJIT)
4+
set(chakra_backend_objects $<TARGET_OBJECTS:Chakra.Backend>)
5+
endif()
6+
7+
if(CC_TARGETS_AMD64)
8+
set(wasm_objects $<TARGET_OBJECTS:Chakra.WasmReader>)
9+
set(wasm_includes ${CHAKRACORE_SOURCE_DIR}/lib/WasmReader)
10+
endif()
11+
12+
add_library (ChakraCoreStatic STATIC
13+
ChakraCoreStatic.cpp
14+
$<TARGET_OBJECTS:Chakra.Pal>
15+
$<TARGET_OBJECTS:Chakra.Common.Core>
16+
$<TARGET_OBJECTS:Chakra.Jsrt>
17+
$<TARGET_OBJECTS:Chakra.Jsrt.Core>
18+
${chakra_backend_objects}
19+
$<TARGET_OBJECTS:Chakra.Common.Common>
20+
$<TARGET_OBJECTS:Chakra.Common.Codex>
21+
$<TARGET_OBJECTS:Chakra.Common.DataStructures>
22+
$<TARGET_OBJECTS:Chakra.Common.Exceptions>
23+
$<TARGET_OBJECTS:Chakra.Common.Memory>
24+
$<TARGET_OBJECTS:Chakra.Common.Util>
25+
$<TARGET_OBJECTS:Chakra.Runtime.Base>
26+
$<TARGET_OBJECTS:Chakra.Runtime.ByteCode>
27+
$<TARGET_OBJECTS:Chakra.Runtime.Debug>
28+
$<TARGET_OBJECTS:Chakra.Runtime.Language>
29+
$<TARGET_OBJECTS:Chakra.Runtime.Library>
30+
$<TARGET_OBJECTS:Chakra.Runtime.Math>
31+
$<TARGET_OBJECTS:Chakra.Runtime.Types>
32+
$<TARGET_OBJECTS:Chakra.Runtime.PlatformAgnostic>
33+
$<TARGET_OBJECTS:Chakra.Parser>
34+
${wasm_objects}
35+
)
36+
37+
if(CC_TARGET_OS_OSX)
38+
target_link_libraries(ChakraCoreStatic
39+
"-framework CoreFoundation"
40+
"-framework Security"
41+
)
42+
else()
43+
if (NOT CC_TARGET_OS_ANDROID)
44+
set(PTHREAD "pthread")
45+
endif()
46+
47+
target_link_libraries(ChakraCoreStatic
48+
${CC_LTO_ENABLED}
49+
${PTHREAD}
50+
"dl"
51+
)
52+
endif()
53+
54+
target_include_directories (
55+
ChakraCoreStatic PUBLIC
56+
${CMAKE_CURRENT_SOURCE_DIR}
57+
${CHAKRACORE_SOURCE_DIR}/lib/Backend
58+
${CHAKRACORE_SOURCE_DIR}/lib/Common
59+
${CHAKRACORE_SOURCE_DIR}/lib/Runtime
60+
${CHAKRACORE_SOURCE_DIR}/lib/Runtime/ByteCode
61+
${CHAKRACORE_SOURCE_DIR}/lib/Parser
62+
${CHAKRACORE_SOURCE_DIR}/lib/Jsrt
63+
${wasm_includes}
64+
)
65+
366
if(BuildJIT)
467
add_subdirectory (Backend)
568
endif()

lib/ChakraCoreStatic.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
// dummy file for build system to make sure libChakraCoreStatic.a builds.
7+
void EMPTY_FUNCTION()
8+
{
9+
10+
}

pal/inc/pal.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6636,17 +6636,6 @@ VOID
66366636
PALAPI
66376637
PAL_Reenter(PAL_Boundary boundary);
66386638

6639-
// This function needs to be called on a thread when it enters
6640-
// a region of code that depends on this instance of the PAL
6641-
// in the process, and it is unknown whether the current thread
6642-
// is already running in the PAL. Returns TRUE if and only if
6643-
// the thread was not running in the PAL previously. Does not
6644-
// modify LastError.
6645-
PALIMPORT
6646-
BOOL
6647-
PALAPI
6648-
PAL_ReenterForEH(VOID);
6649-
66506639
// This function needs to be called on a thread when it leaves
66516640
// a region of code that depends on this instance of the PAL
66526641
// in the process. Does not modify LastError.

pal/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ if(CC_TARGETS_AMD64 OR CC_TARGETS_X86)
6363
if(CC_TARGET_OS_OSX)
6464
set(PLATFORM_SOURCES ${PLATFORM_SOURCES}
6565
arch/i386/activationhandlerwrapper.S
66-
arch/i386/context.S
6766
arch/i386/dispatchexceptionwrapper.S
6867
)
6968
endif()

pal/src/arch/i386/context.S

Lines changed: 0 additions & 36 deletions
This file was deleted.

pal/src/include/pal/dbgmsg.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ extern Volatile<BOOL> dbg_master_switch ;
245245
#define ERROR_(x) TRACE
246246
#define DBG_PRINTF(level, channel, bHeader) TRACE
247247

248-
#define CHECK_STACK_ALIGN
249-
250248
#define SET_DEFAULT_DEBUG_CHANNEL(x)
251249
#define DBG_ENABLED(level, channel) (false)
252250

@@ -272,23 +270,13 @@ extern Volatile<BOOL> dbg_master_switch ;
272270
#define WARN_(x) \
273271
DBG_PRINTF(DLI_WARN,DCI_##x,TRUE)
274272

275-
#if _DEBUG && defined(__APPLE__) && !defined(__i686__)
276-
bool DBG_ShouldCheckStackAlignment();
277-
#define CHECK_STACK_ALIGN if (DBG_ShouldCheckStackAlignment()) DBG_CheckStackAlignment()
278-
#else
279-
#define CHECK_STACK_ALIGN
280-
#endif
281-
282273
#define ENTRY_EXTERNAL \
283-
CHECK_STACK_ALIGN; \
284274
DBG_PRINTF(DLI_ENTRY, defdbgchan,TRUE)
285275

286276
#define ENTRY \
287-
CHECK_STACK_ALIGN; \
288277
DBG_PRINTF(DLI_ENTRY, defdbgchan,TRUE)
289278

290279
#define ENTRY_(x) \
291-
CHECK_STACK_ALIGN; \
292280
DBG_PRINTF(DLI_ENTRY, DCI_##x,TRUE)
293281

294282
#define LOGEXIT \

0 commit comments

Comments
 (0)