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

x/crypto: chacha20Poly1305Open: relocation target runtime.cpuid_ebx7 not defined on Windows #24372

Closed
netvipe opened this issue Mar 13, 2018 · 5 comments

Comments

@netvipe
Copy link

@netvipe netvipe commented Mar 13, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.9.4 windows/amd64

Does this issue reproduce with the latest release?

yes

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

What did you do?

I've imported "golang.org/x/crypto/chacha20poly1305" and created instance via chacha20poly1305.New.
Error message appears when compiling code that contains the import.
Already updated to latest golang 1.9 release but some result.

What did you expect to see?

No compiler error

What did you see instead?

golang.org/x/crypto/chacha20poly1305.chacha20Poly1305Open: relocation target runtime.cpuid_ebx7 not defined
golang.org/x/crypto/chacha20poly1305.chacha20Poly1305Seal: relocation target runtime.cpuid_ebx7 not defined
golang.org/x/crypto/chacha20poly1305.chacha20Poly1305Open: undefined: "runtime.cpuid_ebx7"
golang.org/x/crypto/chacha20poly1305.chacha20Poly1305Seal: undefined: "runtime.cpuid_ebx7"

@andybons andybons changed the title chacha20Poly1305Open: relocation target runtime.cpuid_ebx7 not defined x/crypto: chacha20Poly1305Open: relocation target runtime.cpuid_ebx7 not defined Mar 13, 2018
@gopherbot gopherbot added this to the Unreleased milestone Mar 13, 2018
@andybons
Copy link
Member

@andybons andybons commented Mar 13, 2018

@netvipe 1.10 is the latest release. Does your issue reproduce on that version as well? can you provide a snippet of code that reproduces your issue?

The following program runs without issue for me on macOS using 1.10 (I see you’re running windows so maybe that’s a factor):

package main

import (
        "log"

        "golang.org/x/crypto/chacha20poly1305"
)

func main() {
        c, err := chacha20poly1305.New(make([]byte, chacha20poly1305.KeySize))
        if err != nil {
                log.Fatal(err)
        }
        log.Printf("cipher: %+v", c)
}
@netvipe
Copy link
Author

@netvipe netvipe commented Mar 13, 2018

@andybons My various test snippets look very similar to yours. The only thing missing is a call for "c.Open(...)". But a simple import and a reference is enough for the error message to appear.

The corresponding lines in chacha20poly1305_amd64.{s,go} are identical, so I don't think the new go version will fix it.

The error message only appears on the stated Windows system. It does not appear on another Linux dev system.

Reason for the issue seems to be the Intel i5-3570K CPU, which does not support AVX2 at all.
The Linux server does.

I'm pretty sure it's the following code section in chacha20poly1305_amd64.go:

@Line 61:
	_, ebx7, _, _ := cpuid(7, 0)
	haveAVX2 := isSet(5, ebx7) && haveAVX
	haveBMI2 := isSet(8, ebx7)

I already though about bypassing it, which is pretty simple, but I don't like to modify public sources for my local build system only. There must be a smarter way ;-)

@andybons
Copy link
Member

@andybons andybons commented Mar 14, 2018

@andybons andybons changed the title x/crypto: chacha20Poly1305Open: relocation target runtime.cpuid_ebx7 not defined x/crypto: chacha20Poly1305Open: relocation target runtime.cpuid_ebx7 not defined on Windows Mar 14, 2018
@TocarIP
Copy link
Contributor

@TocarIP TocarIP commented Mar 14, 2018

Are you using latest version of x/crypto?
https://go-review.googlesource.com/c/crypto/+/41862 removed dependency on runtime.cpuid_*
And go1.9 removed cpuid_* from runtime. So this looks like a problem with stale x/crypto

@netvipe
Copy link
Author

@netvipe netvipe commented Mar 15, 2018

You are right. A complete clear of automatically downloaded sources and cached build files in src and pkg removed the issue. I've already upgraded to go 1.9.4 before creating the ticket. But that did not clear the caches etc. My fault.
Many thanks for the support!

@netvipe netvipe closed this Mar 15, 2018
@golang golang locked and limited conversation to collaborators Mar 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.