Skip to content

Commit 3b3aa9b

Browse files
ppenzinrhuanjl
authored andcommitted
Fix Clang 10 and Ubuntu 20.04 compatibility errors
Drive by cleanup - build all wabt files in the build directory. Disambiguate template parameter names. Overloading a template parameter by a declaration (including in parameters to nested templates) is treated as an error by Clang 10. PAL math and memory API clean up (also for chakra-core#6404). Remove PAL redefintions of system functions with incompatible exception declarations. Remove externally visible redifinitions of math and memory management functions. Delete corresponding math function implementations, as they pretty much call their system counterparts. Hide memory management functions, since they are still used from inside of PAL. [CI] Use Ubuntu 20.04 image for default Linux builds. Change default Linux image to Ubuntu 20.04. Add two extra build jobs for Ubuntu 18.04. Closes chakra-core#6600
1 parent 47d31de commit 3b3aa9b

19 files changed

Lines changed: 76 additions & 294 deletions

azure-pipelines.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,30 @@ jobs:
3333
maxParallel: 6
3434
matrix:
3535
Linux.Debug:
36-
image_name: 'ubuntu-18.04'
36+
image_name: 'ubuntu-20.04'
3737
deps: 'sudo apt-get install -y ninja-build clang libicu-dev'
3838
build_type: 'Debug'
3939
do_test: true
4040
libtype_flag: ''
4141
Linux.ReleaseWithDebug:
42-
image_name: 'ubuntu-18.04'
42+
image_name: 'ubuntu-20.04'
4343
deps: 'sudo apt-get install -y ninja-build clang libicu-dev'
4444
build_type: 'RelWithDebInfo'
4545
do_test: true
4646
libtype_flag: ''
4747
Linux.Release:
48+
image_name: 'ubuntu-20.04'
49+
deps: 'sudo apt-get install -y ninja-build clang libicu-dev'
50+
build_type: 'Release'
51+
do_test: false
52+
libtype_flag: ''
53+
Ubuntu18.Debug:
54+
image_name: 'ubuntu-18.04'
55+
deps: 'sudo apt-get install -y ninja-build clang libicu-dev'
56+
build_type: 'Debug'
57+
do_test: true
58+
libtype_flag: ''
59+
Ubuntu18.Release:
4860
image_name: 'ubuntu-18.04'
4961
deps: 'sudo apt-get install -y ninja-build clang libicu-dev'
5062
build_type: 'Release'

bin/ch/MessageQueue.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -28,15 +29,15 @@ class MessageBase
2829
template <typename T>
2930
class SortedList
3031
{
31-
template <typename T>
32+
template <typename U>
3233
struct DListNode
3334
{
34-
T data;
35-
DListNode<T>* prev;
36-
DListNode<T>* next;
35+
U data;
36+
DListNode<U>* prev;
37+
DListNode<U>* next;
3738

3839
public:
39-
DListNode(const T& data) :
40+
DListNode(const U& data) :
4041
data(data),
4142
prev(nullptr),
4243
next(nullptr)

lib/Common/DataStructures/Comparer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -176,7 +177,7 @@ struct DefaultComparer<const WCHAR*> : public StringComparer<const WCHAR*> {};
176177
template <typename T, typename TComparer>
177178
struct SpecializedComparer
178179
{
179-
template <typename T> class TComparerType : public TComparer {};
180+
template <typename U> class TComparerType : public TComparer {};
180181
};
181182

182183
namespace regex

lib/Common/DataStructures/List.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -63,10 +64,10 @@ namespace JsUtil
6364
&& memcmp(this->buffer, list->GetBuffer(), sizeof(T)* this->Count()) == 0;
6465
}
6566

66-
template<class TAllocator>
67-
static ReadOnlyList * New(TAllocator* alloc, __in_ecount(count) T* buffer, DECLSPEC_GUARD_OVERFLOW int count)
67+
template<class UAllocator>
68+
static ReadOnlyList * New(UAllocator* alloc, __in_ecount(count) T* buffer, DECLSPEC_GUARD_OVERFLOW int count)
6869
{
69-
return AllocatorNew(TAllocator, alloc, ReadOnlyList, buffer, count, alloc);
70+
return AllocatorNew(UAllocator, alloc, ReadOnlyList, buffer, count, alloc);
7071
}
7172

7273
ReadOnlyList(__in_ecount(count) T* buffer, int count, TAllocator* alloc)
@@ -284,10 +285,10 @@ namespace JsUtil
284285
}
285286
}
286287

287-
template<class T>
288-
void Copy(const T* list)
288+
template<class U>
289+
void Copy(const U* list)
289290
{
290-
CompileAssert(sizeof(TElementType) == sizeof(typename T::TElementType));
291+
CompileAssert(sizeof(TElementType) == sizeof(typename U::TElementType));
291292
if (list->Count() > 0)
292293
{
293294
this->EnsureArray(list->Count());

lib/Common/Memory/HeapBucket.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -22,8 +23,8 @@ class GenericRecyclerVerifyListConsistencyData
2223
bool hasSetupVerifyListConsistencyData;
2324
SmallHeapBlockT<TBlockAttributes> * nextAllocableBlockHead;
2425

25-
template <typename TBlockAttributes>
26-
void SetupVerifyListConsistencyData(SmallHeapBlockT<TBlockAttributes>* block, bool expectFull, bool expectDispose)
26+
template <typename TBlockAttr>
27+
void SetupVerifyListConsistencyData(SmallHeapBlockT<TBlockAttr>* block, bool expectFull, bool expectDispose)
2728
{
2829
this->nextAllocableBlockHead = block;
2930
this->expectFull = expectFull;

lib/Common/Memory/SmallLeafHeapBucket.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
namespace Memory
@@ -10,7 +11,7 @@ class SmallLeafHeapBucketT : public HeapBucketT<SmallLeafHeapBlockT<TBlockAttrib
1011
typedef HeapBucketT<SmallLeafHeapBlockT<TBlockAttributes>> BaseT;
1112
protected:
1213
friend class HeapBucket;
13-
template <class TBlockAttributes>
14+
template <class TBlockAttr>
1415
friend class HeapBucketGroup;
1516

1617
void Sweep(RecyclerSweep& recyclerSweep);

lib/Parser/TextbookBoyerMoore.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
// From Cormen, Leiserson and Rivest, ch 34.
@@ -14,9 +15,9 @@ namespace UnifiedRegex
1415
private:
1516
typedef typename Chars<C>::Char Char;
1617

17-
template <typename C>
18+
template <typename T>
1819
friend class TextbookBoyerMoore;
19-
template <typename C>
20+
template <typename T>
2021
friend class TextbookBoyerMooreWithLinearMap;
2122

2223
public:
@@ -46,7 +47,7 @@ namespace UnifiedRegex
4647
template <typename C>
4748
class TextbookBoyerMooreWithLinearMap : private Chars<C>
4849
{
49-
template <typename C>
50+
template <typename T>
5051
friend struct TextbookBoyerMooreSetup;
5152
typedef typename Chars<C>::Char Char;
5253
private:
@@ -95,7 +96,7 @@ namespace UnifiedRegex
9596
template <typename C>
9697
class TextbookBoyerMoore : private Chars<C>
9798
{
98-
template <typename C>
99+
template <typename T>
99100
friend struct TextbookBoyerMooreSetup;
100101
typedef typename Chars<C>::Char Char;
101102

lib/Parser/pnodewalk.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
67

7-
template <class ResultType, class Context>
8+
template <class _ResultType, class _Context>
89
struct WalkerPolicyBase
910
{
10-
typedef ResultType ResultType;
11-
typedef Context Context;
11+
using ResultType = _ResultType ;
12+
using Context = _Context ;
1213

1314
inline bool ContinueWalk(ResultType) { return true; }
1415
inline ResultType DefaultResult() { return ResultType(); }
@@ -21,11 +22,11 @@ struct WalkerPolicyBase
2122
inline void WalkReference(ParseNode **ppnode, Context context) { }
2223
};
2324

24-
template <class Context>
25-
struct WalkerPolicyBase<bool, Context>
25+
template <class _Context>
26+
struct WalkerPolicyBase<bool, _Context>
2627
{
2728
typedef bool ResultType;
28-
typedef Context Context;
29+
using Context = _Context ;
2930

3031
inline bool ContinueWalk(ResultType) { return true; }
3132
inline bool DefaultResult() { return true; }

lib/Runtime/Base/jitprofiling.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#include "RuntimeBasePch.h"
@@ -8,12 +9,14 @@
89

910
#include "ittnotify_config.h"
1011

12+
#ifdef ITT_PLATFORM
1113
#if ITT_PLATFORM==ITT_PLATFORM_WIN
1214
#include <windows.h>
1315
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
1416
#if ITT_PLATFORM != ITT_PLATFORM_MAC && ITT_PLATFORM != ITT_PLATFORM_FREEBSD
1517
#include <malloc.h>
1618
#endif
19+
#endif
1720
#include <stdlib.h>
1821

1922
#include "jitprofiling.h"

lib/Runtime/Language/EvalMapRecord.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -103,11 +104,11 @@ namespace Js
103104
template <class Key, class Value, class EntryRecord, class TopLevelDictionary, class NestedKey>
104105
class TwoLevelHashDictionary
105106
{
106-
template <class T, class Value>
107+
template <class T, class V>
107108
class AutoRestoreSetInAdd
108109
{
109110
public:
110-
AutoRestoreSetInAdd(T* instance, Value value) :
111+
AutoRestoreSetInAdd(T* instance, V value) :
111112
instance(instance), value(value)
112113
{
113114
instance->SetIsInAdd(value);
@@ -119,7 +120,7 @@ namespace Js
119120

120121
private:
121122
T* instance;
122-
Value value;
123+
V value;
123124
};
124125

125126
public:

0 commit comments

Comments
 (0)