Repository navigation
Default Linux builds to PIE - #2676
Merged
Quim Muntal (qmuntal) merged 4 commits intoOct 29, 2026
Merged
Conversation
Align executable defaults with Microsoft's security policies on Linux targets that support internal PIE linking. Preserve non-PIE race builds and the explicit -buildmode=exe opt-out. Add cross-architecture ELF/build-info checks and native crypto/cgo tests, and document the dynamic-loader requirement for programs without crypto dependencies. Fixes #2236 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Missing upstream linker context and the new runtime-loader dependency across six Linux architectures require human review of deployment compatibility and native runtime validation beyond the cross-build checks.
No open issues 🎉
What changed in this PR
This PR makes PIE the default for Linux builds on six architectures starting with Go 1.28, aligning the Microsoft build of Go with Microsoft’s security policies.
Changes:
- Enable PIE by default where internal linking supports it, preserving existing defaults for other Linux architectures and
-racebuilds. - Add cross-architecture ELF/build-info checks and native crypto/cgo execution tests.
- Document the dynamic-loader requirement and
-buildmode=exeopt-out for fully static builds.
Patches are happy!
| File | Description |
|---|---|
toolchaintest/README.md |
Add Linux PIE defaults to the documented test coverage. |
toolchaintest/buildmode_test.go |
Test build modes across Linux architectures and native crypto/cgo configurations. |
patches/index.json |
Register the new PIE patch and its integrity metadata. |
patches/0014-Default-to-PIE-on-Linux.patch |
Enable the Linux PIE default for supported architectures, excluding race builds. |
eng/doc/MigrationGuide.md |
Summarize the default change and migration implications. |
eng/doc/AdditionalFeatures.md |
Explain architecture coverage, loader requirements, and static-build guidance. |
docs/go1.28.md |
Announce the PIE default in the Go 1.28 release notes. |
Review effort: Balanced
Member
Author
|
Submitted the following upstream PRs to add internal PIE mode support for 386, arm, and riscv64: https://go-review.googlesource.com/c/go/+/856001 |
Match dependency archives to direct compiler and linker invocations, update ELF expectations, and deduplicate missing-main diagnostics for PIE. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
George Adams (gdams)
approved these changes
Oct 29, 2026
Preserve sanitizer runtime compatibility without changing PIE defaults for normal crypto/cgo builds. Update default-mode selection, build information, linker requirements, native regression tests, and documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse the existing ASan compiler and runtime prerequisites instead of requiring libasan for general toolchain tests. Preserve ELF type, build metadata, and execution checks for both executables and test binaries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Default Linux builds to PIE on amd64, arm64, loong64, ppc64, ppc64le, and s390x to align with Microsoft's security policies. Windows and Darwin binaries already defaulted to PIE.
The default applies with or without cgo and crypto imports. Other Linux architectures retain their previous defaults. Linux
-raceand-asanbuilds remain non-PIE by default for runtime compatibility; explicit-asan -buildmode=pieremains available.Add cross-architecture ELF/build-info checks and native crypto/cgo and race tests. Check ASan executable and test-binary defaults in the existing sanitizer suite, which verifies compiler/runtime prerequisites. Document the new dynamic-loader dependency for programs without crypto dependencies and the
-buildmode=exeopt-out.Validation:
-race.cmd/goscripts, plus Windows/arm64 caller checks.Fixes #2236.