diff --git a/projects/unrar/build.sh b/projects/unrar/build.sh index 94696828a..e4f65811c 100644 --- a/projects/unrar/build.sh +++ b/projects/unrar/build.sh @@ -15,6 +15,18 @@ # ################################################################################ +# Fuzz introspector uses LDFLAGS, so ensure LDFLAGS +# is always set for other sanitizer options. +if [ "$SANITIZER" != "introspector" ]; then + export LDFLAGS="" +else + # We need to add -flto flags because the makefile in unrar does not + # pass cxxflags, which holds the -flto flag from fuzz-introspector. + # This should probably be updated in the future, namely, including + # -flto into LDFLAGS in OSS-Fuzz fuzz-introspector builds. + export LDFLAGS="${LDFLAGS} -flto" +fi + UNRAR_DEFINES="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DRAR_SMP -DRARDLL -DSILENT -DNOVOLUME" UNRAR_WNOS="-Wno-logical-op-parentheses -Wno-switch -Wno-dangling-else" UNRAR_SRC_DIR="$SRC/unrar" @@ -25,7 +37,7 @@ CXXFLAGS="$CXXFLAGS -fno-sanitize=enum" # build 'lib'. This builds libunrar.a and libunrar.so # -fPIC is required for successful compilation. -make CXX=$CXX CXXFLAGS="$CXXFLAGS -fPIC $UNRAR_DEFINES $UNRAR_WNOS" \ +make CXX=$CXX LDFLAGS="$LDFLAGS" CXXFLAGS="$CXXFLAGS -fPIC $UNRAR_DEFINES $UNRAR_WNOS" \ -C $UNRAR_SRC_DIR lib # remove the .so file so that the linker links unrar statically.