Skip to content

Commit

Permalink
[MERGE #2637 @obastemur] xplat: fix lto.gold segfault debian
Browse files Browse the repository at this point in the history
Merge pull request #2637 from obastemur:fix_seg_deb
  • Loading branch information
obastemur committed Mar 8, 2017
2 parents b9dd2d5 + dccac4e commit 95dde93
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,14 @@ endif(CLR_CMAKE_PLATFORM_XPLAT)

if (ENABLE_FULL_LTO_SH OR ENABLE_THIN_LTO_SH)
if (CC_TARGET_OS_LINUX)
set(CC_LTO_ENABLED
-fuse-ld=gold
-Xlinker -plugin=${CHAKRACORE_BINARY_DIR}/../../cc-toolchain/build/lib/LLVMgold.so
)
set(CC_LTO_ENABLED -use-gold-plugin)
set(CC_LTO_ENABLED_C -c)
endif()

if (ENABLE_FULL_LTO_SH)
unset(DENABLE_FULL_LTO_SH CACHE)
add_compile_options(-flto)
add_compile_options(-flto ${CC_LTO_ENABLED_C})

if (CC_LTO_ENABLED)
set(CC_LTO_ENABLED "${CC_LTO_ENABLED} -flto")
endif()
Expand Down
11 changes: 6 additions & 5 deletions bin/ChakraCore/TestHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@ void __stdcall NotifyUnhandledException(PEXCEPTION_POINTERS exceptionInfo)
#undef FLAG_NumberPairSet
#undef FLAG_NumberRange

HRESULT OnChakraCoreLoaded()
HRESULT OnChakraCoreLoaded(OnChakraCoreLoadedPtr pfChakraCoreLoaded)
{
typedef HRESULT(__stdcall *OnChakraCoreLoadedPtr)(TestHooks &testHooks);
OnChakraCoreLoadedPtr pfChakraCoreLoaded = (OnChakraCoreLoadedPtr)GetProcAddress(GetModuleHandle(NULL), "OnChakraCoreLoadedEntry");
if (pfChakraCoreLoaded == nullptr)
{
return S_OK;
pfChakraCoreLoaded = (OnChakraCoreLoadedPtr)GetProcAddress(GetModuleHandle(NULL), "OnChakraCoreLoadedEntry");
if (pfChakraCoreLoaded == nullptr)
{
return S_OK;
}
}

TestHooks testHooks =
Expand Down Expand Up @@ -167,7 +169,6 @@ HRESULT OnChakraCoreLoaded()
#endif
NotifyUnhandledException
};

return pfChakraCoreLoaded(testHooks);
}

Expand Down
4 changes: 3 additions & 1 deletion bin/ChakraCore/TestHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#ifdef ENABLE_TEST_HOOKS

HRESULT OnChakraCoreLoaded();
interface ICustomConfigFlags;

#if defined(_WIN32) || defined(_MSC_VER)
Expand Down Expand Up @@ -66,4 +65,7 @@ struct TestHooks
NotifyUnhandledExceptionPtr pfnNotifyUnhandledException;
};

typedef HRESULT(__stdcall *OnChakraCoreLoadedPtr)(TestHooks &testHooks);
HRESULT OnChakraCoreLoaded(OnChakraCoreLoadedPtr pfChakraCoreLoaded = NULL);

#endif
2 changes: 1 addition & 1 deletion bin/ch/ch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ int _cdecl wmain(int argc, __in_ecount(argc) LPWSTR argv[])

#if defined(CHAKRA_STATIC_LIBRARY) && !defined(NDEBUG)
// handle command line flags
OnChakraCoreLoaded();
OnChakraCoreLoaded(OnChakraCoreLoadedEntry);
#endif

if (argInfo.filename == nullptr)
Expand Down
1 change: 1 addition & 0 deletions bin/ch/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,4 @@ inline JsErrorCode CreatePropertyIdFromString(const char* str, JsPropertyIdRef *

void GetBinaryLocation(char *path, const unsigned size);
void GetBinaryPathWithFileNameA(char *path, const size_t buffer_size, const char* filename);
extern "C" HRESULT __stdcall OnChakraCoreLoadedEntry(TestHooks& testHooks);
6 changes: 4 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ WB_CHECK=
WB_ANALYZE=
WB_ARGS=
TARGET_PATH=0
# -DCMAKE_EXPORT_COMPILE_COMMANDS=ON useful for clang-query tool
CMAKE_EXPORT_COMPILE_COMMANDS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"

if [ -f "/proc/version" ]; then
OS_LINUX=1
Expand Down Expand Up @@ -232,6 +234,7 @@ while [[ $# -gt 0 ]]; do

--xcode)
CMAKE_GEN="-G Xcode -DCC_XCODE_PROJECT=1"
CMAKE_EXPORT_COMPILE_COMMANDS=""
MAKE=0
;;

Expand Down Expand Up @@ -484,9 +487,8 @@ fi
echo Generating $BUILD_TYPE makefiles
cmake $CMAKE_GEN $CC_PREFIX $ICU_PATH $LTO $STATIC_LIBRARY $ARCH $TARGET_OS \
$ENABLE_CC_XPLAT_TRACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE $SANITIZE $NO_JIT \
$WITHOUT_FEATURES $WB_FLAG $WB_ARGS -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
$WITHOUT_FEATURES $WB_FLAG $WB_ARGS $CMAKE_EXPORT_COMPILE_COMMANDS \
../..
# -DCMAKE_EXPORT_COMPILE_COMMANDS=ON useful for clang-query tool

_RET=$?
if [[ $? == 0 ]]; then
Expand Down
21 changes: 10 additions & 11 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,22 @@ else()
endif()

target_link_libraries(ChakraCoreStatic
${CC_LTO_ENABLED}
${PTHREAD}
"dl"
)
endif()

target_include_directories (
ChakraCoreStatic PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CHAKRACORE_SOURCE_DIR}/lib/Backend
${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
${wasm_includes}
)
ChakraCoreStatic PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CHAKRACORE_SOURCE_DIR}/lib/Backend
${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
${wasm_includes}
)

if(BuildJIT)
add_subdirectory (Backend)
Expand Down
1 change: 0 additions & 1 deletion pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,5 @@ if (NOT STATIC_LIBRARY)
target_link_libraries(Chakra.Pal.Singular
${PTHREAD}
dl
${CC_LTO_ENABLED}
)
endif()

0 comments on commit 95dde93

Please sign in to comment.