Skip to content

Commit d478a46

Browse files
committed
Compiler: Cygwin is identified by os(Cygwin) instead of os(Windows)
Since MinGW, Cygwin and MSVC are definitely vary greatly in ABI and C language level behavior, it is neccessary to distinguish each other in Swift. (In target name, MSVC is x86_64-*-windows-msvc, Cygwin is x86_64-*-windows-cygnus) Before change, os(Windows) was *-*-windows-*, and now, os(Cygwin) is for *-*-windows-cygnus, and os(Windows) is for the rest.
1 parent 13a9908 commit d478a46

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/Basic/LangOptions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static const StringRef SupportedConditionalCompilationOSs[] = {
3333
"Windows",
3434
"Android",
3535
"PS4",
36+
"Cygwin"
3637
};
3738

3839
static const StringRef SupportedConditionalCompilationArches[] = {
@@ -125,6 +126,8 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
125126
addPlatformConditionValue("os", "Linux");
126127
else if (triple.isOSFreeBSD())
127128
addPlatformConditionValue("os", "FreeBSD");
129+
else if (triple.isWindowsCygwinEnvironment())
130+
addPlatformConditionValue("os", "Cygwin");
128131
else if (triple.isOSWindows())
129132
addPlatformConditionValue("os", "Windows");
130133
else if (triple.isPS4())
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-cygnus -disable-objc-interop -D FOO -parse-stdlib
2+
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus
3+
4+
#if arch(x86_64) && os(Cygwin) && _runtime(_Native)
5+
class C {}
6+
var x = C()
7+
#endif
8+
var y = x

test/Parse/ConditionalCompilation/x64WindowsTarget.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-cygnus -disable-objc-interop -D FOO -parse-stdlib
2-
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus
1+
// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-msvc -disable-objc-interop -D FOO -parse-stdlib
2+
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-msvc
33

44
#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little)
55
class C {}

0 commit comments

Comments
 (0)