Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: FFLAGS directive is ignored #18975

Closed
idavydov opened this issue Feb 7, 2017 · 1 comment

Comments

@idavydov
Copy link

commented Feb 7, 2017

What did you do?

Trying to pass FFLAGS to go compiler using cgo directive. It seems go is ignoring the flag. Here's a minimal example.

  1. Create files
    test.go:
package main

// #cgo FFLAGS: -wrong-flag
import "C"

import "fmt"

func main() {
	fmt.Println("test")
}

a.f90

! This is a comment line
  1. Building:
    go build -x -v .

What did you expect to see?

Expected to see a compile error (since -wrong-flag is passed to the compiler).

What did you see instead?

Compiled successfully, -wrong-flag is not passed to the compiler.

gfortran -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/_/home/idavydov/tmp/cgo_flags/_obj/ -g -O2 -o $WORK/_/home/idavydov/tmp/cgo_flags/_obj/a.f90.o -c ./a.f90

Passing CGO_FFLAGS="-wrong-flag" produces the desirable effect; so FFLAGS is only ignored as a cgo directive.

gfortran -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/_/home/idavydov/tmp/cgo_flags/_obj/ -wrong-flag -o $WORK/_/home/idavydov/tmp/cgo_flags/_obj/a.f90.o -c ./a.f90
gfortran: error: unrecognized command line option ‘-wrong-flag’

Does this issue reproduce with the latest release (go1.7.5)?

Yes.

System details

go version go1.8rc3 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/idavydov/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build077223555=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
GOROOT/bin/go version: go version go1.8rc3 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.8rc3 X:framepointer
uname -sr: Linux 4.4.0-21-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.1 LTS
Release:	16.04
Codename:	xenial
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.23-0ubuntu5) stable release version 2.23, by Roland McGrath et al.
gdb --version: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1

@ianlancetaylor ianlancetaylor changed the title cgo FFLAGS directive is ignored cmd/cgo: FFLAGS directive is ignored Feb 7, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Feb 7, 2017

CL https://golang.org/cl/36482 mentions this issue.

@gopherbot gopherbot closed this in e7ec06e Feb 10, 2017

@golang golang locked and limited conversation to collaborators Feb 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.