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/asm: default include directories should include $GOROOT/pkg/include #41166

Closed
clausecker opened this issue Sep 1, 2020 · 5 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@clausecker
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.15 freebsd/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fuz/.cache/go-build"
GOENV="/home/fuz/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOINSECURE=""
GOMODCACHE="/home/fuz/src/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/fuz/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-I$HOME/include -I/usr/local/include"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-L$HOME/lib -L/usr/local/lib"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build184679857=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Save the following source file as foo.s:

echo '#include "textflag.h"' >foo.s
go tool asm foo.s

What did you expect to see?

Nothing.

What did you see instead?

foo.s:2: #include: open textflag.h: no such file or directory

The asm tool should by default search $GOROOT/pkg/include for include files because nearly every Go assembly file will include at least textflag.h. This path is searched when assembling files through go tool build, so this discrepancy seems strange and unexpected to me. Not having to manually specify -I $GOROOT/pkg/include would be a nice quality of nice quality of life improvement.

@dmitshur
Copy link
Contributor

dmitshur commented Sep 1, 2020

/cc @cherrymui per owners.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 1, 2020
@dmitshur dmitshur added this to the Backlog milestone Sep 1, 2020
@cherrymui
Copy link
Member

As you noted, the -I flag is passed by the go command if you use go build (or go run, go test, etc.). The assembler is not expected to be invoked by hand in general, although it is possible. If you do that, it is up to you to pass the flag.

Closing as working as intended.

@clausecker
Copy link
Author

That's unfortunate to hear. I have been using the asm tool a lot lately to inspect what the assembler does and to ensure that it does what I intend to do (especially wrt. macro expansions). Wouldn't it be possible to at least have a short hand convenience option for this behaviour? Right now, the usability is just very poor.

@dmitshur
Copy link
Contributor

dmitshur commented Sep 1, 2020

@fuzxxl Can this be addressed more effectively at a higher level (i.e., a convenience wrapper around cmd/asm that takes into account the typical workflow you're describing)?

@clausecker
Copy link
Author

@dmitris Possibly. But apart from providing the right search path for include directories, I have no idea what else this wrapper would do. The only idea I have is adding a flag -S to go build that would invoke compile or asm on all source files listed in addition to/instead of compilation. Not sure what the best solution is here.

@golang golang locked and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants