Skip to content

C++ Interop: add a test for std module interface #39562

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
Oct 6, 2021

Conversation

egorzhdan
Copy link
Contributor

The test checks that the Swift module interface for std & its submodules can be generated & that it contains a couple of known declarations.

This is a follow-up after #37806.

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Oct 3, 2021
@egorzhdan egorzhdan requested a review from zoecarver October 3, 2021 09:08
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan marked this pull request as draft October 3, 2021 12:03
// CHECK-STD: import std.chrono
// CHECK-STD: import std.iosfwd

// CHECK-IOSFWD: extension std.__1 {
Copy link
Contributor

@zoecarver zoecarver Oct 3, 2021

Choose a reason for hiding this comment

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

This will probably need to be different on Linux. I think it's std.__cxx11.string or something like that.

@@ -0,0 +1,33 @@
// RUN: %target-swift-ide-test -print-module -module-to-print=std -source-filename=x -enable-cxx-interop -Xcc -stdlib=libc++ -tools-directory=%llvm_obj_root/bin -module-cache-path %t | %FileCheck %s -check-prefix=CHECK-STD
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm so it looks like here you're specifically testing libc++. I think it would be good to test with whatever stdlib the client's is using.

I'm not sure libstdc++ will work until #38675 lands, so this is OK for now.

Comment on lines +5 to +6
// Clang driver on Windows doesn't support -stdlib=libc++
// XFAIL: OS=windows-msvc
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to see if we can import MSVC's STL. (And if so, add a test for it.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't currently import it: the problem with MSVC's stdlib is that it doesn't have a module map. This should be possible to workaround by manually adding the std definition here: https://github.com/apple/swift/blob/main/stdlib/public/Platform/visualc.modulemap, but I'm not sure that's the best approach.

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.

This looks good. I'm super excited to start testing this!

Other than the nit about std.string, I think this is good to go. Once we have lazy member loading, let's re-visit this test and start checking the system's stdlib rather than libc++ on all platforms.

@zoecarver
Copy link
Contributor

Swift Test Linux Platform (smoke test)

Probably best to just disable this test on Linux until we support libstdc++ (very soon). But I don't feel strongly.

The test checks that the Swift module interface for `std` & its submodules can be generated & that it contains a couple of known declarations.
@egorzhdan egorzhdan force-pushed the cxx-std-module-interface branch from b175771 to bb5f9eb Compare October 4, 2021 18:01
@egorzhdan
Copy link
Contributor Author

Probably best to just disable this test on Linux until we support libstdc++

Agreed, I disabled it on Linux for now.

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan marked this pull request as ready for review October 4, 2021 18:07
@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test Linux

@egorzhdan egorzhdan merged commit bbd9b8f into swiftlang:main Oct 6, 2021
@davezarzycki
Copy link
Contributor

This test is "unexpectedly passing" on my Linux box, so the whole test suite fails. :-(

I think the test should just be REQUIRES: VENDOR=apple for now.

@davezarzycki
Copy link
Contributor

That or UNSUPPORTED: OS=linux-gnu

@davezarzycki
Copy link
Contributor

#39630

@egorzhdan egorzhdan deleted the cxx-std-module-interface branch October 8, 2021 09:08
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.

3 participants