build: Link libgit2 via LIB_FUZZING_ENGINE

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
This commit is contained in:
Paulo Gomes 2022-11-25 17:07:34 +00:00
parent 7bfbb158ea
commit aff16b9f49
No known key found for this signature in database
GPG Key ID: 9995233870E99BEE
2 changed files with 17 additions and 2 deletions

View File

@ -20,10 +20,14 @@ set -euxo pipefail
# Use it for unsetting any environment variables that may impact other building
# processes.
if [[ -n "${PRE_LIB_FUZZING_ENGINE}" ]]; then
export LIB_FUZZING_ENGINE="${PRE_LIB_FUZZING_ENGINE}"
fi
unset TARGET_DIR
unset CGO_ENABLED
unset LIBRARY_PATH
unset PKG_CONFIG_PATH
unset CGO_CFLAGS
unset CGO_LDFLAGS
unset ADDITIONAL_LIBS
unset PRE_LIB_FUZZING_ENGINE

View File

@ -62,4 +62,15 @@ export PKG_CONFIG_PATH="${TARGET_DIR}/lib/pkgconfig"
export CGO_CFLAGS="-I${TARGET_DIR}/include"
export CGO_LDFLAGS="$(pkg-config --libs --static --cflags libgit2)"
export ADDITIONAL_LIBS="${TARGET_DIR}/lib/libgit2.a"
# Temporary hack whilst libgit2 is still in use.
# Enables the fuzzing compilation to link libgit2.
#
# After building the fuzzers, the value of
# LIB_FUZZING_ENGINE is reset to what it was before
# it to avoid side effects onto other repositories.
#
# For context refer to:
# https://github.com/google/oss-fuzz/pull/9063
export PRE_LIB_FUZZING_ENGINE="${LIB_FUZZING_ENGINE}"
export LIB_FUZZING_ENGINE="${LIB_FUZZING_ENGINE} -Wl,--start-group ${TARGET_DIR}/lib/libgit2.a"