Comments (5)
Thanks for the report! If you removed -Z build-std
, did you also remove the --target
flag? Also, when you say whether or not build.rs
is recompiled, is it important to you that the build script itself is recompiled, or just that it runs again and picks up the new CARGO_ENCODED_RUSTFLAGS
? It's unclear what C libraries you are referring to, or how they are being built, or how this relates to the build script and RUSTFLAGS. If you can provide a complete and minimal reproduction, it can be helpful to see exactly what you are doing and trying to accomplish.
Assuming that you removed --target
, and that you only care about running the script again, then this unrelated to -Z build-std
and is a duplicate of #13003.
from cargo.
Thanks for the report! If you removed -Z build-std, did you also remove the --target flag?
No, just -Z build-std
to minimize changes. --target
on its own doesn't cause any issues for me.
Also, when you say whether or not build.rs is recompiled, is it important to you that the build script itself is recompiled, or just that it runs again and picks up the new CARGO_ENCODED_RUSTFLAGS?
Apologies, I meant that whatever build.rs
compiles to doesn't re-run on CPU change.
It's unclear what C libraries you are referring to, or how they are being built, or how this relates to the build script and RUSTFLAGS.
build.rs
calls https://github.com/rust-lang/cc-rs when run. So the first time it compiled libraries for Skylake with certain newer instructions and later when I recompiled for different CPU without clearing target
I discovered that it crashes on older processors due to newer instructions being still in the library. I later reduced and reported the issue.
from cargo.
Hm, I'm not aware of cc
looking at the target-cpu. Can you please post a complete, minimal reproduction, along with exactly what appears to not be being picked up in the build script? Here's exactly what I'm seeing:
[package]
name = "foo"
[build-dependencies]
cc = "1.0.90"
// src/main.rs
fn main() {}
// build.rs
fn main() {
cc::Build::new().file("foo.c").compile("foo");
}
/* foo.c */
RUSTFLAGS="-C target-cpu=skylake" CC_ENABLE_DEBUG_OUTPUT=1 cargo build -vv -Zbuild-std --target x86_64-unknown-linux-gnu
The exact compiler command this displays as running:
[foo 0.0.0] running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-o" "/home/eric/Temp/foo/target/x86_64-unknown-linux-gnu/debug/build/foo-dcda6d277b285a73/out/d1fba762150c532c-foo.o" "-c" "foo.c"
Notice that it does not mention -mcpu
or anything like that. Running with a different CPU:
cargo clean
RUSTFLAGS="-C target-cpu=x86-64-v2" CC_ENABLE_DEBUG_OUTPUT=1 cargo build -vv -Zbuild-std --target x86_64-unknown-linux-gnu
doesn't change the output. cc
is building it identically.
from cargo.
// build.rs
fn main() {
std::fs::write(
format!("{}/rustflags.rs", std::env::var("OUT_DIR").unwrap()),
std::env::var("CARGO_ENCODED_RUSTFLAGS").unwrap_or_default(),
)
.unwrap();
}
// src/main.rs
fn main() {
println!(
"{}",
include_str!(concat!(env!("OUT_DIR"), "/rustflags.rs"))
);
}
Now do:
RUSTFLAGS="-C target-cpu=skylake" cargo +nightly run -Z build-std --target x86_64-unknown-linux-gnu
RUSTFLAGS="-C target-cpu=x86-64-v2" cargo +nightly run -Z build-std --target x86_64-unknown-linux-gnu
You will get:
-Ctarget-cpu=skylake
-Ctarget-cpu=skylake
But should have gotten:
-Ctarget-cpu=skylake
-Ctarget-cpu=x86-64-v2
from cargo.
Thanks! That looks to be a duplicate of #13003, so closing in favor of that.
from cargo.
Related Issues (20)
- cargo new: option to suppress automatic addition to workspace HOT 4
- Include public/private dependency status in `cargo metadata` HOT 2
- Make empty/default fields in the index metadata optional HOT 3
- Support specifying additional config files/values in environment variable.
- `cargo install` when only pre-releases are available HOT 5
- `cargo add` should not silently remove any `path` attribute on dependencies and should support both `version` and `path` attributes HOT 2
- Tracking Issue for location-detail
- Allow `cargo tree` to run despite native library conflicts HOT 2
- `cargo update --verbose` "note" is showing a command that fail HOT 2
- Recommend using `cargo info` after the `cargo search` results HOT 2
- Tracking Issue for native-completion HOT 3
- `[lints]` table reason HOT 2
- Expose lint levels from CLI HOT 11
- Export sanitizer settings in `cargo` CLI HOT 4
- Consider exposing `target_feature` option in cargo CLI HOT 4
- Vendoring of git dependencies is sometimes incorrectly skipped HOT 1
- [patch.crates-io] doesn't correctly override git dependancy HOT 5
- Add support to `cargo tree` for resolving host deps to another platform HOT 2
- Unrelated workspace members affect feature selection even with --bin, unless excluded HOT 1
- Figure out a way to do out-of-band releases of crates in the cargo repo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo.