Skip to content

[Shepherd] Treat Cygwin as a separate OS #10359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Jun 17, 2017

To re-up the discussion that terminated with Chris believing that this kind of thing could only help, not hurt, I've rebased #2351.

// cc @tinysun212

@CodaFi CodaFi requested a review from jrose-apple June 17, 2017 20:29
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 17, 2017

@swift-ci please smoke test

@CodaFi CodaFi changed the title Treat Cygwin as a separate OS [Shepherd] Treat Cygwin as a separate OS Jun 17, 2017
@tinysun212
Copy link
Contributor

Thanks to re-up os(Cygwin). I thought that my past PR is dying.

Many POSIX-compliant systems return the operating system name with the POSIX function uname() and shell command uname. Cygwin also has those.
If we query the OS name under Cygwin environment, it returns 'Cygwin'.

$ uname -o
Cygwin

POSIX-compliant applications that run on Cygwin should recognize its OS as 'Cygwin' without any special logic.
I think that the Cygwin port of Swift compiler is a POSIX application and it can be natural to recognize the OS name to be the output of the uname under POSIX system.

If this is merged, the macro definition used in Glibc port and Foundation port can be replaced in the cleaner way. swiftpm port (swiftlang/swift-package-manager#733) also can be reopened.

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 17, 2017

The base patch is also incomplete. There are numerous places where we guard on os(Windows) || CYGWIN (or, more often than not, !os(Windows) || CYGWIN) that need to be changed.

@CodaFi CodaFi force-pushed the cygni-imperator branch from 3b042c0 to f38e6f7 Compare June 18, 2017 02:36
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 18, 2017

@tinysun212 I've re-arranged the platform conditionals throughout the standard library and stdlib unit test to align with this patch. Can you please run the unit tests on a Cygwin build and see if I've accidentally regressed something?

@CodaFi CodaFi force-pushed the cygni-imperator branch from f38e6f7 to 26f127f Compare June 18, 2017 05:55
@@ -157,6 +158,8 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
addPlatformConditionValue(PlatformConditionKind::OS, "FreeBSD");
else if (triple.isOSWindows())
addPlatformConditionValue(PlatformConditionKind::OS, "Windows");
else if (triple.isWindowsCygwinEnvironment())
addPlatformConditionValue(PlatformConditionKind::OS, "Cygwin");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Cygwin, triple.isOSWindows() and triple.isWindowsCygwinEnvironment() are all true.
The condition order should be changed. After changed, os(Windows) will be false and only os(Cygwin) will be true.

@@ -104,7 +104,7 @@ public typealias StringLiteralType = String
// IEEE Binary64, and we need 1 bit to represent the sign. Instead of using
// 1025, we use the next round number -- 2048.
public typealias _MaxBuiltinIntegerType = Builtin.Int2048
#if (!os(Windows) || CYGWIN) && (arch(i386) || arch(x86_64))
#if os(Cygwin) && (arch(i386) || arch(x86_64))
Copy link
Contributor

@tinysun212 tinysun212 Jun 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just drop CYGWIN.
#if !os(Windows) && (arch(i386) || arch(x86_64))

Linux i386/x86_64, Cygwin i386/x86_64 and macOS x86_64 have Builtin.FPIEEE80.
Windows i386/x86_64 and other CPUs have Builtin.FPIEEE64.

@@ -43,14 +43,14 @@ public typealias CShort = Int16
public typealias CInt = Int32

/// The C 'long' type.
#if os(Windows) && !CYGWIN && arch(x86_64)
#if os(Windows) && !os(Cygwin) && arch(x86_64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old os(Windows) && !CYGWIN is equivalent to new os(Windows).
Just drop && !CYGWIN.
Change to #if os(Windows) && arch(x86_64)

public typealias CLong = Int32
#else
public typealias CLong = Int
#endif

/// The C 'long long' type.
#if os(Windows) && !CYGWIN && arch(x86_64)
#if os(Windows) && !os(Cygwin) && arch(x86_64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment.

@tinysun212
Copy link
Contributor

That's all.
I cherry-picked this PR (with my comments) to my working Cygwin port and not found any regression.

@CodaFi CodaFi force-pushed the cygni-imperator branch from 26f127f to cfe2eb3 Compare June 18, 2017 17:45
// posix_spawn is not available on Android or Windows.
#if os(Windows)
// posix_spawn is not available on Windows.
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to collapse these two conditionals, I think. There's nothing particularly special about Windows or Android.

@CodaFi CodaFi force-pushed the cygni-imperator branch from cfe2eb3 to 912c560 Compare June 20, 2017 08:04
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 20, 2017

@swift-ci please smoke test and merge

@CodaFi CodaFi force-pushed the cygni-imperator branch from 912c560 to 09357c3 Compare June 28, 2017 17:52
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 28, 2017

@swift-ci please smoke test

Cygwin is considered a distinct target with a distinct ABI, environment
conditions, and data types.  Though the goal of the project is
native Windows integration with UNIX-likes, that is not compatible with
the idea that the platform can be ignored as Win-like enough to have the
existing os(Windows) condition apply.
@CodaFi CodaFi force-pushed the cygni-imperator branch from 09357c3 to 0cf1b52 Compare June 28, 2017 20:31
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 28, 2017

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 4830841 into swiftlang:master Jun 28, 2017
@CodaFi CodaFi deleted the cygni-imperator branch June 28, 2017 21:12
@tinysun212
Copy link
Contributor

I'm very glad as if my old PR was passed.
Thanks @CodaFi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants