-
Notifications
You must be signed in to change notification settings - Fork 835
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
Fix contracts compilation with CARGO_TARGET_DIR
set
#2927
Fix contracts compilation with CARGO_TARGET_DIR
set
#2927
Conversation
5b83fee
to
9a9eb77
Compare
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.
Can you add the same line for the riscv build, too?
I believe it is not necessary there due to |
You are right. We should probably do the same for the wasm build then. It seems more robust to remove all variables and only forward/set what we need. But let's wait for @pgherveou opinion. |
I thought about that too, but with switch to huge monorepo compiling everything is extremely painful locally so I decided to not touch what seems to work fine as is. Feel free to experiment with it though. |
I think I tried that and it was failing for some reason. I did not investigated much more since it was working without clearing. |
seems to work ¯_(ツ)_/¯, let me test in docker, push an update and see if that pass CI nvm, does not work in CI, it seems to pick up the wrong clang binary |
@@ -203,6 +203,7 @@ fn invoke_wasm_build(current_dir: &Path) -> Result<()> { | |||
|
|||
let build_res = Command::new(env::var("CARGO")?) | |||
.current_dir(current_dir) | |||
.env("CARGO_TARGET_DIR", current_dir.join("target").display().to_string()) |
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.
shouldln't we just clear it if it set, instead of setting it ?
or the fixtures will end up here instead of OUT_DIR?
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 haven't thought of it right away, but clearing should work as well
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.
It has to end up wherever you expect to find them in the rest of your script. In this case current_dir/target
is the same as the default. Otherwise the CI would fail. So deleting should have the same effect. But let's find out why clearing the environment doesn't 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.
let's stick with the current fix
if we wish to clear env, This works as well
.env_clear()
.envs([
("PATH", env::var("PATH").unwrap_or_default()),
("CARGO_HOME", env::var("CARGO_HOME").unwrap_or_default()),
("RUSTC", env::var("RUSTC").unwrap_or_default()),
])
This is weird. We don't depend on C code in our test fixtures? |
that's when compiling dependencies-
|
Okay yes we pull in a lot of stuff for macro support. Try to forward the |
BTW, this is all already solved here. Not sure what is that complicated to just copy this.. |
In case `CARGO_TARGET_DIR` is set, build artifacts were in the wrong place and `build.rs` was failing. With `CARGO_TARGET_DIR=/home/nazar-pc/.cache/cargo/target`: ``` error: failed to run custom build command for `pallet-contracts-fixtures v1.0.0 (/web/subspace/polkadot-sdk/substrate/frame/contracts/fixtures)` Caused by: process didn't exit successfully: `/home/nazar-pc/.cache/cargo/target/debug/build/pallet-contracts-fixtures-35d534f7ac3009e0/build-script-build` (exit status: 1) --- stderr Error: Failed to read "/tmp/.tmpiYwXfv/target/wasm32-unknown-unknown/release/dummy.wasm" Caused by: Can't read from the file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ``` The file was actually in `/home/nazar-pc/.cache/cargo/target/wasm32-unknown-unknown/release/dummy.wasm`.
In case
CARGO_TARGET_DIR
is set, build artifacts were in the wrong place andbuild.rs
was failing. WithCARGO_TARGET_DIR=/home/nazar-pc/.cache/cargo/target
:The file was actually in
/home/nazar-pc/.cache/cargo/target/wasm32-unknown-unknown/release/dummy.wasm
.