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

Disable some rustc/LLVM optimizations for build efficiency #511

Open
shaneutt opened this issue Jan 30, 2023 · 2 comments
Open

Disable some rustc/LLVM optimizations for build efficiency #511

shaneutt opened this issue Jan 30, 2023 · 2 comments
Labels
upstream/llvm Issue which needs upstream work in LLVM upstream/rustc Issue which needs upstream work in rustc

Comments

@shaneutt
Copy link

Developers can run into problems with the BPF verifier like invalid size of register spill despite having what might not seem (to them) like a very large or complex eBPF program.

One way Aya itself can help with these situations (as per @alessandrod's recommendation) is to disable some of the non-necessary optimizations we currently have enabled in rustc and LLVM which generate extra, complex code.

The purpose of this task is to strategize and implement such optimizations to help improve the development experience.

(originally discussed in #505, and recommended by @alessandrod)

@vadorovsky vadorovsky added upstream/rustc Issue which needs upstream work in rustc upstream/llvm Issue which needs upstream work in LLVM labels Jan 30, 2023
@vadorovsky
Copy link
Member

vadorovsky commented Jan 30, 2023

One way Aya itself can help with these situations

I don't think it can be done in Aya, it's a task to do in rustc (and LLVM if we want to go hardcore). Rust enables these LLVM passes and currently there is no way to disable/enable them from command line:

https://github.com/rust-lang/rust/blob/6a28fb42a8b8f1f67fe854c2206148171e434d73/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp#L62-L76

The first thing which I would do is:

  1. Prepare small eBPF programs which reproduce verifier errors.
  2. Comment all the passes (or all the suspected passes, at least) in PassWrapper.cpp, build custom rustc.
  3. Try to load the same programs, but built with cargo +stage1 build.
  4. If it works, uncomment a pass, repeat 2-4. If it doesn't, we probably know the breaking pass.

After nailing down which pass triggers the issue, the next things to do would be:

  1. Proposing some mechanism of disabling that pass in Rust for BPF target. I think that some kind of per-target blocklist of passes would work.
  2. Bonus points for actually fixing that pass in LLVM.

@alessandrod
Copy link
Collaborator

I don't think it can be done in Aya, it's a task to do in rustc (and LLVM if we want to go hardcore)

We should be fixing LLVM issues as part of what we do on the regular. Nobody is going to fix issues for us, this should become part of our normal workflow.

Rust enables these LLVM passes and currently there is no way to disable/enable them from command line:

Rust does have a way to do that:

https://doc.rust-lang.org/rustc/codegen-options/index.html#no-prepopulate-passes
https://doc.rust-lang.org/rustc/codegen-options/index.html#passes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream/llvm Issue which needs upstream work in LLVM upstream/rustc Issue which needs upstream work in rustc
Projects
None yet
Development

No branches or pull requests

3 participants