2025-10-15 14:54:29 +00:00
|
|
|
// Copyright 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
// Package build provides alternative implementations for go/build.
|
2025-10-16 13:09:32 +00:00
|
|
|
// We override build.Default.Compiler in an init function.
|
2025-10-15 14:54:29 +00:00
|
|
|
|
|
|
|
|
package build
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"go/build"
|
|
|
|
|
"runtime"
|
2025-10-16 06:05:54 +00:00
|
|
|
_ "unsafe"
|
2025-10-15 14:54:29 +00:00
|
|
|
)
|
|
|
|
|
|
2025-10-16 13:09:32 +00:00
|
|
|
//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
|
2025-10-15 14:54:29 +00:00
|
|
|
}
|