Skip to content

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Jul 9, 2016

What's in this pull request?

Resolved bug number: (SR-)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

This adds the swiftMSVCRT module which is similar in spirit to swiftGlibc and
swiftDarwin, exposing the Microsoft C Runtime library to swift. Furthermore,
disable pieces of the standard library which are not immediately trivially
portable to Windows. A lot of this functionality can still be implemented and
exposed to the user, however, this is the quickest means to a PoC for native
windows support.

As a temporary solution, add a -DCYGWIN flag to indicate that we are building
for the cygwin windows target. This allows us to continue supporting the cygwin
environment whilst making the windows port work natively against the windows
environment (msvc). Eventually, that will hopefully be replaced with an
environment check in swift.

@compnerd
Copy link
Member Author

compnerd commented Jul 9, 2016

CC: @gribozavr

@jrose-apple
Copy link
Contributor

What made you decide on these particular names? ("msvcrt", "ucrt")

@compnerd
Copy link
Member Author

msvcrt: thats what its always been called (Microsoft Visual C Runtime).
ucrt: this is what Microsoft is calling their new library (Universal C Runtime).

@jrose-apple
Copy link
Contributor

I guess more specifically: why msvcrt instead of, e.g., MSVCRT? Is there any convention from the managed runtimes we can follow?

(It's not an unreasonable convention for module names to follow DLL names on Windows. On the other hand, if we think Clang will ever start defining module maps for Windows, we probably want to use the same naming conventions so that switching over is less painful.)

@compnerd
Copy link
Member Author

Im not aware of any managed runtimes mapping those libraries specifically. I just followed the library names. Im not tied to the name if there is a better solution.

I don't think that we can really ever ship module maps for msvcrt in clang. Microsoft could (and has) altered headers associated with the library.

@jckarter
Copy link
Contributor

AIUI, msvcrt refers to the infamous system-private msvcrt.dll, not the CRT you're supposed to really link user programs against, doesn't it?

@compnerd
Copy link
Member Author

They are the one and the same. msvcrt is the c library. These days, its actually versioned (e.g. msvcr140.dll). msvcrt refers to that entity. You link against msvcrt.lib which is the import library for the dll.

@compnerd
Copy link
Member Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor

Okay, if Dmitri's happy with the implementation I'm good with the names.

@@ -187,6 +209,7 @@ public func open(
return _swift_Platform_open(path, oflag, 0)
}

#if !os(Windows) || CYGWIN
public func open(
_ path: UnsafePointer<CChar>,
_ oflag: Int32,
Copy link
Contributor

Choose a reason for hiding this comment

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

You've shimmed open() with the mode on Windows, why did you have to hide this overload?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because theres no openat equivalent atm. This is possible to do and unhide this, but, Im trying to get an immediate port going. It would be possible to get an implementation of openat and then unhide this in a follow up.

Copy link
Contributor

Choose a reason for hiding this comment

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

But this is not openat, this is open with a file mode...

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I meant, that because it calls openat. Now, arguably that is a bug, and we should fix that :-).

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ugh, I see what you mean. This was supposed to have an alternate implementation with the signature change. Ill fix this in the upload that Im about to do.

@jrose-apple
Copy link
Contributor

@swift-ci Please test OS X platform

This adds the swiftMSVCRT module which is similar in spirit to swiftGlibc and
swiftDarwin, exposing the Microsoft C Runtime library to swift.  Furthermore,
disable pieces of the standard library which are not immediately trivially
portable to Windows.  A lot of this functionality can still be implemented and
exposed to the user, however, this is the quickest means to a PoC for native
windows support.

As a temporary solution, add a -DCYGWIN flag to indicate that we are building
for the cygwin windows target.  This allows us to continue supporting the cygwin
environment whilst making the windows port work natively against the windows
environment (msvc).  Eventually, that will hopefully be replaced with an
environment check in swift.
@compnerd
Copy link
Member Author

@swift-ci Please test

@compnerd
Copy link
Member Author

@swift-ci Please test OS X platform

@gribozavr
Copy link
Contributor

@swift-ci Please test and merge

1 similar comment
@compnerd
Copy link
Member Author

@swift-ci Please test and merge

@gribozavr gribozavr merged commit 0e838c4 into swiftlang:master Jul 13, 2016
@compnerd compnerd deleted the msvc branch July 14, 2016 00:33
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