Files
swift-mirror/test/ModuleInterface/ossa-modules/sdk-test-stdlib-no-ossa.swift
Michael Gottesman 504b5f2058 [ossa][frontend] Separately namespace enable-ossa-modules in the prebuilt module cache so that the flag causes recompilation of imported resilient modules when the flag is enabled.
This will enable users to try out the '-enable-ossa-modules' flag if their
compiler supports it and get OSSA code on all inlinable code that they use. The
idea is that this is a nice way to stage this in and get more testing.

The specific implementation is that the module interface loader:

1. Knows if enable ossa modules is enabled not to search for any compiled
modules. We always rebuild from the interface file on the system.

2. Knows that if enable ossa modules is enabled to mixin a bit into the module
interface loader cache hash to ensure that we consider the specialized ossa
compiled modules to be different than the modules in that cache from the system.

This ensures that when said flag is enabled, the user transparently gets all
their code in OSSA form from transparent libraries.
2021-03-18 13:03:51 -07:00

45 lines
2.1 KiB
Swift

// This test looks at the behavior of how ossa modules deal with the prebuilt
// module cache. We compile a fake swift stdlib with a module path and a swift
// interface file.
//
// Then we test the behavior of the importing mechanism and make sure that no
// matter whether or not we compile the library with OSSA that
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/TempModuleCacheLibrary)
// RUN: %empty-directory(%t/TempModuleCacheBuilder)
// RUN: %empty-directory(%t/TempModuleCacheOther)
// RUN: %empty-directory(%t/SDK/usr/lib/swift/Swift.swiftmodule)
// RUN: %empty-directory(%t/PreBuiltSDKModules)
// RUN: %target-swift-frontend -c -emit-module-interface-path %t/SDK/usr/lib/swift/Swift.swiftmodule/%target-swiftinterface-name -emit-module-path %t/SDK/usr/lib/swift/Swift.swiftmodule/%target-swiftmodule-name -o %t/Swift.o -parse-stdlib -module-name Swift -enable-library-evolution -module-cache-path %t/TempModuleCacheLibrary -swift-version 5 %s -disable-objc-interop
// RUN: %swift_build_sdk_interfaces_base -o %t/PreBuiltSDKModules -j 1 -sdk %t/SDK -module-cache-path %t/TempModuleCacheBuilder %t/SDK -v
// In this case, we should not rebuild.
// RUN: %target-swift-frontend -typecheck -sdk '%t/SDK' -prebuilt-module-cache-path '%t/PreBuiltSDKModules' -module-cache-path %t/TempModuleCacheOther -resource-dir '' -parse-stdlib -Rmodule-interface-rebuild %S/Inputs/sdk-test-stdlib-no-ossa-referent-no-rebuild-remark.swift -verify
// In this case, we should rebuild since enable-ossa-modules always rebuilds.
// RUN: %target-swift-frontend -typecheck -sdk '%t/SDK' -prebuilt-module-cache-path '%t/PreBuiltSDKModules' -module-cache-path %t/TempModuleCacheOther -resource-dir '' -parse-stdlib -Rmodule-interface-rebuild %S/Inputs/sdk-test-stdlib-no-ossa-referent-with-rebuild-remark.swift -verify -enable-ossa-modules
// Make sure the rebuild is in OSSA.
// RUN: %target-sil-opt -module-name Swift %t/PreBuiltSDKModules/Swift.swiftmodule/*.swiftmodule | grep '@$ss3foos5KlassCyF' | grep '[[]ossa[]]'
@_fixed_layout
public final class Klass {
public init() {
}
}
@inlinable
public func foo() -> Klass {
return Klass()
}