1#!/bin/bash -eu 2# Copyright 2020 Google Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17 18#builds project 19export PATH="$HOME/.local/bin:$PATH" 20$SRC/orbit/bootstrap-orbit.sh --force-public-remotes --dont-compile --ignore-system-requirements 21 22conan profile new default --detect 23conan profile update settings.compiler.libcxx=libc++ default 24conan profile update settings.compiler.fpo=False default 25conan profile update settings.compiler.address_sanitizer=True default 26conan profile update settings.compiler.fuzzer_sanitizer=True default 27 28sed -i 's/\[settings\]/include(libfuzzer_base)\n\n[settings]/' ~/.conan/profiles/default 29echo "CFLAGS=\$BASE_CFLAGS" >> ~/.conan/profiles/default 30echo "CXXFLAGS=\$BASE_CXXFLAGS" >> ~/.conan/profiles/default 31echo "LDFLAGS=\$BASE_LDFLAGS" >> ~/.conan/profiles/default 32echo "OrbitProfiler:CFLAGS=\$BASE_CFLAGS $CFLAGS" >> ~/.conan/profiles/default 33echo "OrbitProfiler:CXXFLAGS=\$BASE_CFLAGS $CXXFLAGS" >> ~/.conan/profiles/default 34 35# The following two lines is what should theoretically be correct. The workaround + explanation follows 36# echo "llvm:CFLAGS=\$BASE_CFLAGS $CFLAGS" >> ~/.conan/profiles/default 37# echo "llvm:CXXFLAGS=\$BASE_CXXFLAGS $CXXFLAGS" >> ~/.conan/profiles/default 38 39# The $CFLAGS and $CXXFLAGS contains "-fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link" 40# when this script is called. Since llvm currently cannot be build with address sanitizers, 41# the flags are set manually here. 42echo "llvm:CFLAGS=\$BASE_CFLAGS -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" >> ~/.conan/profiles/default 43echo "llvm:CXXFLAGS=\$BASE_CXXFLAGS -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -stdlib=libc++" >> ~/.conan/profiles/default 44 45$SRC/orbit/build.sh default 46 47function copy_fuzzer { 48 mkdir -p "$OUT/lib" 49 cp -v "$1" "$OUT/" 50 patchelf --set-rpath '$ORIGIN/lib' "$OUT/$(basename "$1")" 51 52 ldd "$1" | grep '=>' | cut -d ' ' -f 3 | while read lib; do 53 if [[ -f $lib ]]; then 54 cp -v "$lib" "$OUT/lib/" 55 patchelf --set-rpath '$ORIGIN' "$OUT/lib/$(basename "$lib")" 56 fi 57 done 58} 59 60find $SRC/orbit/build_default/bin -name \*Fuzzer | while read fuzzer; do 61 copy_fuzzer "$fuzzer" 62done 63