Skip to content

Support Linux on z as a Swift platform #2541

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 11 commits into from
May 25, 2016

Conversation

bryanpkc
Copy link
Contributor

@bryanpkc bryanpkc commented May 16, 2016

What's in this pull request?

This pull request adds support for Linux on IBM z Systems to Swift. It depends on pull requests in the other repos:

apple/swift-clang#13
apple/swift-llvm#8
apple/swift-lldb#27

The first commit in this pull request adds a new platform condition check named endian(), for which there are two possible values (little and big), to allow conditional compilation of endianness-specific Swift code. The second commit constitutes the bulk of infrastructure changes, including new test cases, to add support for the new target. The remaining commits deal with endianness issues in various parts of the compiler and Swift runtime. In particular, handling of enums is not yet completely fixed for big-endian systems, and we are researching a full solution (to be contributed in a future pull request). Nevertheless, the port gives us a usable compiler and REPL. Validation test results show a 0.2% failure rate:

  Expected Passes    : 7308
  Expected Failures  : 71
  Unsupported Tests  : 797
  Unexpected Failures: 19

No regression is observed on x86_64.


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
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
OS X platform @swift-ci Please test OS X platform
Linux platform @swift-ci Please test Linux platform

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

@gribozavr
Copy link
Contributor

The first commit in this pull request adds a new platform condition check named endian(), for which there are two possible values (little and big), to allow conditional compilation of endianness-specific Swift code.

This change needs to go through the Swift evolution process. We can unblock the port by adding it as _endian for now.

@@ -81,6 +81,12 @@ public struct _stdlib_fd_set {
}
}

#if arch(arm) || arch(i386)
public typealias _stdlib_fd_set = __stdlib_fd_set<UInt32>
#else
Copy link
Contributor

Choose a reason for hiding this comment

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

Please list 64-bit platforms explicitly. This ensures that this code breaks when we have a new port, and it is added to the appropriate list.

@gribozavr
Copy link
Contributor

CC @rjmccall @slavapestov for IRGen and runtime changes.

The library parts and test changes LGTM.

@gribozavr
Copy link
Contributor

@bryanpkc This is fantastic! I'm just curious -- what are the failing tests?

@gribozavr
Copy link
Contributor

Let's run CI to verify that there are no regressions on existing platforms.

@swift-ci Please test

@gribozavr
Copy link
Contributor

@bryanpkc Looks like there are test failures on OS X, please take a look.

@bryanpkc
Copy link
Contributor Author

@gribozavr Thanks for your review. I have made changes according to your suggestions and fixed the test failure on OS X.

@gribozavr
Copy link
Contributor

@swift-ci Please test

@gribozavr
Copy link
Contributor

@bryanpkc OS X failed again.

@lattner
Copy link
Contributor

lattner commented May 17, 2016

@gribozavr thank you for the extensive review, I really appreciate it. @bryanpkc please do submit a proposal for adding the endian #if check. I expect it to be mostly a bike shedding exercise, but it is an important one to do and get past.

@rintaro
Copy link
Member

rintaro commented May 17, 2016

@bryanpkc
Copy link
Contributor Author

@gribozavr I think I have fixed the OS X test case for real this time (sorry I cannot run that test myself). I have also simplified the StringUTF8 fix as you suggested. It also helps us pass a few more test cases.

@lattner, @rintaro: Thanks for the link to the draft proposal. It seems that the bitwidth() part of the proposal is more complicated and warrants more discussion, but I can submit the endian() part of it, if @sadun doesn't mind.

@@ -48,8 +48,10 @@ extension _StringCore {
src: UnsafeMutablePointer(startASCII + i),
size: numericCast(utf16Count))

return (i + utf16Count, result)
// Convert the _UTF8Chunk into host endianness.
return (i + utf16Count, _UTF8Chunk(littleEndian: result))
Copy link
Member

@rintaro rintaro May 17, 2016

Choose a reason for hiding this comment

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

I think, we have another endianness problem in _StringCore._nthContiguous(_:).
Sorry, I cannot test myself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rintaro You are right about _nthContiguous() being little-endian only but that is only part of a larger problem. There does not seem to be any support for UTF-16BE in Swift, and supporting it may require considerable changes to the _StringCore code. I am pretty sure that conversion from UTF-8 to UTF-16 is currently broken in this port, but we hope to tackle that in a future pull request (soonish).

@gribozavr
Copy link
Contributor

@bryanpkc Thank you!

@swift-ci Please test

@gribozavr
Copy link
Contributor

@swift-ci Please test OS X platform

1 similar comment
@gribozavr
Copy link
Contributor

@swift-ci Please test OS X platform

@gribozavr
Copy link
Contributor

@swift-ci Please test

@gribozavr
Copy link
Contributor

The CI failed for unrelated reasons.

Ping @rjmccall @slavapestov for IRGen and runtime changes.

@bryanpkc
Copy link
Contributor Author

I have rebased the commits on to the tip of master, and added a couple more fixes for test failures.

@gribozavr
Copy link
Contributor

@slavapestov has reviewed the changes.

@gribozavr
Copy link
Contributor

@swift-ci Please test and merge

@bryanpkc
Copy link
Contributor Author

@gribozavr Thanks for testing. The TestNSJSONSerialization failure does not seem related to my commits.

@gribozavr
Copy link
Contributor

Yes, it isn't.

@gribozavr gribozavr merged commit 2daa140 into swiftlang:master May 25, 2016
@bryanpkc
Copy link
Contributor Author

Thanks for merging.

MaxDesiatov pushed a commit that referenced this pull request Apr 19, 2021
Resolve conflicts with the `main` branch
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.

5 participants