From d478a4655ed038c5d5eb5040774e07e55400b4b3 Mon Sep 17 00:00:00 2001 From: Han Sangjin Date: Sat, 30 Apr 2016 08:47:07 +0900 Subject: [PATCH] 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. --- lib/Basic/LangOptions.cpp | 3 +++ test/Parse/ConditionalCompilation/x64CygwinTarget.swift | 8 ++++++++ test/Parse/ConditionalCompilation/x64WindowsTarget.swift | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/Parse/ConditionalCompilation/x64CygwinTarget.swift diff --git a/lib/Basic/LangOptions.cpp b/lib/Basic/LangOptions.cpp index f2356bac9857c..686e3f9918f3a 100644 --- a/lib/Basic/LangOptions.cpp +++ b/lib/Basic/LangOptions.cpp @@ -33,6 +33,7 @@ static const StringRef SupportedConditionalCompilationOSs[] = { "Windows", "Android", "PS4", + "Cygwin" }; static const StringRef SupportedConditionalCompilationArches[] = { @@ -125,6 +126,8 @@ std::pair LangOptions::setTarget(llvm::Triple triple) { addPlatformConditionValue("os", "Linux"); else if (triple.isOSFreeBSD()) addPlatformConditionValue("os", "FreeBSD"); + else if (triple.isWindowsCygwinEnvironment()) + addPlatformConditionValue("os", "Cygwin"); else if (triple.isOSWindows()) addPlatformConditionValue("os", "Windows"); else if (triple.isPS4()) diff --git a/test/Parse/ConditionalCompilation/x64CygwinTarget.swift b/test/Parse/ConditionalCompilation/x64CygwinTarget.swift new file mode 100644 index 0000000000000..a5ac4ce055cb5 --- /dev/null +++ b/test/Parse/ConditionalCompilation/x64CygwinTarget.swift @@ -0,0 +1,8 @@ +// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-cygnus -disable-objc-interop -D FOO -parse-stdlib +// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus + +#if arch(x86_64) && os(Cygwin) && _runtime(_Native) +class C {} +var x = C() +#endif +var y = x diff --git a/test/Parse/ConditionalCompilation/x64WindowsTarget.swift b/test/Parse/ConditionalCompilation/x64WindowsTarget.swift index 40a5552514a75..f37beac9dc589 100644 --- a/test/Parse/ConditionalCompilation/x64WindowsTarget.swift +++ b/test/Parse/ConditionalCompilation/x64WindowsTarget.swift @@ -1,5 +1,5 @@ -// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-cygnus -disable-objc-interop -D FOO -parse-stdlib -// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus +// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-msvc -disable-objc-interop -D FOO -parse-stdlib +// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-msvc #if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) class C {}