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/go: -x flag doesn't print executable output if cgo is used #21427

Closed
hirochachacha opened this issue Aug 13, 2017 · 4 comments
Closed

cmd/go: -x flag doesn't print executable output if cgo is used #21427

hirochachacha opened this issue Aug 13, 2017 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hirochachacha
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

package main

import "C"

func main() {}
$ go build -x x.go 2> test.bash
$ bash test.bash

What did you expect to see?

no errors.

What did you see instead?

test.bash: line 5: -O2: command not found
clang: error: no such file or directory: 'trivial.c'
clang: error: no input files
clang: error: no such file or directory: 'trivial.c'
clang: error: no input files
clang: error: no such file or directory: '_cgo_export.c'
clang: error: no input files
clang: error: no such file or directory: 'x.cgo2.c'
clang: error: no input files
clang: error: no such file or directory: '_cgo_main.c'
clang: error: no input files
clang: error: no such file or directory: '/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/_cgo_main.o'
clang: error: no such file or directory: '/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/_cgo_export.o'
clang: error: no such file or directory: '/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/x.cgo2.o'
clang: error: no input files
cannot parse /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/_cgo_.o as ELF, Mach-O or PE
clang: error: unknown argument: '-no-pie'
clang: error: no such file or directory: 'trivial.c'
clang: error: no input files
clang: error: no such file or directory: 'trivial.c'
clang: error: no input files
clang: error: no such file or directory: '/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/_cgo_export.o'
clang: error: no such file or directory: '/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/x.cgo2.o'
/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/_cgo_gotypes.go:0:0: open /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/_cgo_gotypes.go: no such file or directory
test.bash: line 22: pack: command not found
/Users/hiro/go/pkg/tool/darwin_amd64/link: cannot open file /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments.a: open /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments.a: no such file or directory
mv: /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build826286268/command-line-arguments/_obj/exe/a.out: No such file or directory

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

I think so.

System details

go version devel +09ed0f6805 Sun Aug 13 10:08:42 2017 +0000 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hiro/.go"
GORACE=""
GOROOT="/Users/hiro/go"
GOTOOLDIR="/Users/hiro/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build794106771=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version devel +09ed0f6805 Sun Aug 13 10:08:42 2017 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel +09ed0f6805 Sun Aug 13 10:08:42 2017 +0000
uname -v: Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G29
lldb --version: lldb-370.0.42
  Swift-3.1
gdb --version: GNU gdb (GDB) 7.12.1

Maybe this is not a bug report, but a feature request.
I think producing real commands is helpful for debugging.

@ianlancetaylor
Copy link
Contributor

The problem is in the display of CGO_LDFLAGS. It probably needs to be fixed in Builder.runOut in cmd/go/internal/work/build.go.

@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Aug 14, 2017
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 14, 2017
@hirochachacha
Copy link
Contributor Author

Thanks. I'll take a look.

@gopherbot
Copy link

Change https://golang.org/cl/55350 mentions this issue: cmd/go: print executable shell command if -x flag is used

@gopherbot
Copy link

Change https://golang.org/cl/84736 mentions this issue: cmd/go: make -x output commands executable again

@golang golang locked and limited conversation to collaborators Dec 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants