diff --git a/cl/compile.go b/cl/compile.go index d3977318..ec18c06f 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -25,7 +25,6 @@ import ( "log" "os" "sort" - "strings" "github.com/goplus/llgo/cl/blocks" "github.com/goplus/llgo/internal/typepatch" @@ -91,20 +90,6 @@ func (p *context) pkgNoInit(pkg *types.Package) bool { return false } -func ignoreName(name string) bool { - /* TODO(xsw): confirm this is not needed more - if name == "unsafe.init" { - return true - } - */ - return strings.HasPrefix(name, "internal/") || strings.HasPrefix(name, "crypto/") || - strings.HasPrefix(name, "arena.") || strings.HasPrefix(name, "maps.") || - strings.HasPrefix(name, "time.") || strings.HasPrefix(name, "syscall.") || - strings.HasPrefix(name, "os.") || strings.HasPrefix(name, "plugin.") || - strings.HasPrefix(name, "reflect.") || strings.HasPrefix(name, "errors.") || - strings.HasPrefix(name, "runtime/") -} - // ----------------------------------------------------------------------------- type instrOrValue interface { diff --git a/cl/import.go b/cl/import.go index 21979310..fbbf4408 100644 --- a/cl/import.go +++ b/cl/import.go @@ -490,6 +490,20 @@ func replaceGoName(v string, pos int) string { return v } +func ignoreName(name string) bool { + /* TODO(xsw): confirm this is not needed more + if name == "unsafe.init" { + return true + } + */ + return strings.HasPrefix(name, "internal/") || strings.HasPrefix(name, "crypto/") || + strings.HasPrefix(name, "arena.") || strings.HasPrefix(name, "maps.") || + strings.HasPrefix(name, "time.") || strings.HasPrefix(name, "syscall.") || + strings.HasPrefix(name, "os.") || strings.HasPrefix(name, "plugin.") || + strings.HasPrefix(name, "reflect.") || strings.HasPrefix(name, "errors.") || + strings.HasPrefix(name, "runtime/") +} + // ----------------------------------------------------------------------------- const ( diff --git a/cmd/internal/base/base.go b/cmd/internal/base/base.go index 440cdf4a..e23061cf 100644 --- a/cmd/internal/base/base.go +++ b/cmd/internal/base/base.go @@ -52,7 +52,7 @@ type Command struct { // Llgo command var Llgo = &Command{ UsageLine: "llgo", - Short: `llgo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem.`, + Short: `llgo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python.`, // Commands initialized in package main } diff --git a/internal/build/build.go b/internal/build/build.go index 247546c1..d1a522fb 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -292,18 +292,18 @@ func linkMainPkg(pkg *packages.Package, pkgs []*aPackage, runtimeFiles []string, if app == "" { app = filepath.Join(conf.BinPath, name+conf.AppExt) } - const N = 6 + const N = 5 args := make([]string, N, len(pkg.Imports)+len(runtimeFiles)+(N+1)) args[0] = "-o" args[1] = app args[2] = "-Wno-override-module" - args[3] = "-fuse-ld=lld" - args[4] = "-Xlinker" + args[3] = "-Xlinker" if runtime.GOOS == "darwin" { // ld64.lld (macOS) - args[5] = "-dead_strip" + args[4] = "-dead_strip" } else { // ld.lld (Unix), lld-link (Windows), wasm-ld (WebAssembly) - args[5] = "--gc-sections" + args[4] = "--gc-sections" } + //args[5] = "-fuse-ld=lld" // TODO(xsw): to check lld exists or not //args[6] = "-O2" needRuntime := false needPyInit := false @@ -399,25 +399,6 @@ func buildPkg(ctx *context, aPkg *aPackage) { aPkg.LPkg = ret } -func canSkipToBuild(pkgPath string) bool { - switch pkgPath { - case "unsafe", "errors", "runtime", "sync": // TODO(xsw): remove it - return true - default: - return strings.HasPrefix(pkgPath, "internal/") || - strings.HasPrefix(pkgPath, "runtime/internal/") - } -} - -type none struct{} - -var hasAltPkg = map[string]none{ - "math": {}, - "sync": {}, - "sync/atomic": {}, - "runtime": {}, -} - const ( altPkgPathPrefix = "github.com/goplus/llgo/internal/lib/" ) @@ -468,7 +449,9 @@ func allPkgs(ctx *context, initial []*packages.Package) (all []*aPackage, errs [ var altPkg *packages.Cached var ssaPkg = createSSAPkg(prog, p, verbose) if _, ok := hasAltPkg[p.PkgPath]; ok { - altPkg = ctx.dedup.Check(altPkgPathPrefix + p.PkgPath) + if altPkg = ctx.dedup.Check(altPkgPathPrefix + p.PkgPath); altPkg == nil { + return + } } all = append(all, &aPackage{p, ssaPkg, altPkg, nil}) } else { @@ -685,6 +668,25 @@ func decodeFile(outFile string, zipf *zip.File) (err error) { return } +func canSkipToBuild(pkgPath string) bool { + switch pkgPath { + case "unsafe", "errors": // TODO(xsw): remove it + return true + default: + return strings.HasPrefix(pkgPath, "internal/") || + strings.HasPrefix(pkgPath, "runtime/internal/") + } +} + +type none struct{} + +var hasAltPkg = map[string]none{ + "math": {}, + "sync": {}, + "sync/atomic": {}, + "runtime": {}, +} + func check(err error) { if err != nil { panic(err)