Pass config from cargo-kani to kani-compiler#999
Pass config from cargo-kani to kani-compiler#999tedinski merged 3 commits intomodel-checking:mainfrom
Conversation
celinval
left a comment
There was a problem hiding this comment.
It looks good, but I think we should be able to just use relative paths everywhere. When we run cargo build, cargo will put all workspace artifacts in the same directory, doesn't it? So for dev builds you should be able to use executable directory.
I think we are building the libraries twice right now, which isn't ideal.
src/cargo-kani/build.rs
Outdated
|
|
||
| // rustup also seems to set some environment variables, but this is not clearly documented. | ||
| // https://github.com/rust-lang/rustup/blob/master/src/toolchain.rs (search for RUSTUP_HOME) | ||
| // We make use of RUSTUP_TOOLCHAIN in this crate, to avoid needing to otherwise repeat this information |
There was a problem hiding this comment.
This comment seems a bit out of place. Can you please move that to where you implement this logic?
| pub fn rust_toolchain(&self) -> Result<PathBuf> { | ||
| // This is a compile-time constant, not a dynamic lookup at runtime, | ||
| // so we get the toolchain we're built with (i.e. that from rust_toolchain.toml) | ||
| let toolchain = env!("RUSTUP_TOOLCHAIN"); |
There was a problem hiding this comment.
This is a tricky one, eh? We should be careful with custom toolchain override and users setting up this variable in the first place. That said, as long as we automate our releases to not do that, we should be OK.
| .arg( | ||
| Arg::with_name(SYSROOT) | ||
| .long("--sysroot") | ||
| .takes_value(true) |
Are you just talking about I agree it's not ideal. I avoided changing anything in this PR because I wasn't sure what to do. The issue with using the regular build directory is that it has a lot of other stuff in the directory (other dependencies, etc), whereas using the If we use the regular output directory I was slightly worried we might end up with those other dependencies mattering, somehow. On the other hand, this only matters for development builds, since release will distribute only the relevant 3 files. If you think it's probably fine, I'll switch over to doing that. |
|
Ah, actually the bigger problem is that they aren't built with |
What about adding a cargo config file that passes --cfg=kani to the build? That said, I'm OK doing that in a separate PR. |
celinval
left a comment
There was a problem hiding this comment.
I am OK to push further improvements to a separate PR. Can you please move the comment out of src/cargo-kani/build.rs before pushing the change though?
Description of changes:
This change is a bit of a mash-up of things I need to start making things releasable, mostly centering around how we find certain environment/config info in kani-compiler.
In roughly github diff display order you will see:
homecrate to computeRUSTUP_HOMEthe same way rustup does.--sysrootand--kani-libarguments tokani-compilerfromcargo-kaniOsStringnow, instead ofString, now that' we're including Paths.)PathBufs to get cleaner code.kani-compiler, corresponding to where it should search for the rustc libraries in a release bundle. (Basically: next tobin/kani-compilerwill be a symlinktoolchainto the rustup-installed toolchain we require. Hence,../toolchain/lib)/depspath being provided to the linker with-L. This was how it used to work, but this directory didn't exist anymore.Call-outs:
/home/ubuntu/rmc/target/debug/build/kani-compiler-b8c35844f7600bbf/out/liband I wish we could change that outdir to something more predicable, so we could make this unconditional, but I couldn't figure out how.Testing:
How is this change tested? existing suite
Is this a refactor change? not quite
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.