-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile-tsan
82 lines (62 loc) · 3.12 KB
/
Dockerfile-tsan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
FROM ubuntu:jammy
RUN apt update
RUN apt install -y g++-12 gcc-12 build-essential cmake pkg-config git wget ninja-build nano libzip-dev
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 60
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 60
RUN update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-12 60
# Run all downloads first to be able to use Docker's layers as cache and prevent excessive redownloads
WORKDIR /opt
RUN wget https://github.com/redis/hiredis/archive/refs/tags/v1.2.0.tar.gz
RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.bz2
RUN wget https://www.openssl.org/source/openssl-3.0.11.tar.gz
ENV CFLAGS="-Og -fsanitize=thread"
ENV CXXFLAGS="-Og -fsanitize=thread"
ENV LDFLAGS="-fsanitize=thread -static-libtsan -static-libgcc -static-libstdc++"
RUN tar xf openssl-3.0.11.tar.gz
WORKDIR /opt/openssl-3.0.11
RUN ./Configure --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared
RUN make -j
RUN make -j install
WORKDIR /opt
#Build boost with support for asan
RUN tar xf boost_1_81_0.tar.bz2
WORKDIR /opt/boost_1_81_0
RUN <<EOF
cat >> patch << EOR
diff -r -u boost-1.81.0/boost/asio/detail/std_fenced_block.hpp boost-1.81.0-fencecd/boost/asio/detail/std_fenced_block.hpp
--- ./boost/asio/detail/std_fenced_block.hpp 2022-12-14 16:15:35.000000000 +0100
+++ ./boost/asio/detail/std_fenced_block.hpp 2023-10-03 20:17:11.701435674 +0200
@@ -43,14 +43,16 @@
// Constructor for a full fenced block.
explicit std_fenced_block(full_t)
{
- std::atomic_thread_fence(std::memory_order_acquire);
+ _fence.load(std::memory_order_acquire);
}
// Destructor.
~std_fenced_block()
{
- std::atomic_thread_fence(std::memory_order_release);
+ _fence.store(true, std::memory_order_release);
}
+
+ std::atomic<bool> _fence;
};
} // namespace detail
EOR
EOF
RUN patch ./boost/asio/detail/std_fenced_block.hpp < patch
RUN ./bootstrap.sh --prefix=/usr
RUN ./b2 cxxflags="-fsanitize=thread -Og -std=c++20 -DBOOST_USE_TSAN -DBOOST_USE_UCONTEXT" linkflags="-static-libtsan -static-libgcc -static-libstdc++" variant=debug link=static threading=multi context-impl=ucontext
RUN ./b2 cxxflags="-fsanitize=thread -Og -std=c++20 -DBOOST_USE_TSAN -DBOOST_USE_UCONTEXT" linkflags="-static-libtsan -static-libgcc -static-libstdc++" variant=debug link=static threading=multi context-impl=ucontext install
WORKDIR /opt
#Build latest hiredis containing sdevent support, not available yet in apt
RUN tar xf v1.2.0.tar.gz
RUN mkdir /opt/hiredis-1.2.0/build
WORKDIR /opt/hiredis-1.2.0/build
RUN cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDISABLE_TESTS=1 -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=OFF -DENABLE_SSL=1 ..
RUN ninja && ninja install
RUN mkdir -p /opt/ichor/build
WORKDIR /opt/ichor/build
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["unset CFLAGS CXXFLAGS && cd /opt/ichor/build && cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DICHOR_USE_SANITIZERS=0 -DICHOR_USE_MIMALLOC=0 -DICHOR_USE_THREAD_SANITIZER=1 -DICHOR_USE_HIREDIS=1 -DICHOR_USE_BOOST_BEAST=1 -DICHOR_USE_SPDLOG=1 -DICHOR_USE_BACKWARD=0 -DICHOR_SKIP_EXTERNAL_TESTS=1 /opt/ichor/src && ninja && ninja test"]