build: remove error return from genMainModule

The genMainModule function never returns an error, so simplified
its signature to return only Package.

Updated:
- genMainModule signature: (Package, error) -> Package
- Call site in build.go to not handle error
- Both test cases to remove error checking

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <8459+cpunion@users.noreply.github.com>
This commit is contained in:
xgopilot
2025-11-14 22:03:36 +00:00
committed by Li Jie
parent 7abb468592
commit 2a4b2ef023
3 changed files with 6 additions and 15 deletions

View File

@@ -29,10 +29,7 @@ func TestGenMainModuleExecutable(t *testing.T) {
},
}
pkg := &packages.Package{PkgPath: "example.com/foo", ExportFile: "foo.a"}
mod, err := genMainModule(ctx, llssa.PkgRuntime, pkg, true, true)
if err != nil {
t.Fatalf("genMainModule() error = %v", err)
}
mod := genMainModule(ctx, llssa.PkgRuntime, pkg, true, true)
if mod.ExportFile != "foo.a-main" {
t.Fatalf("unexpected export file: %s", mod.ExportFile)
}
@@ -62,10 +59,7 @@ func TestGenMainModuleLibrary(t *testing.T) {
},
}
pkg := &packages.Package{PkgPath: "example.com/foo", ExportFile: "foo.a"}
mod, err := genMainModule(ctx, llssa.PkgRuntime, pkg, false, false)
if err != nil {
t.Fatalf("genMainModule() error = %v", err)
}
mod := genMainModule(ctx, llssa.PkgRuntime, pkg, false, false)
ir := mod.LPkg.String()
if strings.Contains(ir, "define i32 @main") {
t.Fatalf("library mode should not emit main function:\n%s", ir)