From e30fad6a9bdca213f58cc811dbb8cba3ae210fc5 Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 21:35:47 -0500 Subject: [PATCH 1/9] #2415 /Zm20000 increases the available memory for macro expansion and precompiled header processing with MSVC --- build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/build.rs b/build.rs index 786808edcf..835645e376 100644 --- a/build.rs +++ b/build.rs @@ -151,6 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", + "/Zm20000", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant From 616918b977500dac6bf946eace2e43e2d08b2d9e Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 22:28:45 -0500 Subject: [PATCH 2/9] nasm will check for ./target/tools nasm, if its not there, try and use env nasm --- build.rs | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index 835645e376..6b40942535 100644 --- a/build.rs +++ b/build.rs @@ -151,7 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", - "/Zm20000", + "/Zm125", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant @@ -607,11 +607,12 @@ fn configure_cc(c: &mut cc::Build, target: &Target, c_root_dir: &Path, include_d } } + fn nasm(file: &Path, arch: &str, include_dir: &Path, out_dir: &Path, c_root_dir: &Path) { let out_file = obj_path(out_dir, file); let oformat = match arch { x if x == X86_64 => "win64", - x if x == X86 => "win32", + x if x == X86 => "win32", _ => panic!("unsupported arch: {}", arch), }; @@ -619,9 +620,10 @@ fn nasm(file: &Path, arch: &str, include_dir: &Path, out_dir: &Path, c_root_dir: let mut include_dir = include_dir.as_os_str().to_os_string(); include_dir.push(OsString::from(String::from(std::path::MAIN_SEPARATOR))); - let mut c = Command::new("./target/tools/windows/nasm/nasm"); - let _ = c - .arg("-o") + let nasm_exe = get_nasm_executable(); + + let mut c = Command::new(nasm_exe); + c.arg("-o") .arg(out_file.to_str().expect("Invalid path")) .arg("-f") .arg(oformat) @@ -635,6 +637,31 @@ fn nasm(file: &Path, arch: &str, include_dir: &Path, out_dir: &Path, c_root_dir: run_command(c); } +fn get_nasm_executable() -> PathBuf { + // First, try the default target path. + let default_path = if cfg!(target_os = "windows") { + PathBuf::from("./target/tools/windows/nasm/nasm.exe") + } else { + PathBuf::from("./target/tools/windows/nasm/nasm") + }; + if default_path.exists() { + return default_path; + } + // If the default isn't there, try to run "nasm" (or "nasm.exe" on Windows) + let fallback = if cfg!(target_os = "windows") { + "nasm.exe" + } else { + "nasm" + }; + // Try executing fallback with --version to see if it is available. + if let Ok(output) = Command::new(fallback).arg("--version").output() { + if output.status.success() { + return PathBuf::from(fallback); + } + } + panic!("Nasm executable not found. Please install NASM or ensure it is available in your PATH."); +} + fn run_command_with_args(command_name: &Path, args: &[OsString]) { let mut cmd = Command::new(command_name); let _ = cmd.args(args); From 725b474272ee994fd715658efcedb11a19a7319e Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 22:33:17 -0500 Subject: [PATCH 3/9] 2000 --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 6b40942535..a7ad8d6763 100644 --- a/build.rs +++ b/build.rs @@ -151,7 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", - "/Zm125", + "/Zm2000", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant From 795f5dac7a4c31692422c72f804e26f6b6731078 Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 22:37:20 -0500 Subject: [PATCH 4/9] 5000 --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index a7ad8d6763..615d1a98ec 100644 --- a/build.rs +++ b/build.rs @@ -151,7 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", - "/Zm2000", + "/Zm5000", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant From 8dd9172e173d40aa314f3f2fa91635529895238d Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 22:41:28 -0500 Subject: [PATCH 5/9] 3000 --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 615d1a98ec..8c08072326 100644 --- a/build.rs +++ b/build.rs @@ -151,7 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", - "/Zm5000", + "/Zm3000", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant From 87d5f2737105ed5a10812562e23b28427be538e0 Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 22:42:24 -0500 Subject: [PATCH 6/9] 5000 --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 8c08072326..69803930ad 100644 --- a/build.rs +++ b/build.rs @@ -151,7 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", - "/Zm3000", + "/Zm2500", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant From 3e8fcc0849916239444a81d85199543b0e286437 Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 22:43:14 -0500 Subject: [PATCH 7/9] 2000 --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 69803930ad..a7ad8d6763 100644 --- a/build.rs +++ b/build.rs @@ -151,7 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", - "/Zm2500", + "/Zm2000", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant From 8ad10e8acb16f91b195dd265a9f80932253ff471 Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 22:45:07 -0500 Subject: [PATCH 8/9] 20000 --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index a7ad8d6763..fd8124c908 100644 --- a/build.rs +++ b/build.rs @@ -151,7 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", - "/Zm2000", + "/Zm20000", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant From c1297534200812fd685cb1133d13f960de9de5bf Mon Sep 17 00:00:00 2001 From: dave horner Date: Wed, 19 Feb 2025 22:50:11 -0500 Subject: [PATCH 9/9] 2000 --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index fd8124c908..a7ad8d6763 100644 --- a/build.rs +++ b/build.rs @@ -151,7 +151,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", - "/Zm20000", + "/Zm2000", // Warnings. "/Wall", "/wd4127", // C4127: conditional expression is constant