-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
buildRustCrate: don't sort link flags #83379
Conversation
Linkage order is significant and sorting can result in link errors.
@symphorien thanks! That looks very good. Can you craft a case where we can simulate the error so we can add it to the |
maybe I can switch nix-du to crate2nix in nixpkgs instead of crafting an artificial example. What do you think ? |
On 14:57 25.03.20, symphorien wrote:
maybe I can switch nix-du to crate2nix in nixpkgs instead of crafting an artificial example. What do you think ?
That might work now but might get lost over time. At some point we might
not have the actual test case anymore - if nix-du changes significantly.
The idea of `buildRustCrate` is to have a very quick feedback loop on
the core pieces and those that have biten us in the past. I like to add
regression tests.
I am happy to have a look at how we can add those tests. Can you post
the branch/changes you did do nix-du to trigger the error and the exact
error messages you received?
|
Here is a self contained repo which reproduces the bug. https://github.com/symphorien/link_order I don't really know where to put it in nixpkgs. |
On 08:58 26.03.20, symphorien wrote:
Here is a self contained repo which reproduces the bug. https://github.com/symphorien/link_order
I don't really know where to put it in nixpkgs.
Thanks!. I saw the example and it make somewhat sense. I am yet not
entirely sure I understand the issue that is being constructed there. I
guess it is the order in which they are registered during the build.rs
execution? That order must match the order symbols are being looked up
during runtime/linktime?
We have a bunch of buildRustCrate tests in
`pkgs/build-support/rust/build-rust-crate/tests`. I tried to make it
easy to construct these kinds of tests in there. I am happy to assist or
take the first blow on it. I just don't want to postpone testing this as
otherwise it will never happen :) (Speaking of experience).
I'll be available for most of the weekend via IRC/Twitter/… if you want
to chat about a potential implemention of the test.
|
It a crate which must be linked with
Should I copy my full example crate in nixpkgs or fetch it ? |
Added a regression test. |
On 06:28 28.03.20, symphorien wrote:
Added a regression test.
Nice! That looks good. I picked that test to master (locally) and
verified that it does indeed fail there. When applied on this branch it
works as advertised.
Thank you for puttin in the effort! I know it isn't straight forward. We
lack documentation and comments on the test "framework".
One last thing: can you retitle the last commit as below?
buildRustCrateTests: add regression test for link order
(or similar)
Otherwise it looks good and I am ready to merge that in :)
|
done |
Also, please backport to 20.03, if you don't mind. |
I will open a backport PR for the changes to buildRustCrate that we merged in the last few days/weeks. Those have all been non-destructive improvements/bug fixes that should be fine for inclusion. I'll wait for #83488 to land as that seems like a good additional candidate. That should hopefully be some time this weekend. Feel free to poke me if it didn't happen. |
Linkage order is significant and sorting can result in link errors.
This was tested (and the corresponding issue was discovered) by building nix-du with crate2nix.
nix-review reports only one compilation failure which seems unrelated (it's not a linker error)
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)