canSkipToBuild
This commit is contained in:
@@ -25,7 +25,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/goplus/llgo/cl/blocks"
|
"github.com/goplus/llgo/cl/blocks"
|
||||||
"github.com/goplus/llgo/internal/typepatch"
|
"github.com/goplus/llgo/internal/typepatch"
|
||||||
@@ -91,20 +90,6 @@ func (p *context) pkgNoInit(pkg *types.Package) bool {
|
|||||||
return false
|
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 {
|
type instrOrValue interface {
|
||||||
|
|||||||
14
cl/import.go
14
cl/import.go
@@ -490,6 +490,20 @@ func replaceGoName(v string, pos int) string {
|
|||||||
return v
|
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 (
|
const (
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ type Command struct {
|
|||||||
// Llgo command
|
// Llgo command
|
||||||
var Llgo = &Command{
|
var Llgo = &Command{
|
||||||
UsageLine: "llgo",
|
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
|
// Commands initialized in package main
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -292,18 +292,18 @@ func linkMainPkg(pkg *packages.Package, pkgs []*aPackage, runtimeFiles []string,
|
|||||||
if app == "" {
|
if app == "" {
|
||||||
app = filepath.Join(conf.BinPath, name+conf.AppExt)
|
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 := make([]string, N, len(pkg.Imports)+len(runtimeFiles)+(N+1))
|
||||||
args[0] = "-o"
|
args[0] = "-o"
|
||||||
args[1] = app
|
args[1] = app
|
||||||
args[2] = "-Wno-override-module"
|
args[2] = "-Wno-override-module"
|
||||||
args[3] = "-fuse-ld=lld"
|
args[3] = "-Xlinker"
|
||||||
args[4] = "-Xlinker"
|
|
||||||
if runtime.GOOS == "darwin" { // ld64.lld (macOS)
|
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)
|
} 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"
|
//args[6] = "-O2"
|
||||||
needRuntime := false
|
needRuntime := false
|
||||||
needPyInit := false
|
needPyInit := false
|
||||||
@@ -399,25 +399,6 @@ func buildPkg(ctx *context, aPkg *aPackage) {
|
|||||||
aPkg.LPkg = ret
|
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 (
|
const (
|
||||||
altPkgPathPrefix = "github.com/goplus/llgo/internal/lib/"
|
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 altPkg *packages.Cached
|
||||||
var ssaPkg = createSSAPkg(prog, p, verbose)
|
var ssaPkg = createSSAPkg(prog, p, verbose)
|
||||||
if _, ok := hasAltPkg[p.PkgPath]; ok {
|
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})
|
all = append(all, &aPackage{p, ssaPkg, altPkg, nil})
|
||||||
} else {
|
} else {
|
||||||
@@ -685,6 +668,25 @@ func decodeFile(outFile string, zipf *zip.File) (err error) {
|
|||||||
return
|
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) {
|
func check(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user