refactor: address final review comments
- Created zcgo.go with defaultCGO_ENABLED constant (Go 1.24 pattern) - Updated parseGoVersion to panic on unexpected input instead of fallback - Added runtime.(*Func).Name stub to symtab.go for Go 1.21/1.22 compatibility - Removed go1.23 build constraint from demo - Removed internal/buildcfg package (replaced by zcgo.go) These changes ensure the demo works across Go 1.21+ versions. 🤖 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
//go:build go1.23
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
@@ -15,8 +15,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
_ "unsafe"
|
||||
|
||||
"github.com/goplus/llgo/runtime/internal/lib/internal/buildcfg"
|
||||
)
|
||||
|
||||
// Type aliases to reference standard library types
|
||||
@@ -63,7 +61,7 @@ func parseGoVersion() int {
|
||||
return minor
|
||||
}
|
||||
}
|
||||
return 24
|
||||
panic("parseGoVersion: cannot parse go version from runtime.Version(): " + runtime.Version())
|
||||
}
|
||||
|
||||
// defaultContext returns the default Context for builds.
|
||||
@@ -95,7 +93,7 @@ func defaultContext() Context {
|
||||
|
||||
env := os.Getenv("CGO_ENABLED")
|
||||
if env == "" {
|
||||
env = buildcfg.DefaultCGO_ENABLED
|
||||
env = defaultCGO_ENABLED
|
||||
}
|
||||
switch env {
|
||||
case "1":
|
||||
|
||||
7
runtime/internal/lib/go/build/zcgo.go
Normal file
7
runtime/internal/lib/go/build/zcgo.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// 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
|
||||
|
||||
const defaultCGO_ENABLED = "1"
|
||||
@@ -1,12 +0,0 @@
|
||||
// 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 buildcfg
|
||||
|
||||
// llgo:skipall
|
||||
type _buildcfg struct{}
|
||||
|
||||
// DefaultCGO_ENABLED is the default value for CGO_ENABLED
|
||||
// when the environment variable is not set.
|
||||
const DefaultCGO_ENABLED = "1"
|
||||
@@ -140,6 +140,10 @@ type Func struct {
|
||||
opaque struct{} // unexported field to disallow conversions
|
||||
}
|
||||
|
||||
func (f *Func) Name() string {
|
||||
panic("todo")
|
||||
}
|
||||
|
||||
// moduledata records information about the layout of the executable
|
||||
// image. It is written by the linker. Any changes here must be
|
||||
// matched changes to the code in cmd/link/internal/ld/symtab.go:symtab.
|
||||
|
||||
Reference in New Issue
Block a user