From ee0aa3965726111689955e248004ce4e48f7bc63 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 9 Apr 2018 20:01:36 -0700 Subject: [PATCH] cmd/go: compile packages imported by runtime with -+ Packages imported by the runtime should follow the same memory allocation rules as the runtime package. Change-Id: Id3fadb05605acbd6ac61d7fe6068a2add8bb2308 Reviewed-on: https://go-review.googlesource.com/105995 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick Reviewed-by: Keith Randall --- src/cmd/go/internal/work/gc.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go index 3ccc2c1d14..2d61e54333 100644 --- a/src/cmd/go/internal/work/gc.go +++ b/src/cmd/go/internal/work/gc.go @@ -57,9 +57,14 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, a gcargs = append(gcargs, "-std") } compilingRuntime := p.Standard && (p.ImportPath == "runtime" || strings.HasPrefix(p.ImportPath, "runtime/internal")) + // The runtime package imports a couple of general internal packages. + if p.Standard && (p.ImportPath == "internal/cpu" || p.ImportPath == "internal/bytealg") { + compilingRuntime = true + } if compilingRuntime { - // runtime compiles with a special gc flag to emit - // additional reflect type data. + // runtime compiles with a special gc flag to check for + // memory allocations that are invalid in the runtime package, + // and to implement some special compiler pragmas. gcargs = append(gcargs, "-+") } -- 2.50.0