From 1f3ff2c7d184721f19731f46b273a0d74b2a7573 Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Wed, 15 Feb 2017 17:23:01 +0700 Subject: [PATCH] Change the generated code model to Large on Windows 64 bit --- lib/IRGen/IRGen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/IRGen/IRGen.cpp b/lib/IRGen/IRGen.cpp index ddc8652d7dbd6..e0539eda4f0c0 100644 --- a/lib/IRGen/IRGen.cpp +++ b/lib/IRGen/IRGen.cpp @@ -499,7 +499,11 @@ swift::createTargetMachine(IRGenOptions &Opts, ASTContext &Ctx) { // Create a target machine. auto cmodel = CodeModel::Default; - if (Triple.isWindowsCygwinEnvironment()) + + // On Windows 64 bit, dlls are loaded above the max address for 32 bits. + // This means that a default CodeModel causes generated code to segfault + // when run. + if (Triple.isArch64Bit() && Triple.isOSWindows()) cmodel = CodeModel::Large; llvm::TargetMachine *TargetMachine =