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 <luoliwoshang@users.noreply.github.com>
This commit is contained in:
@@ -9,19 +9,11 @@ package build
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go/build"
|
"go/build"
|
||||||
"runtime"
|
|
||||||
_ "unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:linkname buildDefault go/build.Default
|
|
||||||
var buildDefault build.Context
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// LLGO PATCH: Override build.Default.Compiler to be "gc" instead of "llgo"
|
// LLGO PATCH: Override build.Default.Compiler to be "gc" instead of "llgo"
|
||||||
// This prevents "unknown compiler" errors when user code uses go/build package
|
// This prevents "unknown compiler" errors when user code uses go/build package
|
||||||
// Even though runtime.Compiler = "llgo", we set build.Default.Compiler = "gc"
|
// Even though runtime.Compiler = "llgo", we set build.Default.Compiler = "gc"
|
||||||
buildDefault.Compiler = "gc"
|
build.Default.Compiler = "gc"
|
||||||
|
|
||||||
// Verify that runtime.Compiler is still "llgo" (unchanged)
|
|
||||||
_ = runtime.Compiler
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user