mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag This includes a bit in the module format to represent if the module was compiled with -enable-ossa-modules flag. When compiling a client module with -enable-ossa-modules flag, all dependent modules are checked for this bit, if not on, recompilation is triggered with -enable-ossa-modules. * Updated tests
This commit is contained in:
@@ -45,10 +45,11 @@ void anchorForGetMainExecutable() {}
|
||||
using namespace llvm::MachO;
|
||||
|
||||
static bool
|
||||
validateModule(llvm::StringRef data, bool Verbose,
|
||||
validateModule(llvm::StringRef data, bool Verbose, bool requiresOSSAModules,
|
||||
swift::serialization::ValidationInfo &info,
|
||||
swift::serialization::ExtendedValidationInfo &extendedInfo) {
|
||||
info = swift::serialization::validateSerializedAST(data, &extendedInfo);
|
||||
info = swift::serialization::validateSerializedAST(data, requiresOSSAModules,
|
||||
&extendedInfo);
|
||||
if (info.status != swift::serialization::Status::Valid) {
|
||||
llvm::outs() << "error: validateSerializedAST() failed\n";
|
||||
return false;
|
||||
@@ -240,6 +241,9 @@ int main(int argc, char **argv) {
|
||||
opt<bool> QualifyTypes("qualify-types", desc("Qualify dumped types"),
|
||||
cat(Visible));
|
||||
|
||||
opt<bool> EnableOSSAModules("enable-ossa-modules", init(false),
|
||||
desc("Serialize modules in OSSA"), cat(Visible));
|
||||
|
||||
ParseCommandLineOptions(argc, argv);
|
||||
|
||||
// Unregister our options so they don't interfere with the command line
|
||||
@@ -282,8 +286,8 @@ int main(int argc, char **argv) {
|
||||
for (auto &Module : Modules) {
|
||||
info = {};
|
||||
extendedInfo = {};
|
||||
if (!validateModule(StringRef(Module.first, Module.second), Verbose, info,
|
||||
extendedInfo)) {
|
||||
if (!validateModule(StringRef(Module.first, Module.second), Verbose,
|
||||
EnableOSSAModules, info, extendedInfo)) {
|
||||
llvm::errs() << "Malformed module!\n";
|
||||
return 1;
|
||||
}
|
||||
@@ -306,6 +310,7 @@ int main(int argc, char **argv) {
|
||||
Invocation.setModuleName("lldbtest");
|
||||
Invocation.getClangImporterOptions().ModuleCachePath = ModuleCachePath;
|
||||
Invocation.getLangOptions().EnableMemoryBufferImporter = true;
|
||||
Invocation.getSILOptions().EnableOSSAModules = EnableOSSAModules;
|
||||
|
||||
if (!ResourceDir.empty()) {
|
||||
Invocation.setRuntimeResourcePath(ResourceDir);
|
||||
|
||||
Reference in New Issue
Block a user