@@ -767,7 +767,7 @@ public struct Driver {
767767 emitModuleSeparately: emitModuleSeparately,
768768 outputFileMap: self . outputFileMap,
769769 moduleName: moduleOutputInfo. name)
770- self . swiftPrivateInterfacePath = try Self . computeSupplementaryOutputPath (
770+ let givenPrivateInterfacePath = try Self . computeSupplementaryOutputPath (
771771 & parsedOptions, type: . privateSwiftInterface, isOutputOptions: [ ] ,
772772 outputPath: . emitPrivateModuleInterfacePath,
773773 compilerOutputType: compilerOutputType,
@@ -776,6 +776,19 @@ public struct Driver {
776776 outputFileMap: self . outputFileMap,
777777 moduleName: moduleOutputInfo. name)
778778
779+ // Always emitting private swift interfaces if public interfaces are emitted.'
780+ // With the introduction of features like @_spi_available, we may print public
781+ // and private interfaces differently even from the same codebase. For this reason,
782+ // we should always print private interfaces so that we don’t mix the public interfaces
783+ // with private Clang modules.
784+ if let swiftInterfacePath = self . swiftInterfacePath,
785+ givenPrivateInterfacePath == nil {
786+ self . swiftPrivateInterfacePath = VirtualPath . lookup ( swiftInterfacePath)
787+ . replacingExtension ( with: . privateSwiftInterface) . intern ( )
788+ } else {
789+ self . swiftPrivateInterfacePath = givenPrivateInterfacePath
790+ }
791+
779792 var optimizationRecordFileType = FileType . yamlOptimizationRecord
780793 if let argument = parsedOptions. getLastArgument ( . saveOptimizationRecordEQ) ? . asSingle {
781794 switch argument {
0 commit comments