-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: compiling position independant code with CGO_ENABLED=0 seems broken #17789
Comments
While the error message here suggests there might be some configuration bug in how we are interpreting CGO_ENABLED, I believe the underlying problem is fixed at tip. Could you try with Go build from source? I believe that the fact that for GOOS=linux GOARCH=amd64 the 1.8 Go linker will now internally link a PIE executable means this should work. |
This works on linux! However, on windows I get the following:
It looks like the asm tool is being invoked incorrectly perhaps ? |
Can you add |
Yes, this is the output:
|
The usage error is occurring because the go tool is passing both asm.s and asm_amd64.s to a single invocation of the asm tool. The asm tool only takes a single input file. But I really can't imagine what would cause the go tool to do that. I do notice that you are running D:/src/gotip/bin/go.exe but the assembler it is invoking is C:\apps\Go\pkg\tool\windows_amd64\asm.exe. Do you have |
Good catch ... Unsetting GOROOT fixes this issue, though I'm unsure as to why oO |
Is there still an issue here, or should we close this? |
sent from my phone, please excuse brevity On 5 Nov 2016 06:23, "Ian Lance Taylor" notifications@github.com wrote:
I think the assembler can process multiple files in one invocation at tip, |
There is no bug at tip. And while CGO_ENABLED=0 is not the same as internal linking, the two concepts are close enough that I think it's reasonable that buildmode=pie in 1.7 requires cgo. So I'm closing this. @PSG-Luna please reply to this if you still think there's a bug here. |
### What version of Go are you using (
go version
)?Linux: go version go1.7.3 linux/amd64
Windows: go version go1.7.3 windows/amd64
### What operating system and processor architecture are you using (
go env
)?Linux:
Windows:
### What did you do?
I've tried building the following Go program:
using the following command:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildmode=pie
### What did you expect to see?
I expected Go to build a position independant binary with no dependencies on libc, for use on alpine
### What did you see instead?
On linux:
On windows:
The text was updated successfully, but these errors were encountered: