mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
ossfuzz: Generate antlr4 runtime deps
This commit is contained in:
parent
0798167f3d
commit
6101590d93
@ -21,8 +21,8 @@ parameters:
|
|||||||
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:7a4d5271b5552139d9f2caefc50d42f401bf74132cf8f253e199e11c80ab42de"
|
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:7a4d5271b5552139d9f2caefc50d42f401bf74132cf8f253e199e11c80ab42de"
|
||||||
ubuntu-1604-clang-ossfuzz-docker-image:
|
ubuntu-1604-clang-ossfuzz-docker-image:
|
||||||
type: string
|
type: string
|
||||||
# solbuildpackpusher/solidity-buildpack-deps:ubuntu1604.clang.ossfuzz-2
|
# solbuildpackpusher/solidity-buildpack-deps:ubuntu1604.clang.ossfuzz-3
|
||||||
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:efaabb3c143f64171be596932c62013bcfd7f73b1fbcb832025a34dd2b6e6922"
|
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:6fa6914bd81abcac4b162c738e6ff05d87cefe7655e3859c7a827e5a8ec20dc7"
|
||||||
emscripten-docker-image:
|
emscripten-docker-image:
|
||||||
type: string
|
type: string
|
||||||
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:d557d015918c3cf68b0d22839bab41013f0757b651a7fef21595f89721dbebcc"
|
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:d557d015918c3cf68b0d22839bab41013f0757b651a7fef21595f89721dbebcc"
|
||||||
@ -500,7 +500,6 @@ jobs:
|
|||||||
CC: clang
|
CC: clang
|
||||||
CXX: clang++
|
CXX: clang++
|
||||||
TERM: xterm
|
TERM: xterm
|
||||||
CMAKE_OPTIONS: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/libfuzzer.cmake
|
|
||||||
MAKEFLAGS: -j 3
|
MAKEFLAGS: -j 3
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
@ -1,15 +1,55 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -ex
|
||||||
|
|
||||||
ROOTDIR="$(dirname "$0")/../.."
|
ROOTDIR="/root/project"
|
||||||
BUILDDIR="${ROOTDIR}/build"
|
BUILDDIR="${ROOTDIR}/build"
|
||||||
|
mkdir -p "${BUILDDIR}" && mkdir -p "$BUILDDIR/deps"
|
||||||
|
|
||||||
mkdir -p "${BUILDDIR}"
|
ANTLRJAR="${ROOTDIR}/build/deps/antlr4.8.jar"
|
||||||
|
ANTLRJAR_URI="https://www.antlr.org/download/antlr-4.8-complete.jar"
|
||||||
|
|
||||||
|
download_antlr4()
|
||||||
|
{
|
||||||
|
if [[ ! -e "${ANTLRJAR}" ]]
|
||||||
|
then
|
||||||
|
wget -O "${ANTLRJAR}" "${ANTLRJAR_URI}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_protobuf_bindings()
|
||||||
|
{
|
||||||
|
cd "${ROOTDIR}"/test/tools/ossfuzz
|
||||||
|
# Generate protobuf C++ bindings
|
||||||
|
for protoName in yul abiV2 sol;
|
||||||
|
do
|
||||||
|
protoc "${protoName}"Proto.proto --cpp_out .
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_antlr4_bindings()
|
||||||
|
{
|
||||||
|
cd "${ROOTDIR}"
|
||||||
|
# Replace boolean with bool to suit c++ syntax
|
||||||
|
sed -i 's/boolean /bool /g' docs/grammar/Solidity.g4
|
||||||
|
# Generate antlr4 visitor/parser/lexer c++ bindings
|
||||||
|
java -jar "${ANTLRJAR}" -Dlanguage=Cpp \
|
||||||
|
-Xexact-output-dir -package solidity::test::fuzzer -o test/tools/ossfuzz \
|
||||||
|
-no-listener -visitor docs/grammar/SolidityLexer.g4 docs/grammar/Solidity.g4
|
||||||
|
# Delete unnecessary autogen files
|
||||||
|
rm -f "${ROOTDIR}"/test/tools/ossfuzz/Solidity*Visitor.cpp \
|
||||||
|
"${ROOTDIR}"/test/tools/ossfuzz/Solidity*.interp \
|
||||||
|
"${ROOTDIR}"/test/tools/ossfuzz/Solidity*.tokens
|
||||||
|
}
|
||||||
|
|
||||||
|
build_fuzzers()
|
||||||
|
{
|
||||||
cd "${BUILDDIR}"
|
cd "${BUILDDIR}"
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \
|
||||||
protoc --proto_path=../test/tools/ossfuzz yulProto.proto --cpp_out=../test/tools/ossfuzz
|
-DCMAKE_TOOLCHAIN_FILE="${ROOTDIR}"/cmake/toolchains/libfuzzer.cmake
|
||||||
protoc --proto_path=../test/tools/ossfuzz abiV2Proto.proto --cpp_out=../test/tools/ossfuzz
|
|
||||||
protoc --proto_path=../test/tools/ossfuzz solProto.proto --cpp_out=../test/tools/ossfuzz
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/libfuzzer.cmake
|
|
||||||
|
|
||||||
make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j 4
|
make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j 4
|
||||||
|
}
|
||||||
|
|
||||||
|
download_antlr4
|
||||||
|
generate_protobuf_bindings
|
||||||
|
generate_antlr4_bindings
|
||||||
|
build_fuzzers
|
@ -23,12 +23,34 @@ if (OSSFUZZ)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (OSSFUZZ)
|
if (OSSFUZZ)
|
||||||
add_executable(solc_opt_ossfuzz solc_opt_ossfuzz.cpp ../fuzzer_common.cpp ../../TestCaseReader.cpp)
|
add_executable(solc_opt_ossfuzz
|
||||||
target_link_libraries(solc_opt_ossfuzz PRIVATE libsolc evmasm)
|
solc_opt_ossfuzz.cpp
|
||||||
|
../fuzzer_common.cpp
|
||||||
|
../../TestCaseReader.cpp
|
||||||
|
SolidityLexer.cpp
|
||||||
|
SolidityParser.cpp
|
||||||
|
)
|
||||||
|
target_compile_options(solc_opt_ossfuzz
|
||||||
|
PUBLIC
|
||||||
|
${COMPILE_OPTIONS} -Wno-extra-semi -Wno-unused-parameter
|
||||||
|
)
|
||||||
|
target_include_directories(solc_opt_ossfuzz PRIVATE /usr/include/antlr4-runtime)
|
||||||
|
target_link_libraries(solc_opt_ossfuzz PRIVATE libsolc evmasm antlr4-runtime)
|
||||||
set_target_properties(solc_opt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
set_target_properties(solc_opt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
||||||
|
|
||||||
add_executable(solc_noopt_ossfuzz solc_noopt_ossfuzz.cpp ../fuzzer_common.cpp ../../TestCaseReader.cpp)
|
add_executable(solc_noopt_ossfuzz
|
||||||
target_link_libraries(solc_noopt_ossfuzz PRIVATE libsolc evmasm)
|
solc_noopt_ossfuzz.cpp
|
||||||
|
../fuzzer_common.cpp
|
||||||
|
../../TestCaseReader.cpp
|
||||||
|
SolidityLexer.cpp
|
||||||
|
SolidityParser.cpp
|
||||||
|
)
|
||||||
|
target_compile_options(solc_noopt_ossfuzz
|
||||||
|
PUBLIC
|
||||||
|
${COMPILE_OPTIONS} -Wno-extra-semi -Wno-unused-parameter
|
||||||
|
)
|
||||||
|
target_include_directories(solc_noopt_ossfuzz PRIVATE /usr/include/antlr4-runtime)
|
||||||
|
target_link_libraries(solc_noopt_ossfuzz PRIVATE libsolc evmasm antlr4-runtime)
|
||||||
set_target_properties(solc_noopt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
set_target_properties(solc_noopt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
||||||
|
|
||||||
add_executable(const_opt_ossfuzz const_opt_ossfuzz.cpp ../fuzzer_common.cpp)
|
add_executable(const_opt_ossfuzz const_opt_ossfuzz.cpp ../fuzzer_common.cpp)
|
||||||
|
Loading…
Reference in New Issue
Block a user