Skip to content

Correct VFS libc modulemap injection condition. #60265

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
Aug 18, 2022

Conversation

3405691582
Copy link
Member

We should only be skipping VFS libc modulemap injection on Darwin and
Windows. Unfortunately, we cannot use the isOSGlibc Triple method because
LLVM's sense of Glibc (does the platform actually use glibc) differs
from Swift's sense of Glibc (does the platform use libc).

There may be other non-libc platforms that we should skip VFS injection
on but let's correct the conditional for now and other prs should add
those platforms as necessary.

@3405691582
Copy link
Member Author

cc @egorzhdan

@egorzhdan
Copy link
Contributor

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor

@swift-ci please smoke test macOS

@finagolfin
Copy link
Member

Heh, looks like this pull broke two PS4 tests: 🤣

FAIL: Swift(linux-x86_64) :: Parse/ConditionalCompilation/x86_64PS4Target.swift (3966 of 15833)
******************** TEST 'Swift(linux-x86_64) :: Parse/ConditionalCompilation/x86_64PS4Target.swift' FAILED ********************
Script:
--
: 'RUN: at line 1';   '/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend' -module-cache-path /home/build-user/build/buildbot_linux/swift-linux-x86_64/swift-test-results/x86_64-unknown-linux-gnu/clang-module-cache -disable-objc-attr-requires-foundation-module -swift-version 4  -define-availability 'SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999' -define-availability 'SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2' -define-availability 'SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0' -define-availability 'SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4' -define-availability 'SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0' -define-availability 'SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5' -define-availability 'SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0' -define-availability 'SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4' -define-availability 'SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0' -define-availability 'SwiftStdlib 5.8:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999' -typecheck /home/build-user/swift/test/Parse/ConditionalCompilation/x86_64PS4Target.swift -verify -target x86_64-scei-ps4 -disable-objc-interop -parse-stdlib
: 'RUN: at line 2';   '/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-ide-test' -module-cache-path /home/build-user/build/buildbot_linux/swift-linux-x86_64/swift-test-results/x86_64-unknown-linux-gnu/clang-module-cache -completion-cache-path '/home/build-user/build/buildbot_linux/swift-linux-x86_64/swift-test-results/x86_64-unknown-linux-gnu/completion-cache' -swift-version 4  -test-input-complete -source-filename /home/build-user/swift/test/Parse/ConditionalCompilation/x86_64PS4Target.swift -target x86_64-scei-ps4
--
Exit Code: 134

Command Output (stderr):
--
swift-frontend: /home/build-user/llvm-project/clang/include/clang/Basic/Diagnostic.h:1526: clang::DiagnosticBuilder clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int): Assertion `CurDiagID == std::numeric_limits<unsigned>::max() && "Multiple diagnostics in flight at once!"' failed.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.	Program arguments: /home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend -module-cache-path /home/build-user/build/buildbot_linux/swift-linux-x86_64/swift-test-results/x86_64-unknown-linux-gnu/clang-module-cache -disable-objc-attr-requires-foundation-module -swift-version 4 -define-availability "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -define-availability "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" -define-availability "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" -define-availability "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4" -define-availability "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0" -define-availability "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5" -define-availability "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -define-availability "SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" -define-availability "SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0" -define-availability "SwiftStdlib 5.8:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -typecheck /home/build-user/swift/test/Parse/ConditionalCompilation/x86_64PS4Target.swift -verify -target x86_64-scei-ps4 -disable-objc-interop -parse-stdlib
1.	Swift version 5.8-dev (LLVM 219773fdf81b59d, Swift fbffc78c475b057)
2.	Compiling with effective version 4.1.50
 #0 0x00000000061e7763 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x61e7763)
 #1 0x00000000061e54ae llvm::sys::RunSignalHandlers() (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x61e54ae)
 #2 0x00000000061e7aef SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f663d5853c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
 #4 0x00007f663c9f803b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4303b)
 #5 0x00007f663c9d7859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f663c9d7729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f663c9e9006 (/lib/x86_64-linux-gnu/libc.so.6+0x34006)
 #8 0x00000000043200b6 clang::driver::toolchains::PS4CPU::PS4CPU(clang::driver::Driver const&, llvm::Triple const&, llvm::opt::ArgList const&) crtstuff.c:0:0
 #9 0x00000000041c9dc3 clang::driver::Driver::getToolChain(llvm::opt::ArgList const&, llvm::Triple const&) const (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x41c9dc3)
#10 0x0000000001a2e23d swift::getClangInvocationFileMapping[abi:cxx11](swift::ASTContext&) (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x1a2e23d)
#11 0x00000000019e0d5d swift::ClangImporter::create(swift::ASTContext&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, swift::DependencyTracker*, swift::DWARFImporterDelegate*) (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x19e0d5d)
#12 0x00000000006ca8b0 swift::CompilerInstance::setUpModuleLoaders() (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x6ca8b0)
#13 0x00000000006ca54b swift::CompilerInstance::setUpASTContextIfNeeded() (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x6ca54b)
#14 0x00000000006cba7b swift::CompilerInstance::setup(swift::CompilerInvocation const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x6cba7b)
#15 0x000000000067dbfa swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x67dbfa)
#16 0x00000000004bc6fc swift::mainEntry(int, char const**) (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x4bc6fc)
#17 0x00007f663c9d90b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#18 0x00000000004bbd4e _start (/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend+0x4bbd4e)
/home/build-user/build/buildbot_linux/swift-linux-x86_64/test-linux-x86_64/Parse/ConditionalCompilation/Output/x86_64PS4Target.swift.script: line 2: 20099 Aborted                 (core dumped) '/home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swift-frontend' -module-cache-path /home/build-user/build/buildbot_linux/swift-linux-x86_64/swift-test-results/x86_64-unknown-linux-gnu/clang-module-cache -disable-objc-attr-requires-foundation-module -swift-version 4 -define-availability 'SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999' -define-availability 'SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2' -define-availability 'SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0' -define-availability 'SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4' -define-availability 'SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0' -define-availability 'SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5' -define-availability 'SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0' -define-availability 'SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4' -define-availability 'SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0' -define-availability 'SwiftStdlib 5.8:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999' -typecheck /home/build-user/swift/test/Parse/ConditionalCompilation/x86_64PS4Target.swift -verify -target x86_64-scei-ps4 -disable-objc-interop -parse-stdlib

--

@3405691582 3405691582 force-pushed the CorrectVFSExclusion branch 3 times, most recently from 488e7a6 to e55300c Compare July 28, 2022 20:55
@finagolfin
Copy link
Member

Alright, this should pass the CI now.

@3405691582
Copy link
Member Author

Yep, that was a rather astonishing test failure.

@finagolfin
Copy link
Member

Apparently Saleem added some PS4 support in #3221 a little more than six years ago: I had no idea that pull existed.

@3405691582
Copy link
Member Author

Ping.

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Sorry for the delay!

I think the condition should remain in the form of "what OSes we want to apply this to" and not "what OSes do we skip the injection", otherwise someone porting Swift to a new platform in the future will encounter a very surprising behavior.

Can you do something like triple.isGlibc() || triple.isOpenBSD() || triple.isFreeBSD()?

@3405691582 3405691582 force-pushed the CorrectVFSExclusion branch from e55300c to 9457f40 Compare August 15, 2022 18:36
@3405691582
Copy link
Member Author

I have factored this a little more for clarity with some of your suggestion. If this LGTY as-is, then good, but I'm still thinking about the problem where a porter for a new platform comes across missing modulemap errors during compilation, but aren't immediately directed to this point in the code and to the decision they need to make. However, the way to solve this is to force an #error in the right spot, but that requires doing this in the preprocessor, which is less expressive than the "isGlibc" method and friends. What do you think?

@3405691582 3405691582 requested a review from egorzhdan August 15, 2022 18:36
@egorzhdan
Copy link
Contributor

@swift-ci please smoke test

@@ -171,11 +171,15 @@ createClangArgs(const ASTContext &ctx, clang::driver::Driver &clangDriver) {
return clangDriverArgs;
}

static bool shouldInjectGlibcModulemap(const llvm::Triple &triple)
{
return triple.isOSGlibc() || triple.isOSOpenBSD() || triple.isOSFreeBSD();
Copy link
Member

Choose a reason for hiding this comment

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

This will break the native Android build, please add Android here and maybe a comment explaining why we're adding these non-glibc platforms.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done; can you pick and retest?

@3405691582 3405691582 force-pushed the CorrectVFSExclusion branch from 9457f40 to 7bb61cc Compare August 17, 2022 20:21
@3405691582 3405691582 requested review from finagolfin and removed request for egorzhdan August 17, 2022 20:22
We should only be skipping VFS libc modulemap injection on Darwin and
Windows. Unfortunately, we cannot just use the isOSGlibc Triple method
because LLVM's sense of Glibc (does the platform _actually use_ glibc)
differs from Swift's sense of Glibc (does the platform use libc).

There may be other non-libc platforms that we should skip VFS injection
on but let's correct the conditional for now and other prs should add
those platforms as necessary.
@3405691582 3405691582 force-pushed the CorrectVFSExclusion branch from 7bb61cc to 6a55161 Compare August 17, 2022 20:25
Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Thanks!

@egorzhdan
Copy link
Contributor

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit ad938a9 into swiftlang:main Aug 18, 2022
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.

3 participants