From e7ec06e000627ad699a274a5a672bc3f63d6a709 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 7 Feb 2017 07:28:49 -0800 Subject: [PATCH] cmd/go: copy FFLAGS from build.Package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #18975. Change-Id: I60dfb299233ecfed4b2da93750ea84e7921f1fbb Reviewed-on: https://go-review.googlesource.com/36482 Run-TryBot: Ian Lance Taylor Reviewed-by: Daniel Martí Reviewed-by: Russ Cox TryBot-Result: Gobot Gobot --- src/cmd/go/go_test.go | 21 +++++++++++++++++++++ src/cmd/go/internal/load/pkg.go | 1 + 2 files changed, 22 insertions(+) diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 09b6042c0fd..06e87798d0f 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -3777,3 +3777,24 @@ func TestA(t *testing.T) {}`) tg.grepStdout("pkgs$", "expected package not listed") tg.grepStdout("pkgs/a", "expected package not listed") } + +// Issue 18975. +func TestFFLAGS(t *testing.T) { + if !canCgo { + t.Skip("skipping because cgo not enabled") + } + + tg := testgo(t) + defer tg.cleanup() + tg.parallel() + + tg.tempFile("p/src/p/main.go", `package main + // #cgo FFLAGS: -no-such-fortran-flag + import "C" + func main() {} + `) + tg.tempFile("p/src/p/a.f", `! comment`) + tg.setenv("GOPATH", tg.path("p")) + tg.runFail("build", "-x", "p") + tg.grepStderr("no-such-fortran-flag", `missing expected "-no-such-fortran-flag"`) +} diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 11dd6815df6..bf91bb74ada 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -184,6 +184,7 @@ func (p *Package) copyBuild(pp *build.Package) { p.CgoCFLAGS = pp.CgoCFLAGS p.CgoCPPFLAGS = pp.CgoCPPFLAGS p.CgoCXXFLAGS = pp.CgoCXXFLAGS + p.CgoFFLAGS = pp.CgoFFLAGS p.CgoLDFLAGS = pp.CgoLDFLAGS p.CgoPkgConfig = pp.CgoPkgConfig // We modify p.Imports in place, so make copy now.