From 32587c1a404835bb6d220578d74d22b6b2e59886 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Sat, 22 Feb 2025 09:25:44 +0800 Subject: [PATCH] build: fix empty .ll file name generation --- compiler/internal/build/build.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/compiler/internal/build/build.go b/compiler/internal/build/build.go index 11455c05..3e2ad6ac 100644 --- a/compiler/internal/build/build.go +++ b/compiler/internal/build/build.go @@ -306,7 +306,9 @@ func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs } linkParts := concatPkgLinkFiles(ctx, pkg, verbose) allParts := append(linkParts, cgoLdflags...) - allParts = append(allParts, pkg.ExportFile) + 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) } - aPkg.LinkArgs = append(cgoLdflags, pkg.ExportFile) + 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,14 +616,16 @@ func buildPkg(ctx *context, aPkg *aPackage, verbose bool) (cgoLdflags []string, } cgoLdflags = append(cgoLdflags, altLdflags...) } - pkg.ExportFile += ".ll" - os.WriteFile(pkg.ExportFile, []byte(ret.String()), 0644) - if debugBuild || verbose { - fmt.Fprintf(os.Stderr, "==> Export %s: %s\n", aPkg.PkgPath, pkg.ExportFile) - } - if IsCheckEnable() { - if err, msg := llcCheck(ctx.env, pkg.ExportFile); err != nil { - fmt.Fprintf(os.Stderr, "==> lcc %v: %v\n%v\n", pkg.PkgPath, pkg.ExportFile, msg) + if pkg.ExportFile != "" { + pkg.ExportFile += ".ll" + os.WriteFile(pkg.ExportFile, []byte(ret.String()), 0644) + if debugBuild || verbose { + fmt.Fprintf(os.Stderr, "==> Export %s: %s\n", aPkg.PkgPath, pkg.ExportFile) + } + if IsCheckEnable() { + if err, msg := llcCheck(ctx.env, pkg.ExportFile); err != nil { + fmt.Fprintf(os.Stderr, "==> lcc %v: %v\n%v\n", pkg.PkgPath, pkg.ExportFile, msg) + } } } return