-
Notifications
You must be signed in to change notification settings - Fork 239
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
chore(cargo-build-sbf): allow building from nix store #4061
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for your contribution again! I'm a fan of the change, but I want to be sure that I understand how to use it.
If you pass --no-rustup
, then for it to work, you must either set RUSTC, ie. RUSTC=/path/to/solana/rustc cargo build-sbf...
, or ensure that the default rustc
in your PATH is the Solana version of rustc. Is that correct?
Otherwise, just a few nits, it looks good to me
@@ -1048,6 +1066,13 @@ fn main() { | |||
.takes_value(false) |
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 can't comment higher up, but let rust_base_version = get_base_rust_version(...)
on line 995 will use homedir to find the tools version. Since this is just for logging with CI caches, I assume it's OK for it to fail and return an empty string, but I wanted to flag it either way.
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.
in nix wrapper and override I set exact version of tools and path it to cargo-build-sbf.
if that is okey return empty string will do it, 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.
let rust_base_version = get_base_rust_version(DEFAULT_PLATFORM_TOOLS_VERSION);
let version = format!(
"{}\nplatform-tools {}\n{}",
crate_version!(),
DEFAULT_PLATFORM_TOOLS_VERSION,
rust_base_version,
);
let matches = clap::Command::new(crate_name!())
.about(crate_description!())
.version(version.as_str())
oh, recalled what problem was.
- I can invoke cargo build sbf in nix even if this lines runs. no worries.
- I cannot not invoke it in case of nix, because cli parameters not yet parsed. until i change usage of clap and provide own version command. i want to avoid doing anything with next in this PR
.version(version.as_str())
but seems solution which will be backward compatible and provide correct tools and rust version is to do custom command and resolve
bash-5.1$ cargo run -- --version
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
Running `/home/dz/github.com/anza-xyz/agave/target/debug/cargo-build-sbf --version`
solana-cargo-build-sbf 2.2.0
platform-tools v1.43
bash-5.1$
and doing --version --WHATEVER_PARAMETERS_OVERRIDE_RUST
as option.
yes. and that is what exactly nix does well.
specifically i just upstreaming this patch https://github.com/arijoon/solana-nix/blob/52dbde3e8bb09fbee644c371de930d5374c3cb8c/cargo-build-sbf.patch so that nix and non nix (default) solution work from same release |
Problem
Previously I enabled using sbf compiler from nix and downloaded via nix #3762,
but still had to side effect into HOME to allow sbf builds.
Summary of Changes
In this PR I fully eliminate any side effects to HOME,
following nix guidance not to side effect to HOME and also allowed build programs with nix cache.
If no
--no-rustup
option provided, all works a before.