Skip to content

Commit 6423a56

Browse files
committed
Add MSVC compiler flags in build.rs
- /EHsc: Enable C++ exception handling (required by std::ostringstream) - /wd4127: Disable 'conditional expression is constant' warning that triggers in hex_float.h template code
1 parent d5211be commit 6423a56

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

rust/spirv-tools-ffi/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ fn main() {
3939
.std("c++17")
4040
.warnings_into_errors(true);
4141

42+
// MSVC-specific flags
43+
if env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") {
44+
// /EHsc: Enable C++ exception handling (required by std::ostringstream)
45+
bridge_builder.flag("/EHsc");
46+
// Disable C4127: conditional expression is constant (triggers in hex_float.h templates)
47+
bridge_builder.flag("/wd4127");
48+
}
49+
4250
// When building as part of CMake (SPIRV_ENABLE_RUST_TARGET_ENV), the C++ libraries
4351
// are linked by CMake at final link time. We skip emitting link directives here
4452
// to avoid circular dependencies during parallel builds.

0 commit comments

Comments
 (0)