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
Remove -pie from LDFLAGS if buildmode is not pie #3691
Comments
The analysis looks just right, thanks! Would you be interested in sending a fix? rules_go/go/private/rules/cgo.bzl Lines 71 to 74 in ba46686
|
Thanks. I sent a PR that works for this specific example. But I am not sure if I am matching all the conditions right. Will you be able to take a look at the TODO I have in my change? |
I see the same error when trying to build a
Rule:
Bazel 6.3.2 I seemed to solve it by upgrading the grpc-gateway compiler lib |
What version of rules_go are you using?
0.41.0
What version of gazelle are you using?
N/A
What version of Bazel are you using?
6.3.2
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
Debian 12
Any other potentially useful information about your toolchain?
LLVM 15 with LLD. On Debian like systems, can be set up with:
What did you do?
CASE 1: Tried to build and run a cgo test target within this project with the
--force_pic
flag.CASE 2: Instead of one of the tests from this repo, a simpler Go program can also be:
with a build target that is simply:
What did you expect to see?
The test target run completing successfully, and/or the simpler Go program run completing successfully.
What did you see instead?
Notes
This crash is happening because
force_pic
is sending the-pie
flag to the linker, which gets passed along as part of CGO_LDFLAGS. But because the buildmode is not set to "pie" in the go_binary target, I think the stdlib is mismatched.This is not a problem with the standard Go toolchain because it filters out the "-pie" flag from CGO_LDFLAGS.
Building under normal buildmode, will filter out "-pie" from the linker command. Notice that there were no -extldflags set for the link step.
CC=clang-15 CGO_LDFLAGS='-v -fuse-ld=lld -pie' go build -x main.go
To force sending "-pie" to the linker, you will have to explicitly set -extldflags.
The text was updated successfully, but these errors were encountered: