diff --git a/compiler/cl/builtin_test.go b/compiler/cl/builtin_test.go index 657bc6b2..43e6105c 100644 --- a/compiler/cl/builtin_test.go +++ b/compiler/cl/builtin_test.go @@ -329,6 +329,12 @@ func TestIntVal(t *testing.T) { intVal(&ssa.Parameter{}) } +func TestIgnoreName(t *testing.T) { + if !ignoreName("runtime/foo.bar") || ignoreName("internal/abi.Type") { + t.Fatal("ignoreName failed") + } +} + func TestErrImport(t *testing.T) { var ctx context pkg := types.NewPackage("foo", "foo") diff --git a/compiler/internal/build/build.go b/compiler/internal/build/build.go index 6a8f6184..a8aa3f0b 100644 --- a/compiler/internal/build/build.go +++ b/compiler/internal/build/build.go @@ -134,9 +134,9 @@ func Do(args []string, conf *Config) ([]Package, error) { cfg.Mode |= packages.NeedForTest } - if len(overlayFiles) > 0 { + if len(llruntime.OverlayFiles) > 0 { cfg.Overlay = make(map[string][]byte) - for file, src := range overlayFiles { + for file, src := range llruntime.OverlayFiles { overlay := unsafe.Slice(unsafe.StringData(src), len(src)) cfg.Overlay[filepath.Join(env.GOROOT(), "src", file)] = overlay } diff --git a/compiler/internal/build/_overlay/go/parser/resolver.go b/runtime/_overlay/go/parser/resolver.go similarity index 100% rename from compiler/internal/build/_overlay/go/parser/resolver.go rename to runtime/_overlay/go/parser/resolver.go diff --git a/compiler/internal/build/_overlay/net/textproto/textproto.go b/runtime/_overlay/net/textproto/textproto.go similarity index 100% rename from compiler/internal/build/_overlay/net/textproto/textproto.go rename to runtime/_overlay/net/textproto/textproto.go diff --git a/compiler/internal/build/_overlay/testing/testing.go b/runtime/_overlay/testing/testing.go similarity index 100% rename from compiler/internal/build/_overlay/testing/testing.go rename to runtime/_overlay/testing/testing.go diff --git a/runtime/runtime.go b/runtime/build.go similarity index 87% rename from runtime/runtime.go rename to runtime/build.go index 09bfffc8..37105d9c 100644 --- a/runtime/runtime.go +++ b/runtime/build.go @@ -8,7 +8,7 @@ func SkipToBuild(pkgPath string) bool { if _, ok := hasAltPkg[pkgPath]; ok { return false } - if _, ok := supportInternal[pkgPath]; ok { + if _, ok := supportedInternal[pkgPath]; ok { return false } switch pkgPath { @@ -27,13 +27,14 @@ func IgnoreName(name string) bool { } */ const internal = "internal/" - return (strings.HasPrefix(name, internal) && IsSupportInternal(name)) || + return (strings.HasPrefix(name, internal) && !IsSupportedInternal(name)) || strings.HasPrefix(name, "runtime/") || strings.HasPrefix(name, "arena.") || strings.HasPrefix(name, "maps.") || strings.HasPrefix(name, "plugin.") } -func IsSupportInternal(path string) (b bool) { - _, b = supportInternal[path] +func IsSupportedInternal(name string) (b bool) { + paths := strings.Split(name, ".") + _, b = supportedInternal[paths[0]] return } @@ -75,7 +76,7 @@ var hasAltPkg = map[string]none{ "io": {}, } -var supportInternal = map[string]none{ +var supportedInternal = map[string]none{ "internal/abi": {}, "internal/bytealg": {}, "internal/itoa": {}, diff --git a/compiler/internal/build/overlay.go b/runtime/overlay.go similarity index 88% rename from compiler/internal/build/overlay.go rename to runtime/overlay.go index fd8ff857..62bbea28 100644 --- a/compiler/internal/build/overlay.go +++ b/runtime/overlay.go @@ -1,4 +1,4 @@ -package build +package runtime import ( _ "embed" @@ -13,7 +13,7 @@ var testing_testing string //go:embed _overlay/net/textproto/textproto.go var net_textproto string -var overlayFiles = map[string]string{ +var OverlayFiles = map[string]string{ "math/exp_amd64.go": "package math;", "go/parser/resolver.go": go_parser_resolver, "testing/testing.go": testing_testing,