-
Notifications
You must be signed in to change notification settings - Fork 92
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
Bindep handling during source dummification breaks embedded builds #444
Comments
Hi @oddlama thanks for the report! Haven't worked with embedded rust projects before so I'm not exactly sure what is missing off the top of my head, but I wonder if we're filtering out something which needs to be present given that overriding the source dummification appears to fix things 🤔 Do you have a(n ideally minimal) flake I can check out and reproduce directly? I tried to look at the example you linked and paste (a fixed up) version of your flake excerpt, but there was just too many other stuff to try to iron out so I couldn't reproduce it in a time-boxed manner 😅 |
Sure, I've made a small template project where the issue is reproduced here: https://github.com/oddlama/nrf-template I've included my current workaround below the If you enter the devshell, you should be able to |
@oddlama thank you for the reproduction! I see the issue, it has to do with our handling of dummy binary targets which has caused problems in the past... I need to take a closer look at making this dummification smarter (e.g. only stub targets that actually exist as some builds don't expect extra binaries to show up). In the meantime, you can get unblocked by using extraDummyScript = ''
cp -a ${./memory.x} $out/memory.x
rm -rf $out/src/bin/crane-dummy-*
''; |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Alright, sorry for the spam, the problem was nothing with crane, I just forgot that Nix builds in a basic bash shell, so you have to enable the extraDummyScript = ''
cp -a ${./memory.x} $out/memory.x
(shopt -s globstar; rm -rf $out/**/src/bin/crane-dummy-*)
''; |
I've been trying to get crane to compile an embedded rust project, but unfortunately encountered some issues that I was unable to solve. Embedded projects often use an alternative linker called
flip-link
which adds stack overflow safety to embedded devices. The issue is that crane doesn't expect this to happen at some places:flip-link
usually searches for amemory.x
linker script in the current directory, but even though I added the file to my filters, it is missing in thebuildDepsOnly
becausemkDummySrc
filter the source again and discards thememory.x
file. My workaround was to add anextraDummyScript
to eachbuild*
function:flip-link
still fails with the following message (and here I wasn't able to find out what it was missing exactly). It looks like it was linking to the standard library even though we are usingthumbv7a-none-eabihf
which should cause no_std and no_main to be added to the dummy if I'm reading it correctly:cargo build
does work fine in a devshell, and I can also get crane to compile the project correctly by disabling the dummy dependency building by addingcargoArtifacts = pkgs.runCommand "disable-deps" {} "mkdir -p $out/target";
.Have a look at this example project if you want to reproduce this. This is the relevant part of my flake.nix:
The text was updated successfully, but these errors were encountered: