Skip to content

Commit 9edaa8e

Browse files
authored
Merge pull request #1010 from cpunion/fix-empty-content
build: fix empty .ll file name generation
2 parents 019c482 + 32587c1 commit 9edaa8e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

compiler/internal/build/build.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs
306306
}
307307
linkParts := concatPkgLinkFiles(ctx, pkg, verbose)
308308
allParts := append(linkParts, cgoLdflags...)
309-
allParts = append(allParts, pkg.ExportFile)
309+
if pkg.ExportFile != "" {
310+
allParts = append(allParts, pkg.ExportFile)
311+
}
310312
aPkg.LinkArgs = allParts
311313
} else {
312314
// panic("todo")
@@ -358,7 +360,9 @@ func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs
358360
if err != nil {
359361
panic(err)
360362
}
361-
aPkg.LinkArgs = append(cgoLdflags, pkg.ExportFile)
363+
if pkg.ExportFile != "" {
364+
aPkg.LinkArgs = append(cgoLdflags, pkg.ExportFile)
365+
}
362366
aPkg.LinkArgs = append(aPkg.LinkArgs, concatPkgLinkFiles(ctx, pkg, verbose)...)
363367
if aPkg.AltPkg != nil {
364368
aPkg.LinkArgs = append(aPkg.LinkArgs, concatPkgLinkFiles(ctx, aPkg.AltPkg.Package, verbose)...)
@@ -612,14 +616,16 @@ func buildPkg(ctx *context, aPkg *aPackage, verbose bool) (cgoLdflags []string,
612616
}
613617
cgoLdflags = append(cgoLdflags, altLdflags...)
614618
}
615-
pkg.ExportFile += ".ll"
616-
os.WriteFile(pkg.ExportFile, []byte(ret.String()), 0644)
617-
if debugBuild || verbose {
618-
fmt.Fprintf(os.Stderr, "==> Export %s: %s\n", aPkg.PkgPath, pkg.ExportFile)
619-
}
620-
if IsCheckEnable() {
621-
if err, msg := llcCheck(ctx.env, pkg.ExportFile); err != nil {
622-
fmt.Fprintf(os.Stderr, "==> lcc %v: %v\n%v\n", pkg.PkgPath, pkg.ExportFile, msg)
619+
if pkg.ExportFile != "" {
620+
pkg.ExportFile += ".ll"
621+
os.WriteFile(pkg.ExportFile, []byte(ret.String()), 0644)
622+
if debugBuild || verbose {
623+
fmt.Fprintf(os.Stderr, "==> Export %s: %s\n", aPkg.PkgPath, pkg.ExportFile)
624+
}
625+
if IsCheckEnable() {
626+
if err, msg := llcCheck(ctx.env, pkg.ExportFile); err != nil {
627+
fmt.Fprintf(os.Stderr, "==> lcc %v: %v\n%v\n", pkg.PkgPath, pkg.ExportFile, msg)
628+
}
623629
}
624630
}
625631
return

0 commit comments

Comments
 (0)