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

invalid LDFLAGS break build with go1.9.4 / go1.10rc2 #63

Closed
dmitris opened this issue Feb 8, 2018 · 8 comments · Fixed by #64
Closed

invalid LDFLAGS break build with go1.9.4 / go1.10rc2 #63

dmitris opened this issue Feb 8, 2018 · 8 comments · Fixed by #64

Comments

@dmitris
Copy link
Contributor

dmitris commented Feb 8, 2018

On Linux, I'm getting the following error when trying to build the master version with go1.9.4:

$ go install ./...
go build github.com/miekg/pkcs11: invalid flag in #cgo LDFLAGS: -Wl,--no-as-needed

On Mac OS, getting the error:

$ go install ./...
go build github.com/miekg/pkcs11: invalid flag in #cgo LDFLAGS: -I/usr/local/share/libtool

Same errors with go1.10rc2. This is likely be due to changes / security fixes in golang/go#23672

@miekg

@miekg
Copy link
Owner

miekg commented Feb 8, 2018

:-(

Can you send a PR?

@dmitris
Copy link
Contributor Author

dmitris commented Feb 8, 2018

#64

I think that -Wl,--no-as-needed is missing in Go from https://github.com/golang/go/blob/master/src/cmd/go/internal/work/security.go#L88-L89

Is --no-as-needed a must-have? You can install the package with CGO_LDFLAGS_ALLOW='-Wl,--no-as-needed' go install but it's somewhat inconvenient for users to be forced to do it...

@miekg
Copy link
Owner

miekg commented Feb 8, 2018 via email

@dmitris
Copy link
Contributor Author

dmitris commented Feb 8, 2018

I suggest to start with merging this as is, for the sake of the Darwinists, and then figure out what to do for Unix (not sure about Windows).

@miekg miekg closed this as completed in #64 Feb 8, 2018
ghost pushed a commit to hyperledger/fabric that referenced this issue Feb 19, 2018
Following issue described at miekg/pkcs11#63
there is a need to update vendor dependency of pkcs11 lib.

Change-Id: Ic823687f5d93490236cf396626c54fd2a9705a19
Signed-off-by: Artem Barger <bartem@il.ibm.com>
@tocosonic
Copy link

Simply migrate to GO version 1.10. This erroneous behaviour has been fixed in the most recent version.

@ilfrich
Copy link

ilfrich commented Mar 13, 2018

Seems to still be an issue with 1.10 if you use an older library.

There's a workaround in the #67 issue linked above using an environment variable to override the error: CGO_LDFLAGS_ALLOW="-I.*" <your-build-command>

@andlabs
Copy link

andlabs commented Apr 11, 2018

Why do you need -I in LDFLAGS? cgo separates the compiler and linker phases, and -I is only relevant in the former. Unless there's something I'm missing?

-Wl,-no-as-needed should be in the whitelists by now. (This is why I did not like instant, reactionary responses to the security whitelist; it leads to more work for devs later on. There should be a reason for every option in a #cgo directive.)

@ilfrich
Copy link

ilfrich commented Apr 12, 2018

@andlabs I'm not an expert on this project nor do I have much knowledge in Golang. I posted this primarily, because it was a quick workaround to a compile problem with certain libraries in an unrelated project. It solved the problem for me, so apparently does the latest Go version (although it may also be related to some other library versions). But if anyone finds the problem, this can be a quick workaround to prevent that specific error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants