CxxInterop: Swift function returning optional C++ type in shlib doesn't generate metadata

I'm hitting a similar issue to Undefined symbol metadata accessor for __C.CallMeClass in swift::TypeMetadataTrait<CallMeClass>::getTypeMetadata() in CallMeClass.o but in a slightly different way.

In my case instead of simply passing the C++ object back to C++, I'm trying to construct one and return it back to C++.

I'm testing this with a manually created swiftc 6.0 build as close to trunk as I could get it:

Swift version 6.0-dev (LLVM 3427f33b53c666b, Swift 225809e3f8e9c7b)
Target: x86_64-unknown-linux-gnu

Here's a repo with a minimal project that shows the issue: GitHub - ADKaster/swift-shlib-cxx-exe

In essence, it seems like when swift needs to pass along an instance of a type back to c++, the C++ compiler (or the swift compiler?) doesn't emit the swift type info into a library target properly(?)

This seems to stem from using CppType? in my swift file.

the SIL for Color.swift in my example repo doesn't emit the type metadata info for my C++ type, but the generated Shlib-Swift.h clang-header includes information for swift::Optional that assumes there is always type metadata generated for any type held within an optional? And since I'm trying to call the swift method that returns an optional, the missing metadata for my C++ type becomes an issue.

Is this simply a defect in the generated clang header that doesn't understand the proper ABI for Optional<CxxType>?