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

rustc: enable bpfe library targets #382166

Open
wants to merge 4 commits into
base: staging
Choose a base branch
from

Conversation

niklaskorz
Copy link
Contributor

@niklaskorz niklaskorz commented Feb 14, 2025

Includes the bpfe targets in libraries to be built by default, see #373425 (comment) and #381669.

The docs stage of Rust's bootstrapping is broken for no_std targets, as for these, it determines an empty set of libraries to build the docs for, which in turn results in an attempt to build docs for all libraries. For rustc only targetting no_std, this was circumvented by passing the --disable-docs flag, but when we mix no_std and std targets, we still want docs to be built for just the std targets.
This is fixed by skipping any targets for which an empty set of crates to built docs for is returned.

I also included two minor refactoring commits (indented string literal, obsolete darwin frameworks) which can be excluded from this PR if preferred.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@niklaskorz
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 382166 --package rustc --package fd


aarch64-darwin

✅ 4 packages built:
  • fd
  • rustc
  • rustc.doc (rustc.doc.doc, rustc.doc.man)
  • rustc.man (rustc.man.doc, rustc.man.man)

# For rustc only targetting no_std, this was circumvented by passing the
# `--disable-docs` flag, but when we mix no_std and std targets, we still
# want docs to be built for just the std targets.
rustcPatches = [ ./skip-no-std-docs.patch ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this patch been proposed upstream? This is the kind of patch we could easily end up having to keep around forever, and that might break again in more complicated ways due to upstream not being responsible for it, making it difficult to maintain rustc in Nixpkgs (which is already hard enough).

This is an upstream bug, and the fix should be upstream too. Working around it in Nixpkgs should be an absolute last resort.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can pull request to upstream instead of patching to source.

Copy link
Contributor Author

@niklaskorz niklaskorz Feb 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'm definitely planning to upstream this, but that will likely take a long while until it reaches nixpkgs, so to unblock eBPF crates I didn't want one PR to depend on the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'm definitely planning to upstream this, but that will likely take a long while until it reaches nixpkgs, so to unblock eBPF crates I didn't want one PR to depend on the other.

I do. I don't want to be committed to keeping a custom behaviour around we don't know that upstream will be okay with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's wait for the response to rust-lang/rust#137073 :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it merged; we can backport now. @niklaskorz @alyssais

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Change this to a fetchpatch of the upstream commit and this is good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in a sec :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 17, 2025
…-no-std, r=clubby789

boostrap: skip no_std targets in Std doc step

This fixes a bug that currently prevents us from adding no_std library targets to rustc in nixpkgs (NixOS/nixpkgs#382166).

When running `./x.py doc`, the `Std` doc step generally fails for no_std targets, logs: https://gist.github.com/niklaskorz/fb83f9503ce19b75e8b1af02cdebd592

Skipping no_std targets in this step will allow using no_std targets such as `bpfel-unknown-none` together with other targets in the same config without blocking the doc generator for them, e.g.

```
./configure --release-channel=stable --tools=rustc,rustdoc,rust-analyzer-proc-macro-srv --build=aarch64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin,bpfel-unknown-none

./x.py doc
```

Logs with this fix applied: https://gist.github.com/niklaskorz/cdd50aaea33ede579f737434286d800b
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 18, 2025
Rollup merge of rust-lang#137073 - niklaskorz:bootstrap-doc-fix-empty-no-std, r=clubby789

boostrap: skip no_std targets in Std doc step

This fixes a bug that currently prevents us from adding no_std library targets to rustc in nixpkgs (NixOS/nixpkgs#382166).

When running `./x.py doc`, the `Std` doc step generally fails for no_std targets, logs: https://gist.github.com/niklaskorz/fb83f9503ce19b75e8b1af02cdebd592

Skipping no_std targets in this step will allow using no_std targets such as `bpfel-unknown-none` together with other targets in the same config without blocking the doc generator for them, e.g.

```
./configure --release-channel=stable --tools=rustc,rustdoc,rust-analyzer-proc-macro-srv --build=aarch64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin,bpfel-unknown-none

./x.py doc
```

Logs with this fix applied: https://gist.github.com/niklaskorz/cdd50aaea33ede579f737434286d800b
@niklaskorz
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 382166 --package fd --package rustc


aarch64-darwin

✅ 4 packages built:
  • fd
  • rustc
  • rustc.doc (rustc.doc.doc, rustc.doc.man)
  • rustc.man (rustc.man.doc, rustc.man.man)

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for mitmproxy-linux 🎉

and I could finally build the mitmproxy update!!!! Thanks people!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants