Skip to content

[clang] Bypass sandbox in ModuleDependencyCollector#175220

Merged
jansvoboda11 merged 1 commit intollvm:mainfrom
jansvoboda11:mdc-sandbox
Jan 12, 2026
Merged

[clang] Bypass sandbox in ModuleDependencyCollector#175220
jansvoboda11 merged 1 commit intollvm:mainfrom
jansvoboda11:mdc-sandbox

Conversation

@jansvoboda11
Copy link
Contributor

This PR disables the sandbox for file collection within ModuleDependencyCollector. This is typically only invoked when the -module-dependency-dir option is specified for generating a crash report, where the sandbox is not as crucial as for regular compilation.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:modules C++20 modules and Clang Header Modules labels Jan 9, 2026
@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2026

@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

Changes

This PR disables the sandbox for file collection within ModuleDependencyCollector. This is typically only invoked when the -module-dependency-dir option is specified for generating a crash report, where the sandbox is not as crucial as for regular compilation.


Full diff: https://github.com/llvm/llvm-project/pull/175220.diff

1 Files Affected:

  • (modified) clang/lib/Frontend/ModuleDependencyCollector.cpp (+11-5)
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index ff37065885289..38415377c8b9b 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -16,6 +16,7 @@
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/IOSandbox.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -161,11 +162,16 @@ std::error_code ModuleDependencyCollector::copyToRoot(StringRef Src,
   }
 
   // Copy the file into place.
-  if (std::error_code EC = fs::create_directories(path::parent_path(CacheDst),
-                                                  /*IgnoreExisting=*/true))
-    return EC;
-  if (std::error_code EC = fs::copy_file(Paths.CopyFrom, CacheDst))
-    return EC;
+  {
+    // FIXME(sandboxing): Implement this via vfs::{FileSystem,OutputBackend}.
+    auto BypassSandbox = sandbox::scopedDisable();
+
+    if (std::error_code EC = fs::create_directories(path::parent_path(CacheDst),
+                                                    /*IgnoreExisting=*/true))
+      return EC;
+    if (std::error_code EC = fs::copy_file(Paths.CopyFrom, CacheDst))
+      return EC;
+  }
 
   // Always map a canonical src path to its real path into the YAML, by doing
   // this we map different virtual src paths to the same entry in the VFS

@jansvoboda11 jansvoboda11 merged commit fd90b7c into llvm:main Jan 12, 2026
13 checks passed
@jansvoboda11 jansvoboda11 deleted the mdc-sandbox branch January 12, 2026 16:12
Priyanshu3820 pushed a commit to Priyanshu3820/llvm-project that referenced this pull request Jan 18, 2026
This PR disables the sandbox for file collection within
`ModuleDependencyCollector`. This is typically only invoked when the
`-module-dependency-dir` option is specified for generating a crash
report, where the sandbox is not as crucial as for regular compilation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants