Skip to content
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

[SR-11382] 5.1: clang importer sees things differently to 5.0 when it comes to forward declared structs #53783

Closed
weissi opened this issue Aug 27, 2019 · 10 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 5.1

Comments

@weissi
Copy link
Member

weissi commented Aug 27, 2019

Previous ID SR-11382
Radar rdar://problem/54794091
Original Reporter @weissi
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.1Regression, ClangImporter
Assignee None
Priority Medium

md5: abea5a201d771fd6cf25cbde61e6509b

relates to:

  • SR-11125 new, recent Swift 5.1 compiler ambiguity error & crash when compiling project

Issue Description:

The APNSwift project recently received an issue where compilation on Linux would no longer work with Swift 5.1 builds.

/Users/johannes/extsrc/APNSwift/Sources/APNSwift/APNSwiftSigner.swift:56:31: error: use of undeclared type 'BIGNUM'
        var r : UnsafePointer<BIGNUM>? = nil
                              ^~~~~~
/Users/johannes/extsrc/APNSwift/Sources/APNSwift/APNSwiftSigner.swift:57:31: error: use of undeclared type 'BIGNUM'
        var s : UnsafePointer<BIGNUM>? = nil
                              ^~~~~~
/Users/johannes/extsrc/APNSwift/Sources/APNSwift/APNSwiftSigner.swift:56:31: error: use of undeclared type 'BIGNUM'
        var r : UnsafePointer<BIGNUM>? = nil
                              ^~~~~~
/Users/johannes/extsrc/APNSwift/Sources/APNSwift/APNSwiftSigner.swift:57:31: error: use of undeclared type 'BIGNUM'
        var s : UnsafePointer<BIGNUM>? = nil
                              ^~~~~~
/Users/johannes/extsrc/APNSwift/Sources/APNSwift/APNSwiftSigner.swift:56:31: error: use of undeclared type 'BIGNUM'
        var r : UnsafePointer<BIGNUM>? = nil
                              ^~~~~~
/Users/johannes/extsrc/APNSwift/Sources/APNSwift/APNSwiftSigner.swift:57:31: error: use of undeclared type 'BIGNUM'
        var s : UnsafePointer<BIGNUM>? = nil
                              ^~~~~~

BIGNUM seems to be a typedef of the forward declared struct bignum_st:

$ grep -R 'struct bignum_st' /usr/include/
/usr/include/openssl/ossl_typ.h:typedef struct bignum_st BIGNUM;

So I'm actually not too surprised that BIGNUM is undefined in Swift because I'd have expected it to be imported as OpaquePointer (because forward declared).

However, this seems to be a change from Swift 5.0 and I'm not sure this was intended.

Here are two docker commands that are doing the exact same thing, starting from a fresh Ubuntu 18.04. The only difference is the Swift package that they download:

For Swift 5.0.2:

git clone https://github.com/kylebrowning/APNSwift && cd APNSwift
docker run -it --rm -v "$PWD:$PWD" -w "$PWD" ubuntu:18.04 bash -c 'apt-get update && apt-get install -y git curl libxml2-dev build-essential libssl-dev && curl https://swift.org/builds/swift-5.0.2-release/ubuntu1804/swift-5.0.2-RELEASE/swift-5.0.2-RELEASE-ubuntu18.04.tar.gz | tar -C / -xz && export PATH="$PATH:/swift-5.0.2-RELEASE-ubuntu18.04/usr/bin" && swift build'

for swift-5.1-DEVELOPMENT-SNAPSHOT-2019-08-26-a

git clone https://github.com/kylebrowning/APNSwift && cd APNSwift
docker run -it --rm -v "$PWD:$PWD" -w "$PWD" ubuntu:18.04 bash -c 'apt-get update && apt-get install -y git curl libxml2-dev build-essential libssl-dev && curl https://swift.org/builds/swift-5.1-branch/ubuntu1804/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-08-26-a/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-08-26-a-ubuntu18.04.tar.gz | tar -C / -xz && export PATH="$PATH:/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-08-26-a-ubuntu18.04/usr/bin" && swift build'
@belkadan
Copy link
Contributor

I don't think there was any change here, so thanks for reporting!

@swift-ci create

@belkadan
Copy link
Contributor

belkadan commented Sep 7, 2019

Ugh, this is the same problem of BoringSSL and OpenSSL have different definitions for the same types, which means we're in unsupported-land. Swift 5.0 was getting the definition of bignum_st from BoringSSL; Swift 5.1 is not.

@belkadan
Copy link
Contributor

belkadan commented Sep 7, 2019

(I don't know what changed. It might have been something in Clang too. The last time we discussed this was SR-11125.)

@weissi
Copy link
Member Author

weissi commented Sep 8, 2019

@jrose shouldn’t that be covered by NIOSSL now using @implementationOnly import CNIOBoringSSL ?

@weissi
Copy link
Member Author

weissi commented Sep 8, 2019

But in any case this should be fixed by APNSwift by not using the forward declared type.

@belkadan
Copy link
Contributor

belkadan commented Sep 9, 2019

Oh, I didn't realize there'd been a NIO release using implementationOnly yet. That explains it, then: Swift 5.0 doesn't have implementationOnly, and so it's seeing both of them because NIOSSL is written to fall back to a regular import.

@weissi
Copy link
Member Author

weissi commented Sep 9, 2019

@belkadan ooh yes, of course, totally forgot that I made this conditional. Thank you!

@weissi
Copy link
Member Author

weissi commented Sep 9, 2019

@belkadan can we close this then?

@belkadan
Copy link
Contributor

belkadan commented Sep 9, 2019

Sounds good. We know what happened and consider it acceptable, even desirable, breakage.

@belkadan
Copy link
Contributor

belkadan commented Sep 9, 2019

None of the resolutions here really match, oh well.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 5.1
Projects
None yet
Development

No branches or pull requests

3 participants