diff --git a/packages/natives/scripts/build-native.ts b/packages/natives/scripts/build-native.ts index 2778b87fe..194f9faea 100644 --- a/packages/natives/scripts/build-native.ts +++ b/packages/natives/scripts/build-native.ts @@ -376,11 +376,15 @@ if (crossTarget) { // enforces per-function target features: opus' silk/x86 SSE4.1 units fail to // build without the feature enabled globally. The win32 x64 addon floor is // x86-64-v2 (SSE4.2 inclusive), so enabling it for all C deps is safe. + // cargo-xwin overwrites `CFLAGS_` on the cargo it spawns but appends + // the plain `CFLAGS`/`CXXFLAGS` values into it, so those are the only knobs + // that survive. if (crossTarget.endsWith("-msvc") && targetArch === "x64") { - const envKey = `CFLAGS_${bareTriple.replace(/-/g, "_")}`; - const existing = process.env[envKey] ?? ""; - const sseFlags = "-msse4.1 -msse4.2"; - process.env[envKey] = existing ? `${existing} ${sseFlags}` : sseFlags; + for (const envKey of ["CFLAGS", "CXXFLAGS"]) { + const existing = process.env[envKey] ?? ""; + const sseFlags = "-msse4.1 -msse4.2"; + process.env[envKey] = existing ? `${existing} ${sseFlags}` : sseFlags; + } } // napi 3.7.0 resolves the built artifact from the FULL `--target` directory, // but cargo-zigbuild writes under the bare triple; bridge the two so napi's