Skip to content

Fix two issues with the SwiftGlibc module map #32404

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 9 commits into from
Jan 11, 2021

Conversation

martinboehme
Copy link
Contributor

The issues are:

  • Today, some submodules in SwiftGlibc fail to provide definitions that they should contain. As a consequence, Swift fails to import some code that compiles correctly with standalone Clang. As just one example, including signal.h should make the type pid_t available, but it currently does not.

  • SwiftGlibc is not compatible with the libc++ module map. Trying to include libc++ headers in a C++ module imported into Swift results in an error message about cyclic dependencies.

This change fixes both of these issues by making it so that SwiftGlibc no actually longer defines a module map for the glibc headers but merely makes all of the symbols from those headers available in a module that can be imported into Swift. C / Objective-C / C++ code, on the other hand, will now include the glibc headers texually.

For more context on the two issues and this fix, see this forum discussion:

https://forums.swift.org/t/problems-with-swiftglibc-and-proposed-fix/37594

This change only modifies glibc.modulemap.gyb for the time being but leaves bionic.modulemap.gyb and libc-openbsd.modulemap.gyb unchanged. The intent is to fix these in the same way, but it will be easier to do this in separate PRs that can be tested individually.

@martinboehme
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a0ec0fd16b6350065ace857cdae8df9e2988762d

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a0ec0fd16b6350065ace857cdae8df9e2988762d

@gribozavr gribozavr requested a review from DougGregor June 16, 2020 12:45
@gribozavr gribozavr added the c++ interop Feature: Interoperability with C++ label Jun 16, 2020
@martinboehme
Copy link
Contributor Author

@swift-ci Please test OS X

@martinboehme
Copy link
Contributor Author

A fix for the broken test on Linux is in progress at #32465.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7efdc17714aa0b70efcb195e444944c58e2c8c5b

@martinboehme
Copy link
Contributor Author

Build failed
Swift Test OS X Platform
Git Sha - 7efdc17

This is failing with what looks like an unrelated error:

/Users/buildnode/jenkins/workspace/swift-PR-osx/branch-master/swift/test/Constraints/operator.swift:223:26: error: incorrect message found
09:06:03   // expected-error@-1 {{referencing operator function '==' on 'Array' requires that 'Dictionary<String, E>.Values' conform to 'Equatable'}}
09:06:03                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
09:06:03                          operator function '==' requires that 'Dictionary<String, E>.Values' conform to 'Equatable'

@shahmishal
Copy link
Member

Please update the base branch to main by Oct 5th otherwise the pull request will be closed automatically.

  • How to change the base branch: (Link)
  • More detail about the branch update: (Link)

@scentini scentini changed the base branch from master to main October 1, 2020 08:56
@zoecarver zoecarver force-pushed the swift-glibc-fix branch 2 times, most recently from 4f063e6 to 6754c9c Compare October 7, 2020 17:20
@zoecarver
Copy link
Contributor

@swift-ci please smoke test.

@zoecarver
Copy link
Contributor

@swift-ci please smoke test linux platform.

@zoecarver
Copy link
Contributor

(This comment is just so I remember what needs to be done.) To get the Linux build green we need to remove the @_implementationOnly decorator from before import CoreFoundation in three files in swift-corelibs-foundation: Sources/Foundation/Data.swift, Sources/Foundation/NSLock.swift, and Sources/Foundation/Thread.swift.

@scentini
Copy link
Contributor

@swift-ci please smoke test linux platform.

@zoecarver
Copy link
Contributor

@scentini see my above comment. We're going to need to update those three files to get the Linux build working.

@scentini
Copy link
Contributor

@zoecarver we are looking into fixing @_implementationOnly instead, see SR-13785.

@zoecarver
Copy link
Contributor

@zoecarver we are looking into fixing @_implementationOnly instead, see SR-13785.

Oh, great. That's the better way to fix this :)

@hlopko
Copy link
Contributor

hlopko commented Dec 1, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Dec 1, 2020

Build failed
Swift Test Linux Platform
Git Sha - 968f3350373858d0e167b52fc6a102eec8c48dfd

@hlopko
Copy link
Contributor

hlopko commented Jan 7, 2021

@swift-ci please test

@hlopko
Copy link
Contributor

hlopko commented Jan 8, 2021

We'd like to move forward with this PR. If nobody objects by Monday, we'll submit. We're happy to address all post-submit review comments. Thanks!

Copy link
Contributor

@zoecarver zoecarver left a comment

Choose a reason for hiding this comment

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

FWIW this LGTM. Ship it.

@drodriguez
Copy link
Contributor

Not a blocker: Bionic (Android) has a different modulemap (stdlib/public/Platform/bionic.modulemap.gyb), which this PR doesn't change. From my understanding of forum post and the changes in this PR, it should be possible to do the same in Android and remove the specific module map, right?

Once this lands, another PR can be created to do that, no need to change this PR at all (specially because the Android CI cannot be requested for a PR, so checking that it works would be complicated).

@scentini scentini merged commit c5b7e7f into swiftlang:main Jan 11, 2021
@finagolfin
Copy link
Member

@drodriguez, anybody working on the Android version of this pull? I can put it together if noone else is.

@3405691582, you may want to do the same for OpenBSD.

@drodriguez
Copy link
Contributor

@buttaface I had the first step working (removing the complicated modulemap), but the test were failing. In the Android case, I think mostly because of the cross-compilation. These weekends have been quite busy and I haven't had time to work on anything, so if you want to have a try at this, feel free. Also, sorry for not being able to test and merge the other PR you had open. I will try to make time at some point.

@finagolfin
Copy link
Member

@drodriguez, no problem, I figured you were busy. If we get this modulemap change in first, we may not need to modify that C++ test in the NDK pull, so I will try to get this working first.

3405691582 added a commit to 3405691582/swift that referenced this pull request Feb 11, 2022
This migrates OpenBSD to use the single-header Glibc modulemap proposed
and implemented in swiftlang#32404, and necessitates introducing some missing
headers for building Foundation added in swiftlang#38341.

Additionally, incorporate nullability annotations in SwiftShims per
finagolfin pushed a commit to finagolfin/swift that referenced this pull request Feb 22, 2022
This migrates OpenBSD to use the single-header Glibc modulemap proposed
and implemented in swiftlang#32404, and necessitates introducing some missing
headers for building Foundation added in swiftlang#38341.

Additionally, incorporate nullability annotations in SwiftShims per
mhjacobson added a commit to mhjacobson/swift that referenced this pull request Nov 20, 2022
When SwiftGlibc.h was added in swiftlang#32404, no cmake code was added to copy it to the
static resources.  Copy it along with glibc.modulemap, which references it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants