Skip to content

Commit 96a4cf5

Browse files
authored
Merge pull request #5992 from akyrtzi/pr/stable/llbuild-fd-not-existent
[stable/20220421][clang/cas/remote] Don't fatal error if `LLBUILD_TASK_ID` is set but `LLBUILD_CONTROL_FD` is not
2 parents e630334 + 23a6271 commit 96a4cf5

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

clang/test/CAS/remote-cache-service.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
// Baseline to check we got expected outputs.
88
// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -MMD -MT dependencies -MF %t/t.d --serialize-diagnostics %t/t.dia
9-
// RUN: llvm-remote-cache-test -socket-path=%{remote-cache-dir}/%basename_t -cache-path=%t/cache -- env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache \
9+
// Adding `LLBUILD_TASK_ID` just to make sure there's no failure if that is set but `LLBUILD_CONTROL_FD` is not.
10+
// RUN: llvm-remote-cache-test -socket-path=%{remote-cache-dir}/%basename_t -cache-path=%t/cache -- env LLBUILD_TASK_ID=1 LLVM_CACHE_CAS_PATH=%t/cas %clang-cache \
1011
// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t1.o -MMD -MT dependencies -MF %t/t1.d --serialize-diagnostics %t/t1.dia -Rcompile-job-cache \
1112
// RUN: 2>&1 | FileCheck %s --check-prefix=CACHE-MISS
1213
// RUN: llvm-remote-cache-test -socket-path=%{remote-cache-dir}/%basename_t -cache-path=%t/cache -- env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache \

clang/tools/driver/cc1_main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,18 +1134,18 @@ void RemoteCachingOutputs::tryReleaseLLBuildExecutionLane() {
11341134
if (TriedReleaseLLBuildExecutionLane)
11351135
return;
11361136
TriedReleaseLLBuildExecutionLane = true;
1137-
if (const char *LLTaskID = getenv("LLBUILD_TASK_ID")) {
1137+
if (auto LLTaskID = llvm::sys::Process::GetEnv("LLBUILD_TASK_ID")) {
11381138
// Use the llbuild protocol to request to release the execution lane for
11391139
// this task.
1140-
const char *LLControlFD = getenv("LLBUILD_CONTROL_FD");
1140+
auto LLControlFD = llvm::sys::Process::GetEnv("LLBUILD_CONTROL_FD");
11411141
if (!LLControlFD)
1142-
llvm::report_fatal_error("'LLBUILD_CONTROL_FD' env var is not set!");
1142+
return; // LLBUILD_CONTROL_FD may not be set if a shell script is invoked.
11431143
int LLCtrlFD;
1144-
bool HasErr = StringRef(LLControlFD).getAsInteger(10, LLCtrlFD);
1144+
bool HasErr = StringRef(*LLControlFD).getAsInteger(10, LLCtrlFD);
11451145
if (HasErr)
11461146
llvm::report_fatal_error(Twine("failed converting 'LLBUILD_CONTROL_FD' "
11471147
"to an integer, it was: ") +
1148-
LLControlFD);
1148+
*LLControlFD);
11491149
llvm::raw_fd_ostream FDOS(LLCtrlFD, /*shouldClose*/ false);
11501150
FDOS << "llbuild.1\n" << LLTaskID << '\n';
11511151
FDOS.flush();

0 commit comments

Comments
 (0)