internal/fuzz: support coverage builds with oss-fuzz

Use OSS-Fuzz's new compile_go_fuzzer script, which enables code
coverage.

Change-Id: Iff07ac09d054e8c881d819b4ce6d016ad2808978
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/272768
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Joe Tsai <joetsai@google.com>
diff --git a/internal/fuzz/oss-fuzz-build.sh b/internal/fuzz/oss-fuzz-build.sh
index 0953101..459d102 100644
--- a/internal/fuzz/oss-fuzz-build.sh
+++ b/internal/fuzz/oss-fuzz-build.sh
@@ -4,22 +4,10 @@
 
 # This script is executed by OSS-Fuzz's build to create fuzzer binaries.
 
-function compile_fuzzer {
-  path=$1
-  function=$2
-  fuzzer=$3
-
-   # Instrument all Go files relevant to this fuzzer
-  go-fuzz -tags=protolegacy -func $function -o $fuzzer.a $path
-
-   # Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
-  $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
-}
-
 for x in internal/fuzz/*; do
   if [ -d $x/corpus ]; then
     name=$(basename $x)
-    compile_fuzzer google.golang.org/protobuf/$x Fuzz $name
+    compile_go_fuzzer google.golang.org/protobuf/$x Fuzz $name protolegacy
     zip -jr $OUT/${name}_seed_corpus.zip $x/corpus
   fi
 done