Merge pull request #524 from visualfc/sizes

build: fix unsafe.Sizeof for llgo:type C
This commit is contained in:
xushiwei
2024-07-18 06:58:33 +08:00
committed by GitHub
11 changed files with 283 additions and 168 deletions

View File

@@ -19,6 +19,7 @@ package build
import (
"debug/macho"
"fmt"
"go/ast"
"go/constant"
"go/token"
"go/types"
@@ -137,6 +138,12 @@ func Do(args []string, conf *Config) {
prog := llssa.NewProgram(nil)
sizes := prog.TypeSizes
dedup := packages.NewDeduper()
dedup.SetPreload(func(pkg *types.Package, files []*ast.File) {
if canSkipToBuild(pkg.Path()) {
return
}
cl.ParsePkgSyntax(prog, pkg, files)
})
if patterns == nil {
patterns = []string{"."}
@@ -257,7 +264,6 @@ func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs
case cl.PkgDeclOnly:
// skip packages that only contain declarations
// and set no export file
cl.ParsePkgSyntax(ctx.prog, pkg.Types, pkg.Syntax)
pkg.ExportFile = ""
case cl.PkgLinkIR, cl.PkgLinkExtern, cl.PkgPyModule:
if len(pkg.GoFiles) > 0 {