-
Notifications
You must be signed in to change notification settings - Fork 87
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
use mold in nix environments #1564
Open
tbro
wants to merge
6
commits into
main
Choose a base branch
from
tb/moldy-nix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
946c73a
use mold in nix environments
tbro c5f8b7a
Install mold from Nix; disable on MacOS
jbearer 7f1d4d3
make rustDeps available globally
tbro a190910
get gcc version
tbro 6d071ed
add env var for linker clang
tbro f9c2611
improve comment
tbro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
stdenv
meant to be passed tomkShell
?I get compilation errors on NixOS currently (and also if i pass
stdenv
tomkShell
).So it looks like the devShell still brings in gcc and that's used for compilation.
I can compile with this change
However linking still seems fairly slow. What kind of speedup do you get?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry my nix skills are very thin, so I'm probably doing something wrong. The
gcc
error is the same that caused me to add the env var. I'm unsure what configuration is causinggcc
to be selected in some cases and not others. Possibly the issue is related to the gcc version.It is noticeably faster for me. It isn't very straightforward to get real figures, because the biggest speedups are on incremental changes and modifying
RUSTFLAGS
will trigger a recompile of many things.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I think works quite well and is somewhat realistic for development is to run a full build, then
touch sequencer/src/lib.rs
and then run the build again and time it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried with this script and for both the new shell and the old shell I get 4-5 seconds
real
time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the linker is actually not invoked when running cargo clippy. If I make this change
things still work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the shell still doesn't seem to be using
mold
for linking in my case 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can confirm like so:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cargo clippy evokes
rustc
w/ linker arguments... I think some linking would have to go on since you are compiling a new binary... but I'm really not clear on the internals.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe if you want to get a better idea if it mold is useful for you, start by removing nix from the equation. Then we can figure out how to fix my terrible nix code :/.