-
Notifications
You must be signed in to change notification settings - Fork 571
Description
prefer_clang_cl_over_msvc is only tweakable from crates directly using cc-rs, however, this is a "toolchain-specific" setting which is usually the responsibility of a higher scope of the build.
If I missed something, I apologize in advance and please point me to the right direction.
Use case: I want/can to only use clang-cl in my toolchain, some of my crates are depending on a dependency like zstd-sys which uses cc-rs under the hood to compile some C code. I did not find any way to propagate my desire to prefer clang-cl over MSVC to the transitivecc-rs dependency.
We could in theory ask every single author of crates that use cc-rs to expose some parameter in their build.rs too which propagates that boolean to their usage of cc-rs.
But it seems quite tedious, e.g. my build has 4-5 dependencies using cc-rs, it would require a tremendous effort to convince/contribute to all crates that does not allow such propagation (all of them currently 😄).
Maybe something like an env var would work?
As a mitigation, I depend on a fork with that patch applied, but this is of course not ideal for us 😅:
Index: src/lib.rs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs (revision df67ed3948377535664362bac6ccb9ad6af4ee67)
+++ b/src/lib.rs (revision 6cf7186175096ee63b34a22debe06cf988a9a437)
@@ -551,7 +551,7 @@
shell_escaped_flags: None,
build_cache: Arc::default(),
inherit_rustflags: true,
- prefer_clang_cl_over_msvc: false,
+ prefer_clang_cl_over_msvc: true,
}
}