Skip to content

Commit cf09a7a

Browse files
authored
Merge pull request #17 from su2code/feature_tsan
Add containers for building and testing SU2 with the thread sanitizer
2 parents 272d51b + d7c276f commit cf09a7a

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

.github/workflows/docker-image-upload.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
- name: Build and push build-su2
4343
run: docker buildx build --platform=linux/amd64 --platform=linux/arm64 -t ghcr.io/${{ github.repository_owner }}/su2/build-su2:${{ steps.vars.outputs.date_tag }} --push ./build/
4444

45+
- name: Build and push build-su2-tsan
46+
run: docker buildx build --platform=linux/amd64 --platform=linux/arm64 -t ghcr.io/${{ github.repository_owner }}/su2/build-su2-tsan:${{ steps.vars.outputs.date_tag }} --push --file ./build/Dockerfile.tsan ./build/
47+
4548
test-su2:
4649
needs: [build-su2]
4750
if: ${{ always() && !(contains(needs.*.result, 'failure')) }}
@@ -71,6 +74,9 @@ jobs:
7174
- name: Build and push test-su2
7275
run: docker buildx build --platform=linux/amd64 --platform=linux/arm64 --build-arg BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/su2/build-su2:${{ needs.build-su2.outputs.date_tag }} -t ghcr.io/${{ github.repository_owner }}/su2/test-su2:${{ needs.build-su2.outputs.date_tag }} --push ./test/
7376

77+
- name: Build and push test-su2-tsan
78+
run: docker buildx build --platform=linux/amd64 --platform=linux/arm64 --build-arg BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/su2/build-su2-tsan:${{ needs.build-su2.outputs.date_tag }} -t ghcr.io/${{ github.repository_owner }}/su2/test-su2-tsan:${{ needs.build-su2.outputs.date_tag }} --push ./test/
79+
7480
cross-build-su2-mac:
7581
needs: [build-su2]
7682
if: ${{ always() && !(contains(needs.*.result, 'failure')) }}

build/Dockerfile.tsan

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM ubuntu:20.04
2+
3+
LABEL org.opencontainers.image.source https://github.com/su2code/Docker-Builds
4+
5+
ENV LANG C.UTF-8
6+
RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime
7+
RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y \
8+
apt-utils \
9+
python3 \
10+
pkg-config \
11+
python3-pip \
12+
git \
13+
build-essential \
14+
cmake \
15+
python3-numpy \
16+
python3-scipy \
17+
python3-mpi4py \
18+
swig \
19+
libopenmpi-dev \
20+
libopenblas-dev \
21+
openmpi-bin \
22+
ccache \
23+
petsc-dev \
24+
python3-petsc4py \
25+
python3-rtree \
26+
curl \
27+
flex \
28+
&& rm -rf /var/lib/apt/lists/* \
29+
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 10
30+
31+
# Build a gcc suitable for thread sanitizer analysis
32+
RUN cd / \
33+
&& git clone git://gcc.gnu.org/git/gcc.git gcc_sources \
34+
&& cd gcc_sources \
35+
&& git checkout releases/gcc-9.4.0 \
36+
&& ./contrib/download_prerequisites \
37+
&& cd / \
38+
&& mkdir gcc_objdir \
39+
&& cd gcc_objdir \
40+
&& /gcc_sources/configure --prefix=/gcc_install --enable-languages=c,c++ --disable-linux-futex --disable-multilib \
41+
&& make \
42+
&& make install \
43+
&& cd / \
44+
&& rm -rf gcc_sources \
45+
&& rm -rf gcc_objdir \
46+
&& cd /gcc_install/bin \
47+
&& ln -s gcc cc
48+
49+
# Ensure that ccache uses the built gcc
50+
RUN export PATH=/gcc_install/bin:$PATH \
51+
&& /usr/sbin/update-ccache-symlinks
52+
53+
# Configure environment for the built gcc, also enable thread sanitizer
54+
ENV LD_LIBRARY_PATH=/gcc_install/lib64:$LD_LIBRARY_PATH
55+
ENV CXXFLAGS="-I/gcc_install/include/c++/9.4.0 -I/gcc_install/include/c++/9.4.0/x86_64-pc-linux-gnu -fsanitize=thread"
56+
ENV CFLAGS="-I/gcc_install/include/c++/9.4.0 -I/gcc_install/include/c++/9.4.0/x86_64-pc-linux-gnu -fsanitize=thread"
57+
ENV LDFLAGS="-L/gcc_install/lib64 -fsanitize=thread"
58+
ENV PATH=/usr/lib/ccache:/gcc_install/bin:$PATH
59+
ENV TSAN_OPTIONS="history_size=7 halt_on_error=1"
60+
61+
# Copies your code file from your action repository to the filesystem path `/` of the container
62+
COPY compileSU2.sh /compileSU2.sh
63+
64+
# Code file to execute when the docker container starts up (`entrypoint.sh`)
65+
ENTRYPOINT ["/compileSU2.sh"]

0 commit comments

Comments
 (0)