Skip to content

Commit 03f168a

Browse files
authored
ci(gcb): add msan build (#6259)
This build is a little strange because it requires a custom-built libc++, which we build in the Dockerfile.
1 parent ffc2413 commit 03f168a

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed

ci/cloudbuild/builds/msan.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -eu
18+
19+
source "$(dirname "$0")/../../lib/init.sh"
20+
source module ci/cloudbuild/builds/lib/bazel.sh
21+
source module ci/cloudbuild/builds/lib/integration.sh
22+
23+
export CC=clang
24+
export CXX=clang++
25+
26+
mapfile -t args < <(bazel::common_args)
27+
args+=("--config=msan")
28+
bazel test "${args[@]}" --test_tag_filters=-integration-test ...
29+
30+
mapfile -t integration_args < <(integration::args)
31+
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG DISTRO_VERSION=33
16+
FROM fedora:${DISTRO_VERSION}
17+
ARG NCPU=4
18+
19+
# Install the minimal packages needed to compile libcxx, install Bazel, and
20+
# then compile our code.
21+
RUN dnf makecache && \
22+
dnf install -y ccache clang clang-tools-extra cmake findutils gcc-c++ \
23+
git llvm llvm-devel make ninja-build openssl-devel patch python \
24+
python3.8 python3-devel python3-lit python-pip tar unzip which wget xz
25+
26+
# Sets root's password to the empty string to enable users to get a root shell
27+
# inside the container with `su -` and no password. Sudo would not work because
28+
# we run these containers as the invoking user's uid, which does not exist in
29+
# the container's /etc/passwd file.
30+
RUN echo 'root:' | chpasswd
31+
32+
# Install the Python modules needed to run the storage emulator
33+
RUN pip3 install --upgrade pip
34+
RUN pip3 install setuptools wheel
35+
RUN pip3 install git+git://github.com/googleapis/python-storage@8cf6c62a96ba3fff7e5028d931231e28e5029f1c
36+
RUN pip3 install flask==1.1.2 httpbin==0.7.0 scalpl==0.4.0 \
37+
crc32c==2.1 gunicorn==20.0.4
38+
39+
WORKDIR /var/tmp/build
40+
41+
# Install instructions from:
42+
# https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo
43+
RUN git clone --depth=1 --branch llvmorg-11.0.0 https://github.com/llvm/llvm-project
44+
WORKDIR llvm-project/build
45+
# configure cmake
46+
RUN cmake -GNinja ../llvm \
47+
-DCMAKE_BUILD_TYPE=Release \
48+
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
49+
-DCMAKE_C_COMPILER=clang \
50+
-DCMAKE_CXX_COMPILER=clang++ \
51+
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
52+
-DCMAKE_INSTALL_PREFIX=/usr
53+
# build the libraries
54+
RUN cmake --build . -- cxx cxxabi
55+
RUN cmake --build . -- install-cxx install-cxxabi
56+
57+
# Install the Cloud SDK and some of the emulators. We use the emulators to run
58+
# integration tests for the client libraries.
59+
COPY . /var/tmp/ci
60+
WORKDIR /var/tmp/downloads
61+
ENV CLOUDSDK_PYTHON=python3.8
62+
RUN /var/tmp/ci/install-cloud-sdk.sh
63+
ENV CLOUD_SDK_LOCATION=/usr/local/google-cloud-sdk
64+
ENV PATH=${CLOUD_SDK_LOCATION}/bin:${PATH}
65+
# The Cloud Pub/Sub emulator needs Java :shrug:
66+
RUN dnf makecache && dnf install -y java-latest-openjdk
67+
68+
# We need Bazel for this build.
69+
COPY . /var/tmp/ci
70+
RUN /var/tmp/ci/install-bazel.sh
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
filename: ci/cloudbuild/cloudbuild.yaml
2+
github:
3+
name: google-cloud-cpp
4+
owner: googleapis
5+
push:
6+
branch: ^(master|main|v\d+\..*)$
7+
name: msan-ci
8+
substitutions:
9+
_BUILD_NAME: msan
10+
_DISTRO: fedora-msan
11+
tags:
12+
- ci
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
filename: ci/cloudbuild/cloudbuild.yaml
2+
github:
3+
name: google-cloud-cpp
4+
owner: googleapis
5+
pullRequest:
6+
branch: ^(master|main|v\d+\..*)$
7+
commentControl: COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY
8+
name: msan-pr
9+
substitutions:
10+
_BUILD_NAME: msan
11+
_DISTRO: fedora-msan
12+
tags:
13+
- pr

0 commit comments

Comments
 (0)