From 420ad8e01012d9c153232fbde5951c2f62bf5a4a Mon Sep 17 00:00:00 2001 From: xgopilot Date: Thu, 16 Oct 2025 13:28:54 +0000 Subject: [PATCH] refactor: simplify go/build patch - use build.Default directly Remove unnecessary go:linkname, runtime import, and unsafe import. Access build.Default.Compiler directly instead of via linkname. - Removed go:linkname directive - Removed runtime and unsafe imports - Removed unnecessary _ = runtime.Compiler line - Simplified from 27 lines to 19 lines - Same functionality, cleaner code Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang --- runtime/internal/lib/go/build/build.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/runtime/internal/lib/go/build/build.go b/runtime/internal/lib/go/build/build.go index af072099..576fa0a7 100644 --- a/runtime/internal/lib/go/build/build.go +++ b/runtime/internal/lib/go/build/build.go @@ -9,19 +9,11 @@ package build import ( "go/build" - "runtime" - _ "unsafe" ) -//go:linkname buildDefault go/build.Default -var buildDefault build.Context - func init() { // LLGO PATCH: Override build.Default.Compiler to be "gc" instead of "llgo" // This prevents "unknown compiler" errors when user code uses go/build package // Even though runtime.Compiler = "llgo", we set build.Default.Compiler = "gc" - buildDefault.Compiler = "gc" - - // Verify that runtime.Compiler is still "llgo" (unchanged) - _ = runtime.Compiler + build.Default.Compiler = "gc" }