From 1c5a7e79b84a0404cd015606475f5e95f55325e3 Mon Sep 17 00:00:00 2001 From: cwshugg Date: Thu, 14 Nov 2024 11:35:20 -0500 Subject: [PATCH] added conditional for Windows systems that uses '/std:c++17' rather than '-std=c++17'. MSVC ignores the Linux-friendly syntax and does not apply the C++ standard preference --- build.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index e549e3f..9476ab2 100644 --- a/build.rs +++ b/build.rs @@ -31,7 +31,19 @@ fn build_and_link_libfuzzer() { println!("cargo:rerun-if-changed={}", source.display()); build.file(source.to_str().unwrap()); } - build.flag("-std=c++17"); + + // On Windows, the MSVC compiler has a different flag syntax for setting the C++ version. + // If we're building on Windows, use `/std:c++17`. Otherwise, use the Linux-friendly + // syntax. See this link for information on the MSVC option: + // + // https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version + if cfg!(target_os = "windows") { + build.flag("/std:c++17"); + } + else { + build.flag("-std=c++17"); + } + build.flag("-fno-omit-frame-pointer"); build.flag("-w"); build.cpp(true);