cmd/racebuild: use git apply on loong64

The loong64 builder is missing patch, but it turns out that git apply
works fine outside of a git repository.

For golang/go#78059.

Change-Id: Iebb06e5b71118a6b5a7007affa94dfce6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/build/+/758400
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
diff --git a/cmd/racebuild/racebuild.go b/cmd/racebuild/racebuild.go
index 2b1fd80..75c0554 100644
--- a/cmd/racebuild/racebuild.go
+++ b/cmd/racebuild/racebuild.go
@@ -433,7 +433,9 @@
 		OS:   "linux",
 		Arch: "loong64",
 		Type: "gotip-linux-loong64",
-		// Needs git, g++, patch, unzip, golang-bin on the builder.
+		// Needs git, g++, unzip, golang-bin on the builder.
+		// Unlike other builders, this one is missing patch, but git
+		// apply works fine even outside of a git repository.
 		Script: `#!/usr/bin/env bash
 set -e
 cat /etc/os-release
@@ -448,7 +450,7 @@
 curl -L -o llvm.zip https://github.com/llvm/llvm-project/archive/${REV}.zip
 unzip -q llvm.zip llvm-project-${REV}/compiler-rt/*
 if [ "$LLVM_PATCH" != "" ]; then
-  (cd llvm-project-${REV}/ && patch -p1 < ../patch.patch)
+  (cd llvm-project-${REV}/ && git apply ../patch.patch)
 fi
 (cd llvm-project-${REV}/compiler-rt/lib/tsan/go && ./buildgo.sh)
 cp llvm-project-${REV}/compiler-rt/lib/tsan/go/race_linux_loong64.syso go/src/runtime/race