Local testing failure related to CxxShim

Hey everyone,
Recently I'm seeing compiler tests fail locally on some tests with asserting on missing CxxShim module.

Assertion failed: (wrapperModule && "CxxShim module is required when using members of a base class. " "Make sure you `import CxxShim`."), function getInteropStaticCastDeclRefExpr, file ClangImporter.cpp, line 4412.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.	Program arguments: /Users/lucianoalmeida/Documents/programming/swift-lang/build/Ninja-ReleaseAssert/swift-macosx-arm64/bin/swift-frontend -frontend -c -primary-file /Users/lucianoalmeida/Documents/programming/swift-lang/swift/test/Interop/Cxx/operators/member-inline.swift -target arm64-apple-macosx10.9 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -I /Users/lucianoalmeida/Documents/programming/swift-lang/swift/test/Interop/Cxx/operators/Inputs -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Users/lucianoalmeida/Documents/programming/swift-lang/build/Ninja-ReleaseAssert/swift-macosx-arm64/lib -module-cache-path /Users/lucianoalmeida/Documents/programming/swift-lang/build/Ninja-ReleaseAssert/swift-macosx-arm64/swift-test-results/arm64-apple-macosx10.9/clang-module-cache -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" -enable-experimental-cxx-interop -target-sdk-version 12.3 -module-name main -o /var/folders/gp/r_3grpx54s56brqr50kqlffr0000gn/T/member-inline-9cf121.o
1.	Swift version 5.8-dev (LLVM a1f545e08a3c181, Swift 739a6f8714b8864)
2.	Compiling with effective version 4.1.50
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/Users/lucianoalmeida/Documents/programming/swift-lang/swift/test/Interop/Cxx/operators/member-inline.swift")
4.	While silgen emitFunction SIL function "@$sSo32DerivedFromAddressOnlyIntWrapperV14callAsFunctions5Int32VyF".
 for 'callAsFunction()' (in module 'MemberInline')
5.	While evaluating request TypeCheckFunctionBodyRequest(MemberInline.(file).DerivedFromAddressOnlyIntWrapper.callAsFunction())
6.	While evaluating request ParseAbstractFunctionBodyRequest(MemberInline.(file).DerivedFromAddressOnlyIntWrapper.callAsFunction())
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000108a6129c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108a60340 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000108a61950 SignalHandler(int) + 344
3  libsystem_platform.dylib 0x00000001a50434a4 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001a502bee0 pthread_kill + 288
5  libsystem_c.dylib        0x00000001a4f66340 abort + 168
6  libsystem_c.dylib        0x00000001a4f65754 err + 0
7  swift-frontend           0x0000000108e19974 getInteropStaticCastDeclRefExpr(swift::ASTContext&, clang::Module const*, swift::Type, swift::Type) (.cold.4) + 0
8  swift-frontend           0x000000010513601c getInteropStaticCastDeclRefExpr(swift::ASTContext&, clang::Module const*, swift::Type, swift::Type) + 520
9  swift-frontend           0x0000000105136270 getInOutSelfInteropStaticCast(swift::FuncDecl*, swift::NominalTypeDecl*, swift::NominalTypeDecl*) + 564
10 swift-frontend           0x0000000105136f64 synthesizeBaseClassMethodBody(swift::AbstractFunctionDecl*, void*) + 452
11 swift-frontend           0x0000000105564920 swift::ParseAbstractFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 304
12 swift-frontend           0x000000010537eac8 llvm::Expected<swift::ParseAbstractFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::ParseAbstractFunctionBodyRequest>(swift::ParseAbstractFunctionBodyRequest const&) + 380
13 swift-frontend           0x000000010537e7fc llvm::Expected<swift::ParseAbstractFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::ParseAbstractFunctionBodyRequest, (void*)0>(swift::ParseAbstractFunctionBodyRequest const&) + 100
14 swift-frontend           0x00000001052e526c swift::ParseAbstractFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::ParseAbstractFunctionBodyRequest>(swift::Evaluator&, swift::ParseAbstractFunctionBodyRequest, swift::ParseAbstractFunctionBodyRequest::OutputType) + 40
15 swift-frontend           0x00000001052c9400 swift::AbstractFunctionDecl::getBody(bool) const + 196
16 swift-frontend           0x0000000104fa3940 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 184
17 swift-frontend           0x0000000105380674 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest>(swift::TypeCheckFunctionBodyRequest const&) + 376
18 swift-frontend           0x000000010538043c llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 104
19 swift-frontend           0x00000001052e53c8 swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType) + 36
20 swift-frontend           0x000000010486e888 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 140
21 swift-frontend           0x00000001047fe7bc swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 6792
22 swift-frontend           0x0000000104802cac swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 4168
23 swift-frontend           0x00000001048ab784 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 132
24 swift-frontend           0x00000001048061a4 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 380
25 swift-frontend           0x0000000104802f90 swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 80
26 swift-frontend           0x00000001042ca348 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 520
27 swift-frontend           0x00000001042d8c0c withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
28 swift-frontend           0x00000001042cc0cc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3364
29 swift-frontend           0x0000000104147260 swift::mainEntry(int, char const**) + 3756
30 dyld                     0x00000001115f908c start + 520
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

More curious about what may be happening and if I'm missing something on local setup for them to run properly.
Those are the ones failing

********************
********************
Failed Tests (6):
  Swift(macosx-arm64) :: Interop/Cxx/class/inheritance/fields.swift
  Swift(macosx-arm64) :: Interop/Cxx/class/inheritance/functions.swift
  Swift(macosx-arm64) :: Interop/Cxx/foreign-reference/pod.swift
  Swift(macosx-arm64) :: Interop/Cxx/operators/member-inline.swift
  ... more, but unrelated

cc @zoecarver @egor.zhdan

Looks like the implicit import CxxShim wasn't added by the compiler. @adlere have you seen this before?

1 Like

Hmmm. Did you run ninja swift-stdlib, ninja swift-frontend and ninja swift-ide-test?

For me this happened because I needed to build swift-stdlib again I believe

2 Likes

I'll try that, thanks @egor.zhdan, @adlere

1 Like

@LucianoPAlmeida did @adlere's suggestions resolve the issue? I'm experiencing the same 4 failed tests when trying to do an initial build by following the instructions on swift/GettingStarted.md at main · apple/swift · GitHub but when I try running the ninja commands that were suggested I get an error saying that there's "No such file or directory".

Yes, it does. But note that you have to run it in your ninja build folder e.g. build/Ninja-ReleaseAssert/swift-macosx-arm64

1 Like

Thanks! that seems to have worked.

1 Like