Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially enable build with GCC: PAL and WABT #6611

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 50 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
cmake_minimum_required(VERSION 3.2)
project (CHAKRACORE)

if (CMAKE_C_COMPILER_ID MATCHES "Clang")
set(COMPILER_IS_CLANG 1)
set(COMPILER_IS_GNU 0)
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(COMPILER_IS_CLANG 0)
set(COMPILER_IS_GNU 1)
else ()
set(COMPILER_IS_CLANG 0)
set(COMPILER_IS_GNU 0)
endif ()

set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")

# Disable expected CMake workflow
Expand Down Expand Up @@ -355,32 +366,42 @@ if(CLR_CMAKE_PLATFORM_XPLAT)
# CXX WARNING FLAGS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-ignored-attributes\
-Wno-parentheses-equality\
-Wno-reorder\
-Wno-microsoft\
-Wno-unused-value\
-Wno-int-to-void-pointer-cast\
-Wno-invalid-offsetof\
-Wno-undefined-inline\
-Wno-inconsistent-missing-override\
-Wno-c++14-extensions\
-Wno-macro-redefined\
-Wno-pragmas\
-Wno-invalid-token-paste\
-Wno-format\
-Wno-invalid-noreturn\
-Wno-null-arithmetic\
-Wno-tautological-constant-out-of-range-compare\
-Wno-tautological-undefined-compare\
-Wno-address-of-temporary\
-Wno-null-conversion\
-Wno-return-type\
-Wno-switch\
-Wno-int-to-pointer-cast\
-Wno-tautological-constant-compare\
-Wno-enum-compare-switch\
-Wno-unknown-warning-option"
-Wno-int-to-pointer-cast"
)

if (COMPILER_IS_CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-address-of-temporary\
-Wno-c++14-extensions\
-Wno-enum-compare-switch\
-Wno-inconsistent-missing-override\
-Wno-int-to-void-pointer-cast\
-Wno-invalid-noreturn\
-Wno-invalid-token-paste\
-Wno-macro-redefined\
-Wno-microsoft\
-Wno-null-conversion\
-Wno-null-arithmetic\
-Wno-parentheses-equality\
-Wno-tautological-constant-compare\
-Wno-tautological-constant-out-of-range-compare\
-Wno-tautological-undefined-compare\
-Wno-undefined-inline\
-Wno-unknown-warning-option"
)
elseif(COMPILER_IS_GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-conversion-null"
)
endif()

# notes..
# -Wno-address-of-temporary # vtinfo.h, VirtualTableInfo<T>::RegisterVirtualTable
# -Wno-null-conversion # Check shmemory.cpp and cs.cpp here...
Expand All @@ -395,17 +416,23 @@ if(CLR_CMAKE_PLATFORM_XPLAT)
# -Wno-unknown-warning-option ... well, some of the new switches are not
# recognized by older compilers and they fail. So, put this one and not fail



include(Build/CMakeFeatureDetect.cmake)

# CXX / CC COMPILER FLAGS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${CXX_DO_NOT_OPTIMIZE_SIBLING_CALLS} \
-fno-omit-frame-pointer \
-fdelayed-template-parsing"
)
-fno-omit-frame-pointer"
)

if (COMPILER_IS_CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-fdelayed-template-parsing \
-fasm-blocks")
endif()

# CXX / CC COMPILER FLAGS
add_compile_options(
-fasm-blocks
-fms-extensions
-fwrapv # Treat signed integer overflow as two's complement
)
Expand Down
4 changes: 2 additions & 2 deletions lib/Backend/JnHelperMethodList.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#endif

#define HELPERCALL_MATH(Name, Address, Attributes) \
HELPERCALLCHK(Name##, Address##, Attributes)
HELPERCALLCHK(Name, Address, Attributes)

#define HELPERCALL_FULL_OR_INPLACE_MATH(Name, Address, Attributes) \
HELPERCALLCHK(Name##, Address##, Attributes) \
HELPERCALLCHK(Name, Address, Attributes) \
HELPERCALLCHK(Name##_Full, Address##_Full, Attributes) \
HELPERCALLCHK(Name##InPlace, Address##_InPlace, Attributes)

Expand Down
3 changes: 2 additions & 1 deletion lib/Common/Common/MathUtil.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "CommonCommonPch.h"
Expand Down Expand Up @@ -32,7 +33,7 @@ Math::Rand()
return newRand;
}

__declspec(noreturn) void Math::DefaultOverflowPolicy()
DECLSPEC_NORETURN void Math::DefaultOverflowPolicy()
{
Js::Throw::OutOfMemory();
}
3 changes: 2 additions & 1 deletion lib/Common/Common/MathUtil.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand Down Expand Up @@ -72,7 +73,7 @@ class Math
// Define a couple of overflow policies for the UInt32Math routines.

// The default policy for overflow is to throw an OutOfMemory exception
__declspec(noreturn) static void DefaultOverflowPolicy();
DECLSPEC_NORETURN static void DefaultOverflowPolicy();

// A functor (class with operator()) which records whether a the calculation
// encountered an overflow condition.
Expand Down
23 changes: 12 additions & 11 deletions lib/Common/Exceptions/Throw.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand All @@ -15,20 +16,20 @@ namespace Js {
class Throw
{
public:
static void __declspec(noreturn) OutOfMemory();
static void __declspec(noreturn) StackOverflow(ScriptContext *scriptContext, PVOID returnAddress);
static void __declspec(noreturn) NotImplemented();
static void __declspec(noreturn) InternalError();
static void __declspec(noreturn) FatalInternalError(HRESULT hr = E_FAIL);
static void __declspec(noreturn) FatalInternalErrorEx(int scenario);
static void __declspec(noreturn) FatalInternalGlobalizationError();

static void __declspec(noreturn) FatalProjectionError();
static void DECLSPEC_NORETURN OutOfMemory();
static void DECLSPEC_NORETURN StackOverflow(ScriptContext *scriptContext, PVOID returnAddress);
static void DECLSPEC_NORETURN NotImplemented();
static void DECLSPEC_NORETURN InternalError();
static void DECLSPEC_NORETURN FatalInternalError(HRESULT hr = E_FAIL);
static void DECLSPEC_NORETURN FatalInternalErrorEx(int scenario);
static void DECLSPEC_NORETURN FatalInternalGlobalizationError();

static void DECLSPEC_NORETURN FatalProjectionError();
#if ENABLE_JS_REENTRANCY_CHECK
static void __declspec(noreturn) FatalJsReentrancyError();
static void DECLSPEC_NORETURN FatalJsReentrancyError();
#endif
#ifdef ENABLE_JS_BUILTINS
static void __declspec(noreturn) FatalJsBuiltInError();
static void DECLSPEC_NORETURN FatalJsBuiltInError();
#endif

#if !defined(_M_IX86) && defined(_WIN32)
Expand Down
3 changes: 2 additions & 1 deletion lib/Parser/Hash.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "ParserPch.h"
Expand Down Expand Up @@ -425,7 +426,7 @@ bool HashTbl::Contains(_In_reads_(cch) LPCOLESTR prgch, int32 cch)
#include "HashFunc.cpp"


__declspec(noreturn) void HashTbl::OutOfMemory()
DECLSPEC_NORETURN void HashTbl::OutOfMemory()
{
throw ParseExceptionObject(ERRnoMemory);
}
3 changes: 2 additions & 1 deletion lib/Parser/Hash.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand Down Expand Up @@ -474,7 +475,7 @@ class HashTbl
static const KWD * KwdOfTok(tokens tk)
{ return (unsigned int)tk < tkLimKwd ? g_mptkkwd + tk : nullptr; }

static __declspec(noreturn) void OutOfMemory();
static DECLSPEC_NORETURN void OutOfMemory();
#if PROFILE_DICTIONARY
DictionaryStats *stats;
#endif
Expand Down
9 changes: 5 additions & 4 deletions lib/Parser/Parse.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand Down Expand Up @@ -315,11 +316,11 @@ class Parser
HashTbl * GetHashTbl() { return this->GetScanner()->GetHashTbl(); }

LPCWSTR GetTokenString(tokens token);
__declspec(noreturn) void Error(HRESULT hr, LPCWSTR stringOne = _u(""), LPCWSTR stringTwo = _u(""));
DECLSPEC_NORETURN void Error(HRESULT hr, LPCWSTR stringOne = _u(""), LPCWSTR stringTwo = _u(""));
private:
__declspec(noreturn) void Error(HRESULT hr, ParseNodePtr pnode);
__declspec(noreturn) void Error(HRESULT hr, charcount_t ichMin, charcount_t ichLim, LPCWSTR stringOne = _u(""), LPCWSTR stringTwo = _u(""));
__declspec(noreturn) static void OutOfMemory();
DECLSPEC_NORETURN void Error(HRESULT hr, ParseNodePtr pnode);
DECLSPEC_NORETURN void Error(HRESULT hr, charcount_t ichMin, charcount_t ichLim, LPCWSTR stringOne = _u(""), LPCWSTR stringTwo = _u(""));
DECLSPEC_NORETURN static void OutOfMemory();

void EnsureStackAvailable();

Expand Down
3 changes: 2 additions & 1 deletion lib/Parser/Scan.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand Down Expand Up @@ -774,7 +775,7 @@ class Scanner : public IScanner, public EncodingPolicy
return m_ptoken->tk = tkScanError;
}

__declspec(noreturn) void Error(HRESULT hr)
DECLSPEC_NORETURN void Error(HRESULT hr)
{
m_pchMinTok = m_currentCharacter;
m_cMinTokMultiUnits = this->m_cMultiUnits;
Expand Down
3 changes: 2 additions & 1 deletion lib/Runtime/Base/ScriptContext.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand Down Expand Up @@ -1385,7 +1386,7 @@ namespace Js
bool HasRecordedException() const { return threadContext->GetRecordedException() != nullptr; }
Js::JavascriptExceptionObject * GetAndClearRecordedException(bool *considerPassingToDebugger = nullptr);
void RecordException(Js::JavascriptExceptionObject * exceptionObject, bool propagateToDebugger = false);
__declspec(noreturn) void RethrowRecordedException(JavascriptExceptionObject::HostWrapperCreateFuncType hostWrapperCreateFunc);
DECLSPEC_NORETURN void RethrowRecordedException(JavascriptExceptionObject::HostWrapperCreateFuncType hostWrapperCreateFunc);

#if ENABLE_NATIVE_CODEGEN
BOOL IsNativeAddress(void * codeAddr);
Expand Down
2 changes: 1 addition & 1 deletion lib/Runtime/Debug/TTSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace TTD
class TTDebuggerSourceLocation;
}

void _NOINLINE __declspec(noreturn) TTDAbort_unrecoverable_error(const char* msg);
void _NOINLINE DECLSPEC_NORETURN TTDAbort_unrecoverable_error(const char* msg);

////////
//Memory allocators used by the TT code
Expand Down
3 changes: 2 additions & 1 deletion lib/Runtime/Language/JavascriptExceptionOperators.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "RuntimeLanguagePch.h"
Expand Down Expand Up @@ -996,7 +997,7 @@ namespace Js
}
#endif

void __declspec(noreturn) JavascriptExceptionOperators::OP_Throw(Var object, ScriptContext* scriptContext)
void DECLSPEC_NORETURN JavascriptExceptionOperators::OP_Throw(Var object, ScriptContext* scriptContext)
{
Throw(object, scriptContext);
}
Expand Down
17 changes: 9 additions & 8 deletions lib/Runtime/Language/JavascriptExceptionOperators.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand Down Expand Up @@ -75,13 +76,13 @@ namespace Js
~PendingFinallyExceptionStack();
};

static void __declspec(noreturn) OP_Throw(Var object, ScriptContext* scriptContext);
static void __declspec(noreturn) Throw(Var object, ScriptContext* scriptContext);
static void __declspec(noreturn) ThrowExceptionObject(Js::JavascriptExceptionObject* exceptionObject, ScriptContext* scriptContext, bool considerPassingToDebugger = false, PVOID returnAddress = NULL, bool resetStack = false);
static void __declspec(noreturn) RethrowExceptionObject(Js::JavascriptExceptionObject* exceptionObject, ScriptContext* scriptContext, bool considerPassingToDebugger = false);
static void DECLSPEC_NORETURN OP_Throw(Var object, ScriptContext* scriptContext);
static void DECLSPEC_NORETURN Throw(Var object, ScriptContext* scriptContext);
static void DECLSPEC_NORETURN ThrowExceptionObject(Js::JavascriptExceptionObject* exceptionObject, ScriptContext* scriptContext, bool considerPassingToDebugger = false, PVOID returnAddress = NULL, bool resetStack = false);
static void DECLSPEC_NORETURN RethrowExceptionObject(Js::JavascriptExceptionObject* exceptionObject, ScriptContext* scriptContext, bool considerPassingToDebugger = false);

static void __declspec(noreturn) DoThrow(JavascriptExceptionObject* exceptionObject, ScriptContext* scriptContext);
static void __declspec(noreturn) DoThrowCheckClone(JavascriptExceptionObject* exceptionObject, ScriptContext* scriptContext);
static void DECLSPEC_NORETURN DoThrow(JavascriptExceptionObject* exceptionObject, ScriptContext* scriptContext);
static void DECLSPEC_NORETURN DoThrowCheckClone(JavascriptExceptionObject* exceptionObject, ScriptContext* scriptContext);

#ifdef _M_X64
static void *OP_TryCatch(void *try_, void *catch_, void *frame, size_t spillSize, size_t argsSize, int hasBailedOutOffset, ScriptContext *scriptContext);
Expand All @@ -105,8 +106,8 @@ namespace Js
static Var OP_RuntimeRangeError(MessageId messageId, ScriptContext* scriptContext);
static Var OP_RuntimeReferenceError(MessageId messageId, ScriptContext* scriptContext);
static Var OP_WebAssemblyRuntimeError(MessageId messageId, ScriptContext* scriptContext);
static void __declspec(noreturn) ThrowOutOfMemory(ScriptContext* scriptContext);
static void __declspec(noreturn) ThrowStackOverflow(ScriptContext* scriptContext, PVOID returnAddress);
static void DECLSPEC_NORETURN ThrowOutOfMemory(ScriptContext* scriptContext);
static void DECLSPEC_NORETURN ThrowStackOverflow(ScriptContext* scriptContext, PVOID returnAddress);

static uint64 GetStackTraceLimit(Var thrownObject, ScriptContext* scriptContext);
static Var ThrowTypeErrorRestrictedPropertyAccessor(RecyclableObject* function, CallInfo callInfo, ...);
Expand Down
3 changes: 2 additions & 1 deletion lib/Runtime/Library/JSONScanner.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand All @@ -24,7 +25,7 @@ namespace JSON
uint GetCurrentStringLen() { return currentIndex; }
uint GetScanPosition() { return uint(currentChar - inputText); }

void __declspec(noreturn) ThrowSyntaxError(int wErr)
void DECLSPEC_NORETURN ThrowSyntaxError(int wErr)
{
char16 scanPos[16];
::_itow_s(GetScanPosition(), scanPos, _countof(scanPos), 10);
Expand Down
Loading