From d9e2ba4fcce0a405e2d103e43c19f01fa1a5401d Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 19 Dec 2018 07:03:04 -0800 Subject: [PATCH] cmd/cgo: ensure the command passed to run retains a trailing dash This was accidentally broken by CL 127755. Fixes #29333 Change-Id: I5e92048c64a55c1699d6c38eb4dbbd51c817b820 Reviewed-on: https://go-review.googlesource.com/c/155037 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- misc/cgo/test/issue4339.go | 3 ++- src/cmd/cgo/gcc.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/misc/cgo/test/issue4339.go b/misc/cgo/test/issue4339.go index 4fa4b2bbd7..3715fde575 100644 --- a/misc/cgo/test/issue4339.go +++ b/misc/cgo/test/issue4339.go @@ -5,7 +5,8 @@ package cgotest /* -#include "issue4339.h" +// We've historically permitted #include <>, so test it here. Issue 29333. +#include */ import "C" diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 27bd59b54e..11c3ff3a9c 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -1992,8 +1992,10 @@ func (p *Package) gccErrors(stdin []byte) string { } } - // Force -O0 optimization + // Force -O0 optimization but keep the trailing "-" at the end. nargs = append(nargs, "-O0") + nl := len(nargs) + nargs[nl-2], nargs[nl-1] = nargs[nl-1], nargs[nl-2] if *debugGcc { fmt.Fprintf(os.Stderr, "$ %s <