Skip to content

Commit 21976e4

Browse files
authored
build: add support for Clang with Thread Sanitizer. (proxy-wasm#266)
Signed-off-by: Piotr Sikora <[email protected]>
1 parent 5ac4f08 commit 21976e4

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

.bazelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ build:clang-asan-strict --config=clang-asan
3030
build:clang-asan-strict --copt -fsanitize=integer
3131
build:clang-asan-strict --linkopt -fsanitize=integer
3232

33+
# Use Clang compiler with Thread Sanitizer.
34+
build:clang-tsan --config=clang
35+
build:clang-tsan --copt -DTHREAD_SANITIZER=1
36+
build:clang-tsan --copt -O1
37+
build:clang-tsan --copt -fno-omit-frame-pointer
38+
build:clang-tsan --copt -fno-optimize-sibling-calls
39+
build:clang-tsan --copt -fsanitize=thread
40+
build:clang-tsan --linkopt -fsanitize=thread
41+
build:clang-tsan --linkopt -fuse-ld=lld
42+
3343
# Use GCC compiler.
3444
build:gcc --action_env=BAZEL_COMPILER=gcc
3545
build:gcc --action_env=CC=gcc

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ jobs:
102102
arch: x86_64
103103
action: test
104104
flags: --config=clang-asan-strict --define=crypto=system
105+
- name: 'NullVM on Linux/x86_64 with TSan'
106+
engine: 'null'
107+
os: ubuntu-20.04
108+
arch: x86_64
109+
action: test
110+
flags: --config=clang-tsan
105111
- name: 'NullVM on Windows/x86_64'
106112
engine: 'null'
107113
os: windows-2019
@@ -123,6 +129,14 @@ jobs:
123129
action: test
124130
flags: --config=clang-asan
125131
cache: true
132+
- name: 'V8 on Linux/x86_64 with TSan'
133+
engine: 'v8'
134+
repo: 'v8'
135+
os: ubuntu-20.04
136+
arch: x86_64
137+
action: test
138+
flags: --config=clang-tsan
139+
cache: true
126140
- name: 'V8 on Linux/aarch64'
127141
engine: 'v8'
128142
repo: 'v8'

test/runtime_test.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,14 @@ TEST_P(TestVM, CloneUntilOutOfMemory) {
128128
// Prevent clone from droping out of scope and freeing memory.
129129
clones.push_back(std::move(clone));
130130
}
131-
EXPECT_GE(clones.size(), 1000);
131+
132+
size_t min_clones = 1000;
133+
#if defined(__has_feature)
134+
#if __has_feature(thread_sanitizer)
135+
min_clones = 100;
136+
#endif
137+
#endif
138+
EXPECT_GE(clones.size(), min_clones);
132139
}
133140

134141
#endif

0 commit comments

Comments
 (0)