Skip to content

Commit 8d3d7c8

Browse files
committed
[MERGE #2460 @obastemur] xplat: make sure linker doesn't pass gluing sub libs
Merge pull request #2460 from obastemur:fix_glue - remove unused definitions and fix mixing empty object file (context) - make sure sub libs (static) are combined (use an empty object file)
2 parents c599f4f + e98e1b8 commit 8d3d7c8

File tree

16 files changed

+178
-308
lines changed

16 files changed

+178
-308
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
@@ -61,74 +17,66 @@ target_include_directories (
6117
"-fvisibility=hidden"
6218
)
6319

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

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

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

95-
# common link deps
55+
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)
9656
set(lib_target "${lib_target}"
97-
-Wl,-undefined,error
98-
${LINKER_START_GROUP}
99-
ChakraCoreStatic
100-
${LINKER_END_GROUP}
101-
pthread
102-
dl
103-
${ICULIB}
57+
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libChakraCoreLib.version
58+
# reduce link time memory usage
59+
-Xlinker --no-keep-memory
10460
)
105-
106-
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)
107-
set(lib_target "${lib_target}"
108-
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libChakraCoreLib.version
109-
# reduce link time memory usage
110-
-Xlinker --no-keep-memory
111-
)
112-
elseif(CC_TARGET_OS_OSX)
113-
if(CC_TARGETS_X86)
114-
set(lib_target "${lib_target} -arch i386")
115-
elseif(CC_TARGETS_ARM)
116-
set(lib_target "${lib_target} -arch arm")
117-
endif()
61+
elseif(CC_TARGET_OS_OSX)
62+
if(CC_TARGETS_X86)
63+
set(lib_target "${lib_target} -arch i386")
64+
elseif(CC_TARGETS_ARM)
65+
set(lib_target "${lib_target} -arch arm")
11866
endif()
67+
endif()
11968

120-
target_link_libraries (ChakraCore
121-
${lib_target}
122-
${CC_LTO_ENABLED}
123-
)
69+
target_link_libraries (ChakraCore
70+
${lib_target}
71+
${CC_LTO_ENABLED}
72+
)
12473

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

bin/ch/WScriptJsrt.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,10 @@ bool WScriptJsrt::Initialize()
789789
JsValueRef buildValue;
790790
#ifdef _DEBUG
791791
#define BUILD_TYPE_STRING_CH "Debug" // (O0)
792+
#elif defined(ENABLE_DEBUG_CONFIG_OPTIONS)
793+
#define BUILD_TYPE_STRING_CH "Test" // (O3 with debug config options)
792794
#else
793-
#define BUILD_TYPE_STRING_CH "Release" // consider Test is also Release build (O3)
795+
#define BUILD_TYPE_STRING_CH "Release" // (O3)
794796
#endif
795797
IfJsrtErrorFail(ChakraRTInterface::JsCreateString(
796798
BUILD_TYPE_STRING_CH, strlen(BUILD_TYPE_STRING_CH), &buildValue), false);

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)