summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch')
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch52
1 files changed, 0 insertions, 52 deletions
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch
deleted file mode 100644
index 497db4f5..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch
+++ /dev/null
@@ -1,52 +0,0 @@
1From 60854c328d8729b2ef10b9bb4dcbcc282f43c5e7 Mon Sep 17 00:00:00 2001
2From: Raphael Isemann <teemperor@gmail.com>
3Date: Thu, 1 Apr 2021 18:41:44 +0200
4Subject: [PATCH] Avoid calling ParseCommandLineOptions in BackendUtil if
5 possible
6
7Calling `ParseCommandLineOptions` should only be called from `main` as the
8CommandLine setup code isn't thread-safe. As BackendUtil is part of the
9generic Clang FrontendAction logic, a process which has several threads executing
10Clang FrontendActions will randomly crash in the unsafe setup code.
11
12This patch avoids calling the function unless either the debug-pass option or
13limit-float-precision option is set. Without these two options set the
14`ParseCommandLineOptions` call doesn't do anything beside parsing
15the command line `clang` which doesn't set any options.
16
17See also D99652 where LLDB received a workaround for this crash.
18
19Reviewed By: JDevlieghere
20
21Differential Revision: https://reviews.llvm.org/D99740
22
23Upstream-Status: Backport [https://github.com/llvm/llvm-project/commit/60854c328d8729b2ef10b9bb4dcbcc282f43c5e7]
24Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
25
26---
27 clang/lib/CodeGen/BackendUtil.cpp | 8 ++++++++
28 1 file changed, 8 insertions(+)
29
30diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
31index 41eafd13d97c..00d92e7beadd 100644
32--- a/clang/lib/CodeGen/BackendUtil.cpp
33+++ b/clang/lib/CodeGen/BackendUtil.cpp
34@@ -871,7 +871,15 @@ static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) {
35 BackendArgs.push_back("-limit-float-precision");
36 BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
37 }
38+ // Check for the default "clang" invocation that won't set any cl::opt values.
39+ // Skip trying to parse the command line invocation to avoid the issues
40+ // described below.
41+ if (BackendArgs.size() == 1)
42+ return;
43 BackendArgs.push_back(nullptr);
44+ // FIXME: The command line parser below is not thread-safe and shares a global
45+ // state, so this call might crash or overwrite the options of another Clang
46+ // instance in the same process.
47 llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
48 BackendArgs.data());
49 }
50--
512.29.2
52