refactor: use go:linkname to link internal/platform.CgoSupported
Instead of creating a custom platform package, use the go:linkname directive to directly link to Go's standard library internal/platform.CgoSupported function. This approach: - Eliminates the need to maintain a copy of platform support data - Uses Go's canonical platform information directly - Reduces code duplication and maintenance burden - Follows Go's linkname pattern for accessing internal packages Changes: - Added import _ "unsafe" to enable linkname - Added //go:linkname directive for cgoSupported function - Removed custom runtime/internal/lib/internal/platform package - Updated function call from platform.CgoSupported to cgoSupported 🤖 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
This commit is contained in:
@@ -14,8 +14,7 @@ import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/goplus/llgo/runtime/internal/lib/internal/platform"
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
// Type aliases to reference standard library types
|
||||
@@ -79,7 +78,7 @@ func defaultContext() Context {
|
||||
c.CgoEnabled = false
|
||||
default:
|
||||
if runtime.GOARCH == c.GOARCH && runtime.GOOS == c.GOOS {
|
||||
c.CgoEnabled = platform.CgoSupported(c.GOOS, c.GOARCH)
|
||||
c.CgoEnabled = cgoSupported(c.GOOS, c.GOARCH)
|
||||
break
|
||||
}
|
||||
c.CgoEnabled = false
|
||||
@@ -122,3 +121,6 @@ func buildToolTags() []string {
|
||||
"goexperiment.boringcrypto", // Default boring crypto experiment
|
||||
}
|
||||
}
|
||||
|
||||
//go:linkname cgoSupported internal/platform.CgoSupported
|
||||
func cgoSupported(goos, goarch string) bool
|
||||
|
||||
Reference in New Issue
Block a user