Is auto compilation of the standard library broken on Linux?

Hi!

When running a given version of the swift frontend (say 5.7.1) on top of another version of the standard library (say 5.7) by using -resource-dir I have seen a different behaviour between Linux and macOS. The first time this is done on macOS the compiler will use the .swiftinterface files and compile the standard library, outputting the following remark:

<unknown>:0: remark: did not find a prebuilt standard library for target 'x86_64-apple-macos' compatible with this Swift compiler; building it may take a few minutes, but it should only happen once for this combination of compiler and target

However running something like

/opt/swift-5.7.1-RELEASE-ubuntu22.04/usr/bin/swift-frontend -c /dev/null -resource-dir /opt/swift-5.7-RELEASE-ubuntu22.04/usr/lib/swift

will instead result in

<unknown>:0: error: module compiled with Swift 5.7 cannot be imported by the Swift 5.7.1 compiler: /opt/swift-5.7-RELEASE-ubuntu22.04/usr/lib/swift/linux/Swift.swiftmodule/x86_64-unknown-linux-gnu.swiftmodule

even though the corresponding .swiftinterface is there (and the frontend would be able to compile it as can be tested with swift-frontend -compile-module-from-interface /opt/swift-5.7-RELEASE-ubuntu22.04/usr/lib/swift/linux/Swift.swiftmodule/x86_64-unknown-linux-gnu.swiftinterface -module-name Swift -parse-stdlib).

Is there any reason why automatic lazy compilation of the standard library does not happen on Linux?

We are building codeql support for Swift, and we built the solution on top of the swift frontend, and we rely on this auto-compilation to be able to ship one version of codeql able to analyse builds with older versions of swift, without having to ship any additional resources. Is there some magic command line flag I should provide to make it work? Did I hit a bug on the Linux version of the frontend?

So, one small progress I made, is that running the same command under SWIFT_FORCE_MODULE_LOADING=prefer-interface will indeed compile the interfaces, at the cost of doing it the first time even if the serialized modules are compatible. It seems like the default module loading mode (prefer-serialized) actually behaves like only-serialized on Linux for some reason. I'm more and more convinced this is a bug, so I opened one.