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

[WIP] Use weak linkage instead of compiler generated shims #134522

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Dec 19, 2024

#86844 (unstably) made it possible to avoid the allocator shim when using #[global_allocator]. This PR makes it possible to also avoid the allocator shim when using the default allocator in libstd by making use of weak linkage. Eventual stabilization of avoiding the allocator shim may be blocked on it working with the default allocator too.

This is still keeping the __rust_no_alloc_shim_is_unstable symbol for now until #123015 gets stabilized.

TODO: Update comments everywhere, test on macOS and Windows and write a better PR description why we want this. Also prevent codegen of weak symbols when there is a non-weak definition of the same symbol in the same codegen unit.

try-job: x86_64-msvc
try-zzz-job: x86_64-apple-1
try-zzz-job: x86_64-apple-2

@rustbot
Copy link
Collaborator

rustbot commented Dec 19, 2024

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 19, 2024
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the weak_linkage_allocator branch from f4f6936 to 93bd5d3 Compare December 19, 2024 16:38
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the weak_linkage_allocator branch 5 times, most recently from d179738 to 1b00966 Compare December 20, 2024 09:28
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the weak_linkage_allocator branch from 8f98f5e to 08bddfb Compare December 20, 2024 10:53
@bjorn3
Copy link
Member Author

bjorn3 commented Dec 20, 2024

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 20, 2024
[WIP] Use weak linkage instead of compiler generated shims

rust-lang#86844 (unstably) made it possible to avoid the allocator shim when using `#[global_allocator]`. This PR makes it possible to also avoid the allocator shim when using the default allocator in libstd by making use of weak linkage. Eventual stabilization of avoiding the allocator shim may be blocked on it working with the default allocator too.

This is still keeping the `__rust_no_alloc_shim_is_unstable` symbol for now until rust-lang#123015 gets stabilized.

TODO: Update comments everywhere, test on macOS and Windows and write a better PR description why we want this. Also prevent codegen of weak symbols when there is a non-weak definition of the same symbol in the same codegen unit.

try-job: x86_64-msvc
try-job: x86_64-apple-1
try-job: x86_64-apple-2
@bors
Copy link
Contributor

bors commented Dec 20, 2024

⌛ Trying commit abd406c with merge 25f4036...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 20, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 20, 2024
@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member Author

bjorn3 commented Dec 20, 2024

@bors try

@bors
Copy link
Contributor

bors commented Dec 20, 2024

⌛ Trying commit 3e25d5a with merge 3659c42...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 20, 2024
[WIP] Use weak linkage instead of compiler generated shims

rust-lang#86844 (unstably) made it possible to avoid the allocator shim when using `#[global_allocator]`. This PR makes it possible to also avoid the allocator shim when using the default allocator in libstd by making use of weak linkage. Eventual stabilization of avoiding the allocator shim may be blocked on it working with the default allocator too.

This is still keeping the `__rust_no_alloc_shim_is_unstable` symbol for now until rust-lang#123015 gets stabilized.

TODO: Update comments everywhere, test on macOS and Windows and write a better PR description why we want this. Also prevent codegen of weak symbols when there is a non-weak definition of the same symbol in the same codegen unit.

try-job: x86_64-msvc
try-job: x86_64-apple-1
try-job: x86_64-apple-2
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 20, 2024

💔 Test failed - checks-actions

@bjorn3
Copy link
Member Author

bjorn3 commented Dec 20, 2024

@bors try

@bors
Copy link
Contributor

bors commented Dec 20, 2024

⌛ Trying commit 3e25d5a with merge f0b0345...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 20, 2024
[WIP] Use weak linkage instead of compiler generated shims

rust-lang#86844 (unstably) made it possible to avoid the allocator shim when using `#[global_allocator]`. This PR makes it possible to also avoid the allocator shim when using the default allocator in libstd by making use of weak linkage. Eventual stabilization of avoiding the allocator shim may be blocked on it working with the default allocator too.

This is still keeping the `__rust_no_alloc_shim_is_unstable` symbol for now until rust-lang#123015 gets stabilized.

TODO: Update comments everywhere, test on macOS and Windows and write a better PR description why we want this. Also prevent codegen of weak symbols when there is a non-weak definition of the same symbol in the same codegen unit.

try-zzz-job: x86_64-msvc
try-job: x86_64-apple-1
try-job: x86_64-apple-2
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs PG-exploit-mitigations Project group: Exploit mitigations labels Dec 20, 2024
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 21, 2024

☔ The latest upstream changes (presumably #134604) made this pull request unmergeable. Please resolve the merge conflicts.

@bjorn3 bjorn3 force-pushed the weak_linkage_allocator branch from a351266 to 7952352 Compare January 17, 2025 13:36
@bjorn3
Copy link
Member Author

bjorn3 commented Jan 17, 2025

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 17, 2025
[WIP] Use weak linkage instead of compiler generated shims

rust-lang#86844 (unstably) made it possible to avoid the allocator shim when using `#[global_allocator]`. This PR makes it possible to also avoid the allocator shim when using the default allocator in libstd by making use of weak linkage. Eventual stabilization of avoiding the allocator shim may be blocked on it working with the default allocator too.

This is still keeping the `__rust_no_alloc_shim_is_unstable` symbol for now until rust-lang#123015 gets stabilized.

TODO: Update comments everywhere, test on <strike>macOS and</strike> Windows and write a better PR description why we want this. Also prevent codegen of weak symbols when there is a non-weak definition of the same symbol in the same codegen unit.

try-zzz-job: x86_64-msvc
try-job: x86_64-apple-1
try-job: x86_64-apple-2
@bors
Copy link
Contributor

bors commented Jan 17, 2025

⌛ Trying commit 7952352 with merge d5915d9...

@bors
Copy link
Contributor

bors commented Jan 17, 2025

☀️ Try build successful - checks-actions
Build commit: d5915d9 (d5915d9567206920e25d38421ce09513599a9d53)

@bjorn3
Copy link
Member Author

bjorn3 commented Jan 17, 2025

And for windows.

@bors try

@bors
Copy link
Contributor

bors commented Jan 17, 2025

⌛ Trying commit 7952352 with merge 0b44463...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 17, 2025
[WIP] Use weak linkage instead of compiler generated shims

rust-lang#86844 (unstably) made it possible to avoid the allocator shim when using `#[global_allocator]`. This PR makes it possible to also avoid the allocator shim when using the default allocator in libstd by making use of weak linkage. Eventual stabilization of avoiding the allocator shim may be blocked on it working with the default allocator too.

This is still keeping the `__rust_no_alloc_shim_is_unstable` symbol for now until rust-lang#123015 gets stabilized.

TODO: Update comments everywhere, test on <strike>macOS and</strike> Windows and write a better PR description why we want this. Also prevent codegen of weak symbols when there is a non-weak definition of the same symbol in the same codegen unit.

try-job: x86_64-msvc
try-zzz-job: x86_64-apple-1
try-zzz-job: x86_64-apple-2
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 17, 2025

💔 Test failed - checks-actions

@bors
Copy link
Contributor

bors commented Jan 30, 2025

☔ The latest upstream changes (presumably #136035) made this pull request unmergeable. Please resolve the merge conflicts.

@ChrisDenton
Copy link
Member

I don't think anyone has worked on Rust's support for Windows weak linkage yet? Maybe extern_weak would work on Windows but I'm not even sure that's hooked up properly yet.

IIRC #[linkage] is just forwarding straight to LLVM and not always correctly.

This is still keeping the allocator shim for the oom handler and the
__rust_no_alloc_shim_is_unstable symbol for now.

TODO: Update comments everywhere and test on macOS and Windows
@bjorn3 bjorn3 force-pushed the weak_linkage_allocator branch from 7952352 to afbc5b3 Compare February 7, 2025 15:10
@bjorn3 bjorn3 force-pushed the weak_linkage_allocator branch from afbc5b3 to 8f53ab0 Compare February 7, 2025 15:33
@bors
Copy link
Contributor

bors commented Feb 9, 2025

☔ The latest upstream changes (presumably #136751) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants