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