Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion clang/lib/Frontend/CompileJobCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/MCCAS/MCCASObjectV1.h"
#include "llvm/RemoteCachingService/Client.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/IOSandbox.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrefixMapper.h"
#include "llvm/Support/Process.h"
Expand Down Expand Up @@ -594,7 +595,11 @@ Expected<bool> CompileJobCache::maybeIngestNonVirtualOutputFromFileSystem(
StringRef OutputPath = FrontendOpts.OutputFile;
if (OutputPath.empty())
return false;
if (llvm::sys::fs::is_directory(OutputPath)) {
bool IsDirectory = [&] {
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
return llvm::sys::fs::is_directory(OutputPath);
}();
if (IsDirectory) {
// FIXME: A directory is produced for the 'html' output of the analyzer,
// support it for caching purposes.
Clang.getDiagnostics().Report(diag::warn_clang_cache_disabled_caching)
Expand Down Expand Up @@ -708,6 +713,8 @@ Expected<llvm::cas::ObjectRef> ObjectStoreCachingOutputs::writeOutputs(
}

Error ObjectStoreCachingOutputs::addNonVirtualOutputFile(StringRef FilePath) {
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();

auto F = llvm::sys::fs::openNativeFileForRead(FilePath);
if (!F)
return F.takeError();
Expand Down
13 changes: 10 additions & 3 deletions clang/tools/driver/cc1depscan_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,12 @@ int cc1depscand_main(ArrayRef<const char *> Argv, const char *Argv0,
}

// Create the base directory if necessary.
StringRef BaseDir = llvm::sys::path::parent_path(Server.BasePath);
if (std::error_code EC = llvm::sys::fs::create_directories(BaseDir))
reportError(Twine("cannot create basedir: ") + EC.message());
{
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
StringRef BaseDir = llvm::sys::path::parent_path(Server.BasePath);
if (std::error_code EC = llvm::sys::fs::create_directories(BaseDir))
reportError(Twine("cannot create basedir: ") + EC.message());
}

if (Command == "-serve") {
Server.start(/*Exclusive*/ true, CASArgs);
Expand Down Expand Up @@ -782,6 +785,8 @@ int cc1depscand_main(ArrayRef<const char *> Argv, const char *Argv0,
(Server.BasePath + ".err").toVector(LogErrPath);

auto openAndReplaceFD = [&](int ReplacedFD, StringRef Path) {
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();

int FD;
if (std::error_code EC = llvm::sys::fs::openFile(
Path, FD, llvm::sys::fs::CD_CreateAlways, llvm::sys::fs::FA_Write,
Expand Down Expand Up @@ -835,6 +840,8 @@ void ScanServer::start(bool Exclusive, ArrayRef<const char *> CASArgs) {
CompilerInvocation::ParseCASArgs(CASOpts, ParsedCASArgs, Diags);
CASOpts.ensurePersistentCAS();

auto BypassSandbox = llvm::sys::sandbox::scopedDisable();

static std::once_flag ValidateOnce;
std::call_once(ValidateOnce, [&] {
if (getenv("LLVM_CAS_DISABLE_VALIDATION"))
Expand Down