-
Notifications
You must be signed in to change notification settings - Fork 17
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: remove from env CARGO_ENCODED_RUSTFLAGS for easier nested builds, simplify RUSTFLAGS computation rule #289
fix: remove from env CARGO_ENCODED_RUSTFLAGS for easier nested builds, simplify RUSTFLAGS computation rule #289
Conversation
match key { | ||
"RUSTFLAGS" => { | ||
let rustflags: &mut String = final_env | ||
.entry(key) | ||
.or_insert_with(|| std::env::var(key).unwrap_or_default()); | ||
// helps avoids situation on complete match `RUSTFLAGS="-C link-arg=-s -C link-arg=-s"` | ||
if !rustflags.contains(value) { | ||
if !rustflags.is_empty() { | ||
rustflags.push(' '); | ||
} | ||
rustflags.push_str(value); | ||
} | ||
} | ||
_ => { | ||
final_env.insert(key, value.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.
this is just a simplification to avoid concatenating with value from env.
It will be simply -Awarnings
for abi builds and -C link-arg=-s
for wasm builds
// CARGO_ENCODED_RUSTFLAGS="-Awarnings" and RUSTFLAGS="-Awarnings" both result | ||
// in mysterious failures of `cargo build --target wasm32-unknown-unknown` (rustc bug) | ||
cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); |
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.
The comment says that both CARGO_ENCODED_RUSTFLAGS
and RUSTFLAGS
cause problems, but we only remove CARGO_ENCODED_RUSTFLAGS
, is this intended?
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.
RUSTFLAGS gets reset to unset in build scripts, so the 2nd or 3rd of 4th build won't inherit this value from
previous 1st or 2nd or 3rd one,
and the 1st build isn't having its value concatenated with value from env as per another commented change,
and will have it defined as -Awarnings
for abi builds and -C link-arg=-s
for wasm builds
somewhat redundantly tested this on dj8yfo/neardevhub-treasury-dashboard@6e8f765 via build log only (no deploy): - Binary: /home/near/code/web4/treasury-web4/target/near/treasury_web4.wasm
- SHA-256 checksum hex : 94d35d0c174020f04a59cbe18f8408021e3f86a0d426686fb8e9f2a64b0a2323
- SHA-256 checksum bs58: B1xGfvAYbi4ZktyztiiqGaVbvG7JtXmBuxc3rUV1s7HU │ warning: [email protected]: Build artifact path: /home/near/code/web4/treasury-web4/target/near/treasury_web4.wasm
│ warning: [email protected]: Sub-build artifact SHA-256 checksum hex: 94d35d0c174020f04a59cbe18f8408021e3f86a0d426686fb8e9f2a64b0a2323
│ warning: [email protected]: Sub-build artifact SHA-256 checksum bs58: B1xGfvAYbi4ZktyztiiqGaVbvG7JtXmBuxc3rUV1s7HU
│ warning: [email protected]:
│ warning: [email protected]:
│ warning: [email protected]: Path to result artifact of build is exported to `BUILD_RS_WEB4_TREASURY_WEB4_WASM` |
@race-of-sloths include |
@dj8yfo Thank you for your contribution! Your pull request is now a part of the Race of Sloths! Current status: executed
Your contribution is much appreciated with a final score of 13! @akorchyn received 25 Sloth Points for reviewing and scoring this pull request. What is the Race of SlothsRace of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow For contributors:
For maintainers:
Feel free to check our website for additional details! Bot commands
|
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.
@race-of-sloths score 13
Good job!
6930c38
to
3c168e3
Compare
@@ -109,7 +109,7 @@ impl ReproducibleBuild { | |||
for command_token in build_command { | |||
if command_token | |||
.chars() | |||
.any(|c| !c.is_ascii() || c.is_ascii_control() || c.is_ascii_whitespace()) | |||
.any(|c| !c.is_ascii() || c.is_ascii_control()) |
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.
changing this allows doing
container_build_command = ["cargo", "near", "build", "non-reproducible-wasm", "--locked", "--env", "RUSTFLAGS=--verbose -C link-arg=-s"]
## 🤖 New release * `cargo-near`: 0.13.2 -> 0.13.3 (✓ API compatible changes) * `cargo-near-build`: 0.4.2 -> 0.4.3 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> ## `cargo-near` <blockquote> ## [0.13.3](cargo-near-v0.13.2...cargo-near-v0.13.3) - 2025-01-22 ### Other - update near-cli-rs to 0.18.0 (#293) - update `cargo near new` template `image` and `image_digest` ([#288](#288)) - update `cargo near new` template `image` and `image_digest` ([#283](#283)) </blockquote> ## `cargo-near-build` <blockquote> ## [0.4.3](cargo-near-build-v0.4.2...cargo-near-build-v0.4.3) - 2025-01-22 ### Fixed - remove from env CARGO_ENCODED_RUSTFLAGS for easier nested builds, simplify RUSTFLAGS computation rule (#289) ### Other - optimize out retriggering 2nd stage of build + of wasmopt stage in tests context (#292) - update `cargo near new` template `image` and `image_digest` ([#288](#288)) - unpin `cc` after issue resolution (#285) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
resolves #287
this stuff gets set for build-scripts https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/custom_build.rs#L378, while
RUSTFLAGS
is unsettested to help resolve problem in #287 on dj8yfo/neardevhub-treasury-dashboard@56bcbcf