build: fix empty .ll file name generation

This commit is contained in:
Li Jie
2025-02-22 09:25:44 +08:00
parent 019c482d18
commit 32587c1a40

View File

@@ -306,7 +306,9 @@ func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs
}
linkParts := concatPkgLinkFiles(ctx, pkg, verbose)
allParts := append(linkParts, cgoLdflags...)
if pkg.ExportFile != "" {
allParts = append(allParts, pkg.ExportFile)
}
aPkg.LinkArgs = allParts
} else {
// panic("todo")
@@ -358,7 +360,9 @@ func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs
if err != nil {
panic(err)
}
if pkg.ExportFile != "" {
aPkg.LinkArgs = append(cgoLdflags, pkg.ExportFile)
}
aPkg.LinkArgs = append(aPkg.LinkArgs, concatPkgLinkFiles(ctx, pkg, verbose)...)
if aPkg.AltPkg != nil {
aPkg.LinkArgs = append(aPkg.LinkArgs, concatPkgLinkFiles(ctx, aPkg.AltPkg.Package, verbose)...)
@@ -612,6 +616,7 @@ func buildPkg(ctx *context, aPkg *aPackage, verbose bool) (cgoLdflags []string,
}
cgoLdflags = append(cgoLdflags, altLdflags...)
}
if pkg.ExportFile != "" {
pkg.ExportFile += ".ll"
os.WriteFile(pkg.ExportFile, []byte(ret.String()), 0644)
if debugBuild || verbose {
@@ -622,6 +627,7 @@ func buildPkg(ctx *context, aPkg *aPackage, verbose bool) (cgoLdflags []string,
fmt.Fprintf(os.Stderr, "==> lcc %v: %v\n%v\n", pkg.PkgPath, pkg.ExportFile, msg)
}
}
}
return
}