Skip to content

Commit e68ab43

Browse files
authored
Merge pull request swiftlang#20474 from tinysun212/pr-swiftc-cygwin-3
2 parents 1be22c5 + 577ffab commit e68ab43

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/IRGen/GenClangType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ ClangTypeConverter::reverseBuiltinTypeMapping(IRGenModule &IGM,
324324
// On 64-bit Windows, no C type is imported as an Int or UInt; CLong is
325325
// imported as an Int32 and CLongLong as an Int64. Therefore, manually
326326
// add mappings to C for Int and UInt.
327-
if (IGM.Triple.isOSWindows() && IGM.Triple.isArch64Bit()) {
327+
// On 64-bit Cygwin, no manual mapping is required.
328+
if (IGM.Triple.isOSWindows() && !IGM.Triple.isWindowsCygwinEnvironment() &&
329+
IGM.Triple.isArch64Bit()) {
328330
// Map UInt to uintptr_t
329331
auto swiftUIntType = getNamedSwiftType(stdlib, "UInt");
330332
auto clangUIntPtrType = ctx.getCanonicalType(ctx.getUIntPtrType());

lib/IRGen/IRGen.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,17 @@ swift::createTargetMachine(IRGenOptions &Opts, ASTContext &Ctx) {
676676
}
677677

678678

679+
// On Cygwin 64 bit, dlls are loaded above the max address for 32 bits.
680+
// This means that the default CodeModel causes generated code to segfault
681+
// when run.
682+
Optional<CodeModel::Model> cmodel = None;
683+
if (EffectiveTriple.isArch64Bit() && EffectiveTriple.isWindowsCygwinEnvironment())
684+
cmodel = CodeModel::Large;
685+
679686
// Create a target machine.
680687
llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
681688
EffectiveTriple.str(), CPU, targetFeatures, TargetOpts, Reloc::PIC_,
682-
None, OptLevel);
689+
cmodel, OptLevel);
683690
if (!TargetMachine) {
684691
Ctx.Diags.diagnose(SourceLoc(), diag::no_llvm_target,
685692
EffectiveTriple.str(), "no LLVM target machine");

0 commit comments

Comments
 (0)