diff --git a/projects/tint/Dockerfile b/projects/tint/Dockerfile new file mode 100644 index 000000000..dc293e905 --- /dev/null +++ b/projects/tint/Dockerfile @@ -0,0 +1,23 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder +RUN apt-get update && apt-get install -y make autoconf automake libtool ninja-build +RUN git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' --depth 1 +ENV PATH="${SRC}/depot_tools:${PATH}" +RUN git clone --depth 1 https://dawn.googlesource.com/tint tint +WORKDIR tint +COPY build.sh $SRC/ diff --git a/projects/tint/build.sh b/projects/tint/build.sh new file mode 100755 index 000000000..5ce1fede3 --- /dev/null +++ b/projects/tint/build.sh @@ -0,0 +1,62 @@ +#!/bin/bash -eu +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +cp standalone.gclient .gclient +gclient sync + +mkdir -p out/Debug +pushd out/Debug + +# ubsan's vptr sanitization is desabled as it requires RTTI, which is disabled +# when building tint. +CFLAGS="$CFLAGS -fno-sanitize=vptr" \ +CXXFLAGS="$CXXFLAGS -fno-sanitize=vptr" \ +cmake -GNinja ../.. -DTINT_BUILD_FUZZERS=ON -DTINT_BUILD_SPIRV_TOOLS_FUZZER=ON -DTINT_BUILD_TESTS=OFF + +SPIRV_FUZZERS="tint_spv_reader_fuzzer\ + tint_spv_reader_msl_writer_fuzzer\ + tint_spv_reader_wgsl_writer_fuzzer\ + tint_spv_reader_hlsl_writer_fuzzer\ + tint_spv_reader_spv_writer_fuzzer" + +# TODO(afd): add tint_spirv_tools_fuzzer + +# The spirv-as tool is used to build seed corpora +ninja ${SPIRV_FUZZERS} spirv-as + +cp ${SPIRV_FUZZERS} $OUT + +popd + +# Generate a corpus of SPIR-V binaries from the SPIR-V assembly files in the +# tint repository. +mkdir $WORK/spirv-corpus +python3 fuzzers/generate_spirv_corpus.py test $WORK/spirv-corpus out/Debug/spirv-as + +mkdir $WORK/spirv-corpus-hashed-names +for f in `ls $WORK/spirv-corpus/*.spv` +do + hashed_name=$(sha1sum "$f" | awk '{print $1}') + cp $f $WORK/spirv-corpus-hashed-names/$hashed_name +done + +zip -j "$WORK/seed_corpus.zip" "$WORK"/spirv-corpus-hashed-names/* + +for fuzzer in $SPIRV_FUZZERS +do + cp "$WORK/seed_corpus.zip" "$OUT/${fuzzer}_seed_corpus.zip" +done diff --git a/projects/tint/project.yaml b/projects/tint/project.yaml new file mode 100644 index 000000000..46fec183e --- /dev/null +++ b/projects/tint/project.yaml @@ -0,0 +1,13 @@ +homepage: https://dawn.googlesource.com/tint +language: c++ +primary_contact: bclayton@google.com +auto_ccs: + - "afdx@google.com" +sanitizers: + - address + - memory + - undefined +main_repo: 'https://dawn.googlesource.com/tint.git' +architectures: + - x86_64 + - i386