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

Can cargo2nix run -Zbuild-std cross-compiling for embedded targets? #330

Open
wrsturgeon opened this issue Jul 11, 2023 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@wrsturgeon
Copy link

Title. This tool blew my mind, by the way—this is just an edge case that I'm wondering if you support. If not, I'll just use a less Nix-y way.

@wrsturgeon
Copy link
Author

Apologies, I should be more specific:

I'm not entirely clear where to introduce this option.

  • I already have .cargo/config and rust-toolchain specifying -Zbuild-std and a bunch of other options (which works without Nix), but cargo2nix doesn't recognize them—I'm assuming this is on purpose? Still, nightly is no problem (thanks to makePackageSet), but I can't find the best way to introduce -Zbuild-std.
  • The Rust target is thumb-v6m-none-eabi (an Arduino MKR WIFI, clearly no OS), so this can't work with the crossSystem argument as in your cross-compilation example (tried, unrecognized).
  • There doesn't seem to be another way in arguments to makePackageSet. I've used nightly already and set the target, but a few crates fail with a missing panic handler, a symptom of not having std available, so it seems that std does not build by default when cross-compiling (sensible), but I can't use the cargo2nix method of cross-compilation, either.
  • I'm not sure it's the best way to override the environment variables, and I'll admit I'm not sure how to do this and haven't found an example. My intuition is that this is not the safest way to do it, but that's why I ask for help.

If this is too hand-wave-y / a waste of your time, let me know, but I'd appreciate any pointers!

@heph2
Copy link

heph2 commented Jul 12, 2023

Hi @wrsturgeon i'm currently trying to use cargo2nix for build an embedded project (raspberry pico) and i'm also having some issues..
Do you mind share your flake.nix?

@psionic-k
Copy link
Member

cargo2nix is an expression-generator style solution. The generator, cargo2nix, doesn't deal with any -Z flags.

Later on, the overlay we provide does consume flags. My plan is to handle this soon by adding the most generic flags options first and then adding the more specific ones to line up the user experience to match other Rust nix tooling.

@psionic-k psionic-k added the enhancement New feature or request label Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants