-
Notifications
You must be signed in to change notification settings - Fork 10.5k
C++ Interop: import namespaces redecls as separate extensions #37695
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
Conversation
6c2dc5d
to
8dbd18b
Compare
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked at the tests yet, but here are some comments.
Thanks again for the PR!
14941cd
to
80e4bfc
Compare
@swift-ci please smoke test |
@swift-ci please test Windows |
80e4bfc
to
83f5146
Compare
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being so slow to review this :/
This patch is really good. So, let's try to get it in pretty soon. I only have a few small comments.
Looks like macos is having an unrelated problem. Let's try again. @swift-ci please smoke test macOS platform. |
@swift-ci please smoke test macOS platform. |
6221bc9
to
4723cf7
Compare
@swift-ci please smoke test |
@swift-ci please test Windows |
@swift-ci please smoke test macOS |
4723cf7
to
2cc300b
Compare
2cc300b
to
ec155ca
Compare
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great work. Thank you for all the time you put into it. This implementation is now much better. I have a few very small nits, you can either take them or leave them. Then 🚢 it.
Previously a namespace declaration was imported along with all of its redeclarations, and their members were added to a single Swift extension. This was problematic when a single namespace is declared in multiple modules – the extension belonged to only one of them. For an example of this, try printing a module interface for `std.string`/`std.iosfwd` – it will be empty, even though the declarations from those modules are actually imported into Swift correctly. This change makes sure that when we're importing different redeclarations of the same namespace, we're adding them as separate extensions to appropriate modules.
ec155ca
to
cfc9483
Compare
@swift-ci please smoke test |
@swift-ci please test Windows |
@swift-ci please smoke test Linux |
Thanks for reviewing this @zoecarver! |
@egorzhdan @zoecarver Is it possible this change causes ASAN failures? |
@rintaro that would seem a bit odd to me. The test that's failing doesn't seem to touch namespaces whatsoever. That being said, this patch did touch the clang importer more generally, so it is possible that it broke that test. Maybe we should put up a PR to revert this change and see if that fixes the bots? Side note: I'm almost done with a patch that would undo many of the more general clang importer changes and moves the namespace importing logic elsewhere, if this patch is the culprit, I suspect my change will fix it. So, if that is the case, let's revert the patch and I can submit something later that will probably not have the same issues. For future readers, here's the Jenkins output (so that you don't have to dig through the huge text file)******************** TEST 'Swift(macosx-x86_64) :: Interpreter/SDK/weak_objc_interop.swift' FAILED ******************** Script: -- : 'RUN: at line 1'; rm -rf "/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp" && mkdir -p "/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp" : 'RUN: at line 3'; cp /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/swift/test/Interpreter/SDK/weak_objc_interop.swift /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp/main.swift : 'RUN: at line 4'; xcrun --toolchain default --sdk '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk' clang++ -target x86_64-apple-macosx10.9 -fmodules-cache-path='/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache' -fno-objc-arc /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/swift/test/Interpreter/SDK/Inputs/ObjCWeak/ObjCWeak.m -c -o /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp/ObjCWeak.o : 'RUN: at line 5'; xcrun --toolchain default --sdk '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk' /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/bin/swiftc -target x86_64-apple-macosx10.9 -module-cache-path /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -F '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks' -toolchain-stdlib-rpath -Xlinker -rpath -Xlinker '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks' -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -headerpad_max_install_names -swift-version 4 -Xfrontend -define-availability -Xfrontend 'SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0' -F '/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/lib' -Xlinker -rpath -Xlinker '/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/lib' /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp/main.swift -I /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/swift/test/Interpreter/SDK/Inputs/ObjCWeak/ -Xlinker /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp/ObjCWeak.o -o /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp/weak_objc_interop -Xfrontend -disable-access-control : 'RUN: at line 6'; /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/swift/utils/swift-darwin-postprocess.py /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp/weak_objc_interop : 'RUN: at line 7'; /usr/bin/env DYLD_LIBRARY_PATH='/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/lib/swift/macosx' LD_LIBRARY_PATH='/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/lib/swift/macosx:' SIMCTL_CHILD_DYLD_LIBRARY_PATH='/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/lib/swift/macosx' /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64/test-macosx-x86_64/Interpreter/SDK/Output/weak_objc_interop.swift.tmp/weak_objc_interop 2>&1 | /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/swift/utils/PathSanitizingFileCheck --sanitize BUILD_DIR=/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/swift-macosx-x86_64 --sanitize SOURCE_DIR=/Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/swift --use-filecheck /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/buildbot_incremental_asan/llvm-macosx-x86_64/bin/FileCheck /Volumes/swift-ci/jenkins/workspace/oss-swift-incremental-ASAN-RA-macos/swift/test/Interpreter/SDK/weak_objc_interop.swift -- Exit Code: 1 |
I think 3372ab7 is a more likely reason of the ASAN failure, since it touches ObjC closures & |
Thank you for looking into this @egorzhdan ! I just put up another PR for testing 3372ab7 revert. |
Also started building with ASAN locally. Since if 3372ab7 is the reason, the failure is flaky, so we need to run the test multiple times. |
Unfortunately, an ASAN PR test without any change https://ci.swift.org/job/swift-PR-macos-ASAN-test/229/console just passed |
https://ci.swift.org/job/oss-swift-incremental-ASAN-RA-macos/ |
Alright, thanks for the update @rintaro! |
This is just a cleanup of `importFullName` invocations, discussed here: swiftlang#37695 (comment) This change makes `importFullName` return a pair of a canonical & alternative names instead of having one of them passed as a parameter.
Previously a namespace declaration was imported along with all of its redeclarations, and their members were added to a single Swift extension. This was problematic when a single namespace is declared in multiple modules – the extension belonged to only one of them.
For an example of this, try printing a module interface for
std.string
/std.iosfwd
– it will be empty, even though the declarations from those modules are actually imported into Swift correctly.This change makes sure that when we're importing different redeclarations of the same namespace, we're adding them as separate extensions to appropriate modules.