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/link: document default flags passed to extld #24494

Open
TocarIP opened this issue Mar 22, 2018 · 2 comments
Open

cmd/link: document default flags passed to extld #24494

TocarIP opened this issue Mar 22, 2018 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation
Milestone

Comments

@TocarIP
Copy link
Contributor

TocarIP commented Mar 22, 2018

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

master

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/localdisk/itocar/gocache/"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/localdisk/itocar/gopath/"
GORACE=""
GOROOT="/localdisk/itocar/golang"
GOTMPDIR=""
GOTOOLDIR="/localdisk/itocar/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build748215444=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go build -ldflags="-extld=/path/to/ld.hugetlbfs -linkmode=external" foo.go
I was trying to map code section to huge pages.

What did you expect to see?

Everything works.

What did you see instead?

Linker didn't recognize -m64 option.

Looks like we pass a bunch of gcc/clang specific flags to any external linker.
I worked around this by passing -extld=gcc -extldflags="-B /path/to/ld.hugetlbfs", to use gcc as a linker that recognizes -m64 and calls ld.hugetlbfs without passing -m64, but this behavior was surprising to me and should be documented somewhere (in extld documentation?)

@ianlancetaylor
Copy link
Contributor

To be honest, I would prefer to not have to document this. These options are very likely to change in the future. Documenting them would give some presumption of consistency even if we explicitly disclaim it. Since we effectively reserve the right to pass any option that is accepted by the standard linker on the platform, there is nothing useful you can gain from any documentation.

@TocarIP
Copy link
Contributor Author

TocarIP commented Mar 23, 2018

reserve the right to pass any option that is accepted by the standard linker on the platform

How about adding this to extld description? Something like
"Linker should be option compatible with default linker"

@andybons andybons added this to the Unplanned milestone Mar 26, 2018
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation
Projects
None yet
Development

No branches or pull requests

4 participants