merge upstream

This commit is contained in:
xushiwei
2024-06-17 19:33:27 +08:00
8 changed files with 188 additions and 114 deletions

View File

@@ -290,7 +290,7 @@ func linkMainPkg(pkg *packages.Package, pkgs []*aPackage, llFiles []string, conf
if app == "" {
app = filepath.Join(conf.BinPath, name+conf.AppExt)
}
const N = 5
const N = 6
args := make([]string, N, len(pkg.Imports)+len(llFiles)+(N+1))
args[0] = "-o"
args[1] = app
@@ -298,11 +298,13 @@ func linkMainPkg(pkg *packages.Package, pkgs []*aPackage, llFiles []string, conf
args[3] = "-Xlinker"
if runtime.GOOS == "darwin" { // ld64.lld (macOS)
args[4] = "-dead_strip"
args[5] = "" // It's ok to leave it empty, as we can assume libpthread is built-in on macOS.
} else { // ld.lld (Unix), lld-link (Windows), wasm-ld (WebAssembly)
args[4] = "--gc-sections"
args[5] = "-lpthread" // libpthread is built-in since glibc 2.34 (2021-08-01); we need to support earlier versions.
}
//args[5] = "-fuse-ld=lld" // TODO(xsw): to check lld exists or not
//args[6] = "-O2"
//args[6] = "-fuse-ld=lld" // TODO(xsw): to check lld exists or not
//args[7] = "-O2"
needRuntime := false
needPyInit := false
packages.Visit([]*packages.Package{pkg}, nil, func(p *packages.Package) {