runtime: config hasAltPkg and ignoreName
This commit is contained in:
@@ -30,6 +30,7 @@ import (
|
||||
|
||||
"github.com/goplus/llgo/compiler/internal/env"
|
||||
llssa "github.com/goplus/llgo/compiler/ssa"
|
||||
llruntime "github.com/goplus/llgo/runtime"
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -668,4 +669,8 @@ func replaceGoName(v string, pos int) string {
|
||||
return v
|
||||
}
|
||||
|
||||
func ignoreName(name string) bool {
|
||||
return llruntime.IgnoreName(name)
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -46,6 +46,7 @@ import (
|
||||
"github.com/goplus/llgo/xtool/env/llvm"
|
||||
|
||||
llssa "github.com/goplus/llgo/compiler/ssa"
|
||||
llruntime "github.com/goplus/llgo/runtime"
|
||||
clangCheck "github.com/goplus/llgo/xtool/clang/check"
|
||||
)
|
||||
|
||||
@@ -154,7 +155,7 @@ func Do(args []string, conf *Config) ([]Package, error) {
|
||||
sizes := prog.TypeSizes
|
||||
dedup := packages.NewDeduper()
|
||||
dedup.SetPreload(func(pkg *types.Package, files []*ast.File) {
|
||||
if canSkipToBuild(pkg.Path()) {
|
||||
if llruntime.SkipToBuild(pkg.Path()) {
|
||||
return
|
||||
}
|
||||
cl.ParsePkgSyntax(prog, pkg, files)
|
||||
@@ -580,7 +581,7 @@ func buildPkg(ctx *context, aPkg *aPackage, verbose bool) (cgoLdflags []string,
|
||||
if debugBuild || verbose {
|
||||
fmt.Fprintln(os.Stderr, pkgPath)
|
||||
}
|
||||
if canSkipToBuild(pkgPath) {
|
||||
if llruntime.SkipToBuild(pkgPath) {
|
||||
pkg.ExportFile = ""
|
||||
return
|
||||
}
|
||||
@@ -642,8 +643,8 @@ const (
|
||||
func altPkgs(initial []*packages.Package, alts ...string) []string {
|
||||
packages.Visit(initial, nil, func(p *packages.Package) {
|
||||
if p.Types != nil && !p.IllTyped {
|
||||
if _, ok := hasAltPkg[p.ID]; ok {
|
||||
alts = append(alts, altPkgPathPrefix+p.ID)
|
||||
if llruntime.HasAltPkg(p.PkgPath) {
|
||||
alts = append(alts, altPkgPathPrefix+p.PkgPath)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -691,7 +692,7 @@ func allPkgs(ctx *context, initial []*packages.Package, verbose bool) (all []*aP
|
||||
}
|
||||
var altPkg *packages.Cached
|
||||
var ssaPkg = createSSAPkg(prog, p, verbose)
|
||||
if _, ok := hasAltPkg[pkgPath]; ok {
|
||||
if llruntime.HasAltPkg(pkgPath) {
|
||||
if altPkg = ctx.dedup.Check(altPkgPathPrefix + pkgPath); altPkg == nil {
|
||||
return
|
||||
}
|
||||
@@ -864,13 +865,6 @@ func pkgExists(initial []*packages.Package, pkg *packages.Package) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func canSkipToBuild(pkgPath string) bool {
|
||||
if _, ok := hasAltPkg[pkgPath]; ok {
|
||||
return false
|
||||
}
|
||||
return pkgPath == "unsafe"
|
||||
}
|
||||
|
||||
// findDylibDep finds the dylib dependency in the executable. It returns empty
|
||||
// string if not found.
|
||||
func findDylibDep(exe, lib string) string {
|
||||
@@ -889,49 +883,6 @@ func findDylibDep(exe, lib string) string {
|
||||
|
||||
type none struct{}
|
||||
|
||||
var hasAltPkg = map[string]none{
|
||||
"crypto/hmac": {},
|
||||
"crypto/md5": {},
|
||||
"crypto/rand": {},
|
||||
"crypto/sha1": {},
|
||||
"crypto/sha256": {},
|
||||
"crypto/sha512": {},
|
||||
"crypto/subtle": {},
|
||||
"go/parser": {},
|
||||
"hash/crc32": {},
|
||||
"internal/abi": {},
|
||||
"internal/bytealg": {},
|
||||
"internal/cpu": {},
|
||||
"internal/itoa": {},
|
||||
"internal/filepathlite": {},
|
||||
"internal/godebug": {},
|
||||
"internal/oserror": {},
|
||||
"internal/poll": {},
|
||||
"internal/race": {},
|
||||
"internal/reflectlite": {},
|
||||
"internal/stringslite": {},
|
||||
"internal/syscall/execenv": {},
|
||||
"internal/syscall/unix": {},
|
||||
"math": {},
|
||||
"math/big": {},
|
||||
"math/cmplx": {},
|
||||
"math/rand": {},
|
||||
"reflect": {},
|
||||
"sync": {},
|
||||
"sync/atomic": {},
|
||||
"syscall": {},
|
||||
"time": {},
|
||||
"os": {},
|
||||
"os/exec": {},
|
||||
"os/signal": {},
|
||||
"runtime": {},
|
||||
"runtime/debug": {},
|
||||
"runtime/pprof": {},
|
||||
"runtime/trace": {},
|
||||
"runtime/internal/syscall": {},
|
||||
"io": {},
|
||||
}
|
||||
|
||||
func check(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user