Skip to content

Commit 588d286

Browse files
committed
workaround for invalid binary created on windows
when target native features are used. See #508
1 parent 845f221 commit 588d286

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/codegen.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4959,8 +4959,16 @@ static void init(CodeGen *g) {
49594959
const char *target_specific_cpu_args;
49604960
const char *target_specific_features;
49614961
if (g->is_native_target) {
4962-
target_specific_cpu_args = ZigLLVMGetHostCPUName();
4963-
target_specific_features = ZigLLVMGetNativeFeatures();
4962+
// LLVM creates invalid binaries on Windows sometimes.
4963+
// See https://github.com/zig-lang/zig/issues/508
4964+
// As a workaround we do not use target native features on Windows.
4965+
if (g->zig_target.os == ZigLLVM_Win32) {
4966+
target_specific_cpu_args = "";
4967+
target_specific_features = "";
4968+
} else {
4969+
target_specific_cpu_args = ZigLLVMGetHostCPUName();
4970+
target_specific_features = ZigLLVMGetNativeFeatures();
4971+
}
49644972
} else {
49654973
target_specific_cpu_args = "";
49664974
target_specific_features = "";

0 commit comments

Comments
 (0)