Closed rastogishubham closed 2 weeks ago
@swift-ci please test
@swift-ci please test llvm
@cachemeifyoucan I added a test for the -fcasid-output
option.
The code is now
if (JustComputedResult && !WriteOutputAsCASID)
In file-based caching, if -fcasid-output
is not used and if there is a cache miss, JustComputedResult
will be true and WriteOutputAsCASID
will be false, so the code will just exit this function and not replay anything.
In file-based caching, if -fcasid-output
is not used and if there is a cache hit, JustComputedResult
will be false and WriteOutputAsCASID
will be false, so the code will replay the object file.
In MCCAS, if -fcasid-output
is not used and if there is a cache miss, JustComputedResult
will be true and WriteOutputAsCASID
will be false, so the code will just exit this function and not replay anything.
In MCCAS, if -fcasid-output
is not used and if there is a cache hit, JustComputedResult
will be false and WriteOutputAsCASID
will be false, so the code will replay the object file.
if -fcasid-output
is used, then WriteOutputAsCASID
is true, so we always go into the replay code whether we used MCCAS or file based caching, whether there is a cache hit or miss. However, the raw_ostream is filtered out.
CompileJobCache.cpp:449
IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OnDiskOutputs =
llvm::makeIntrusiveRefCnt<llvm::vfs::OnDiskOutputBackend>();
if (WriteOutputAsCASID) {
OnDiskOutputs = llvm::vfs::makeFilteringOutputBackend(
OnDiskOutputs,
[this](StringRef ResolvedPath, std::optional<llvm::vfs::OutputConfig>) {
return ResolvedPath != this->OutputFile;
});
}
So we always write the casid to the object file stream when -fcasid-output
is used.
Now this patch also ensures that whether swift caching or clang caching is used with MCCAS. The MachOCASWriter
always writes to the raw_ostream it gets, which also solves the bug with 0 byte object files in swift MCCAS.
@swift-ci please test
@swift-ci please test
@swift-ci please test macOS
When clang caching and MCCAS are enabled, on a cache miss, the object file is not written to in MachOCASWriter, instead the replay code is rerun and the object file is serialized and written out. However, in swift, the replay code isn't run on a cache miss at all, and it expects the object writer to write to the object file.
This patch makes it so that on a cache miss, the MachOCASWriter always writes to the raw_ostream buffer for the object file and doesn't serialize the object file in the replay code.
rdar://134425492 ([MCCAS] Fix bug with swift caching where object files are 0 bytes in size)