-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add unstable hotpatch flag to rustc #134004
base: master
Are you sure you want to change the base?
Conversation
These commits modify compiler targets. The run-make-support library was changed cc @jieyouxu This PR modifies cc @jieyouxu |
This is waiting on the MCP rust-lang/compiler-team#745, right? |
The MCP is stuck due to missing linux support, due to missing linker support. Current plan to get the MCP approved would be to:
With this there would be a proof of concept that works on linux and would unstuck the MCP. |
Ah okay, thanks for the clarifications! |
So ... I think we should remove the "S-waiting-on-MCP" tag then and put it back to waiting on review? |
This is waiting on the MCP because the MCP needs a second from a compiler team member. There's no action needed on your side. |
As far as I understood getting a second will only happen when I have a poc that works on linux. Again sorry for the confusion and thank you for your time! |
Let me go ask other compiler people about this and then get back to you. |
I think there's been a misunderstanding here. That was my opinion on the MCP, not on whether it needs an MCP. Unstable flags usually do go through an MCP. |
This PR adds an unstable hotpatch flag, which ensures the first instruction of a function being two bytes long, otherwise inserting a nop. This is needed for code hotpatching (such as Live++ or Recode) tools to work, so they can provide very quick iteration cycles for development.
This uses a LLVM feature that is only implemented on x86/x86_64. On aarch64 this is not needed as there are no 1 byte instructions.
Hotpatching also requires a linker argument (e.g. functionpadmin on link.exe/lld), which ensures a minimum padding between functions. This can not implemented in rustc as this is linker specific. However, we do mark functions to be hotpatchable when using the hotpatch flag, as the link.exe/lld need it for their functionpadmin flag to work.
Typical usage with cargo for hotpatching the would be "RUSTFLAGS=-Z hotpatch -C link-arg=-functionpadmin". This currently only works on Windows due to linker support. But there should be nothing blocking other linkers to implement a flag similar to functionpadmin.
There is a similar flag "patchable-function-entry". The main difference is that hotpatch + functionpadmin, should leave functions that are already hotpatchable, an extremely common case, untouched. This reduces bloat, but requires linker support.
This is a first step to establish a proof of concept for rust-lang/compiler-team#745. The follow up step would be to add support for lld (or another linker) so this also works on linux.