Pivot towards relative paths for installs and runtimes (#6547)

When building in Bazel actions, notably building runtimes, using
absolute paths makes the results non-hermetic and generally less
cache-friendly.

This restructures the code to only form an absolute path as part of the
`bazel run` change of working directory. It also tries to make the API
for doing this a bit more clear by taking the `exe_path` and
transforming it internally.

To support this, this PR also generalizes the `RemovingDir` to support
relative paths. While these can be tricky -- the working directory needs
to not change while they exist -- that isn't a reason to fully exclude
them and they're useful for implementing relative-path runtimes, etc.
This commit is contained in:
Chandler Carruth
2026-01-01 22:20:40 +00:00
committed by GitHub
parent 137695c1ca
commit e545929386
15 changed files with 80 additions and 95 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ auto main(int argc, char** argv) -> int {
// Do LLVM's initialization first, this will also transform UTF-16 to UTF-8.
Carbon::InitLLVM init_llvm(argc, argv);
Carbon::SetWorkingDirForBazel();
Carbon::SetWorkingDirForBazelRun();
llvm::SmallVector<llvm::StringRef> args(argv + 1, argv + argc);
bool success = Carbon::Testing::Run(args);