Default link mode to PIE on supported platforms#4481
Default link mode to PIE on supported platforms#4481fmeum merged 3 commits intobazel-contrib:masterfrom
Conversation
fmeum
left a comment
There was a problem hiding this comment.
You can disable the failing test in the Bazel 6 config in the .bazelci config directory.
8156045 to
96f76de
Compare
|
@fmeum I've managed to fix the tests by adding |
|
Doesn't have to be in this PR, but should we try to flip the default to PIE globally? I think that would match the vanilla go toolchain? |
If that's actually the case then let's do it here so that we don't have to introduce the Android special case at all. |
Looks like it's on by default in androis/ios/macos and windows without race, but not linux/bsds. |
|
@alextercete Could you update the condition to match what native Go does? |
96f76de to
7668b29
Compare
|
@dzbarsky The failures look like |
So there's a few things going on here:
This patch can do it: (Pulled this out into #4489)
Hope that helps! |
3fe0c0a to
c5c2e60
Compare
|
@dzbarsky I tried your suggestion to fix the CI failures on Windows, but they didn't work. Any other ideas? |
|
cc @linzhp for mocks |
|
We can disable that target on Windows if it's failing. We are moving the mock support to https://github.com/uber-go/mock |
18183c8 to
e0f1670
Compare
|
I'm not sure if there are any targets I can disable. The new ones I've added are all tagged as I've rebased onto the latest |
|
@alextercete can you try marking these targets as |
b823df2 to
ac416dd
Compare
65741c8 to
3dd6c63
Compare
|
It turns out there was a legitimate failure on Windows related to testing for stripped portable executables. I've adjusted the test and now CI is green. |
3dd6c63 to
229c608
Compare
We now choose `pie` over `normal` when `linkmode` is omitted (or explicitly set to `auto`) and target supports it. This mirrors the behaviour of `go build`.
Go's PIE builds for Windows clear the COFF symbol table by zeroing the header fields, so the old .symtab lookup hit a panic on every run. Instead, the test now checks those header indicators (and falls back to the parsed symbol list) to decide whether the binary was stripped.
229c608 to
80e1901
Compare
|
@alextercete thanks for powering through this one! |
What type of PR is this?
Feature
What does this PR do? Why is it needed?
We now choose
pieovernormalwhenlinkmodeis omitted (or explicitly set toauto) and target supports it. This mirrors the behaviour ofgo build.Which issues(s) does this PR fix?
Fixes #4478