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

wrapRustcWith: fix linking with libgcc_s with llvm #330037

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

Conversation

RossComputerGuy
Copy link
Member

Description of changes

Follow up to #320432

This is necessary to get some rust packages building with LLVM, notably mesa.

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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

@RossComputerGuy RossComputerGuy force-pushed the fix/pkgsllvm/rustc-wrapper branch 5 times, most recently from b1d7c36 to 751864f Compare July 26, 2024 01:54
@ofborg ofborg bot requested review from tjni and Mic92 July 26, 2024 04:43
@RossComputerGuy RossComputerGuy marked this pull request as draft August 3, 2024 02:24
@RossComputerGuy RossComputerGuy force-pushed the fix/pkgsllvm/rustc-wrapper branch from 751864f to e99b72c Compare August 3, 2024 02:28
@RossComputerGuy RossComputerGuy changed the base branch from master to staging August 3, 2024 02:28
@RossComputerGuy RossComputerGuy marked this pull request as ready for review August 3, 2024 02:29
@RossComputerGuy RossComputerGuy force-pushed the fix/pkgsllvm/rustc-wrapper branch from e99b72c to 02551bf Compare August 3, 2024 02:43
@RossComputerGuy
Copy link
Member Author

rusti-cal builds, mesa which this is mainly needed for doesn't build until the deps are fixed.

@@ -26,4 +26,5 @@ if (( "${NIX_DEBUG:-0}" >= 1 )); then
printf " %q\n" "${extraAfter[@]}" >&2
fi

export NIX_LDFLAGS="@ldflags@ $NIX_LDFLAGS"
Copy link
Member

Choose a reason for hiding this comment

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

NIX_LDFLAGS_@suffixSalt@ is sometimes used for cross compiling, but it's not clear to me if we need it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I can't tell either. Maybe it'll be good to check how CC wrapper works and see if this could affect cross compiled LLVM Rust packages and if it does then add the suffix?

Copy link
Member

Choose a reason for hiding this comment

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

@Ericson2314 probably knows. But not sure if his GitHub feed is too swamped as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a blocker or can it be resolved later?

Copy link
Member

Choose a reason for hiding this comment

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

Not if nix-build -A tests.rust-hooks still succeeds.

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 10, 2024
@RossComputerGuy RossComputerGuy force-pushed the fix/pkgsllvm/rustc-wrapper branch 2 times, most recently from 4ad8701 to 38a1443 Compare January 2, 2025 22:08
@RossComputerGuy RossComputerGuy removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 2, 2025
@RossComputerGuy RossComputerGuy force-pushed the fix/pkgsllvm/rustc-wrapper branch 2 times, most recently from 6cd78d3 to 195ebac Compare January 2, 2025 22:58
runCommand "libunwind-libgcc" { } ''
mkdir -p $out/lib
ln -s ${rustc-unwrapped.llvmPackages.libunwind}/lib/libunwind.so $out/lib/libgcc_s.so
ln -s ${rustc-unwrapped.llvmPackages.libunwind}/lib/libunwind.so $out/lib/libgcc_s.so.1
Copy link
Member

Choose a reason for hiding this comment

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

This looks extremely weird. I think we need a much better explanation of why this is the right fix, if indeed it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't fully remember why but I know it's the same reason as why we need https://github.com/NixOS/nixpkgs/blob/nixos-24.11/pkgs/development/compilers/rust/rustc.nix#L350-L358

Copy link
Member

Choose a reason for hiding this comment

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

The URL in that comment is broken.

Copy link
Member Author

Choose a reason for hiding this comment

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

It opens up correctly for me, not sure how it's broken.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/gentoo/gentoo/blob/master/dev-lang/rust/rust-1.78.0.ebuild#L284 is 404 page not found. Seems like it's critical to understanding what's going on here — would you mind updating it to an exact commit hash rather than "master" so it won't rot?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like it might be setting a specific flag at compile time?

Shouldn't we be using that instead then?

We should, I remember trying it before and it didn't work.

I think using musl is just as much of a hack as symlinking stuff is.

If Musl is the intended target for non-GNU userlands -- as the Rust developer above said -- I'm not sure how that even approaches renaming a library to pretend to be another one. These are not ABI compatible, and if rustc is requesting them, I'd imagine it probably has a reason to and this could easily lead to breakages when the library is actually used and not just linked. If it doesn't have a reason to, this is most definitely an upstream bug or an issue with our configuration...and I'm leaning towards it being latter since AFAICT, literally no other distribution uses this method, including the one we originally sourced this hack from

The other "option" is waiting for LLVM to land the LLVM ABI but that implies the LLVM libc.

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like no matter what flags I set, I cannot get rustc to compile like it does on Gentoo. We might have to live with the stupid symlink hack.

Copy link
Member

Choose a reason for hiding this comment

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

Gentoo dropped it in gentoo/gentoo@349e9c0

Copy link
Member

Choose a reason for hiding this comment

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

it seems a solution may be to actually target the musl abi instead of GNU -- as said rust-lang/rust#119504 (comment)

This sort of "just works" now with pkgsLLVM.pkgsMusl. Opened #379632

Copy link
Member

Choose a reason for hiding this comment

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

I think the best way forward here would be to ask the author of the Gentoo change how come they were able to drop the hack.

@Mic92
Copy link
Member

Mic92 commented Feb 6, 2025

Good to merge if nix-build -A tests.rust-hooks still works.

@RossComputerGuy
Copy link
Member Author

Good to merge if nix-build -A tests.rust-hooks still works.

error: attribute 'rust-hooks' in selection path 'tests.rust-hooks' not found

@Mic92
Copy link
Member

Mic92 commented Feb 6, 2025

Good to merge if nix-build -A tests.rust-hooks still works.

error: attribute 'rust-hooks' in selection path 'tests.rust-hooks' not found

You need to rebase onto #379269

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.

6 participants