Skip to content
Merged
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
6 changes: 5 additions & 1 deletion barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,15 @@
"description": "Build with thread sanitizer on clang16 with debugging information",
"inherits": "clang16-dbg",
"binaryDir": "build-msan",
"generator": "Unix Makefiles",
"environment": {
"CFLAGS": "-fsanitize=memory",
"CXXFLAGS": "-fsanitize=memory",
"LDFLAGS": "-fsanitize=memory"
},
"cacheVariables": {
"HAVE_STD_REGEX": "ON",

@ludamad ludamad Feb 15, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workaround for poor std regex detection in CMake

"CMAKE_CXX_FLAGS": "$env{MSAN_CFLAGS}",
"CMAKE_EXE_LINKER_FLAGS": "$env{MSAN_LFLAGS}"
}
},
{
Expand Down
43 changes: 43 additions & 0 deletions barretenberg/cpp/dockerfiles/interactive/Dockerfile.msan.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ubuntu:lunar

RUN apt update && apt install -y \
build-essential \
curl \
git \
cmake \
lsb-release \
wget \
software-properties-common \
gnupg \
ninja-build \
npm \
libssl-dev \
jq \
bash \
libstdc++6

RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 16

ENV CXX=clang++-16
ENV CC=clang-16

RUN git clone --depth 1 -b release/16.x https://github.com/llvm/llvm-project

RUN cd llvm-project

RUN mkdir llvm-project/build

RUN cmake -G Ninja -S llvm-project/runtimes -B llvm-project/build \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
-DCMAKE_INSTALL_PREFIX=/opt

RUN ninja -C llvm-project/build cxx cxxabi
RUN ninja -C llvm-project/build install-cxx install-cxxabi

ENV MSAN_CFLAGS="-std=c++20 -fsanitize=memory -nostdinc++ -I/opt/include -I/opt/include/c++/v1"
ENV MSAN_LFLAGS="-fsanitize=memory -stdlib=libc++ -L/opt/lib -lc++abi -Wl,-rpath,/opt/lib"

WORKDIR /usr/src/barretenberg/cpp

CMD ["/bin/bash"]
4 changes: 2 additions & 2 deletions barretenberg/cpp/scripts/docker_interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Enter script directory.
set -eu
cd $(dirname $0)
# allows for 'alpine' or 'ubuntu'
# allows for 'alpine', 'ubuntu' or 'msan.ubuntu'
ENVIRONMENT_KIND="${1:-alpine}"
DOCKERFILE="../dockerfiles/interactive/Dockerfile.$ENVIRONMENT_KIND"
docker build -t "env-$ENVIRONMENT_KIND" -f "$DOCKERFILE" .
docker run -it --mount type=bind,source=$(pwd)/..,target=/usr/src/barretenberg/cpp "env-$ENVIRONMENT_KIND"
docker run -it --mount type=bind,source=$(pwd)/..,target=/usr/src/barretenberg/cpp "env-$ENVIRONMENT_KIND"