Merge pull request #331 from aofei/build
build: force use of LLVM Linker (lld) and fix usage of -dead_strip on Linux
This commit is contained in:
@@ -286,14 +286,19 @@ 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 = 5
|
const N = 6
|
||||||
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] = "-Xlinker"
|
args[3] = "-fuse-ld=lld"
|
||||||
args[4] = "-dead_strip"
|
args[4] = "-Xlinker"
|
||||||
//args[5] = "-O2"
|
if runtime.GOOS == "darwin" { // ld64.lld (macOS)
|
||||||
|
args[5] = "-dead_strip"
|
||||||
|
} else { // ld.lld (Unix), lld-link (Windows), wasm-ld (WebAssembly)
|
||||||
|
args[5] = "--gc-sections"
|
||||||
|
}
|
||||||
|
//args[6] = "-O2"
|
||||||
needRuntime := false
|
needRuntime := false
|
||||||
needPyInit := false
|
needPyInit := false
|
||||||
packages.Visit([]*packages.Package{pkg}, nil, func(p *packages.Package) {
|
packages.Visit([]*packages.Package{pkg}, nil, func(p *packages.Package) {
|
||||||
|
|||||||
Reference in New Issue
Block a user