[PATCH] D87051: scan-build-py: fix multiprocessing error
Lawrence D'Anna via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 2 12:16:09 PDT 2020
lawrence_danna created this revision.
lawrence_danna added reviewers: ldionne, chandlerc, jasonmolenda, JDevlieghere.
Herald added subscribers: cfe-commits, dexonsmith, whisperity.
Herald added a project: clang.
lawrence_danna requested review of this revision.
Recent versions of python3's multiprocessing module will blow up with
a Runtime error from this code, saying:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase
This is becuae the wrappers in bin/ are not using the __name__
"__main__" idiom correctly.
---------------------------
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87051
Files:
clang/tools/scan-build-py/bin/analyze-build
clang/tools/scan-build-py/bin/intercept-build
clang/tools/scan-build-py/bin/scan-build
Index: clang/tools/scan-build-py/bin/scan-build
===================================================================
--- clang/tools/scan-build-py/bin/scan-build
+++ clang/tools/scan-build-py/bin/scan-build
@@ -5,12 +5,13 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
import multiprocessing
-multiprocessing.freeze_support()
-
import sys
import os.path
this_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.dirname(this_dir))
from libscanbuild.analyze import scan_build
-sys.exit(scan_build())
+
+if __name__ == '__main__':
+ multiprocessing.freeze_support()
+ sys.exit(scan_build())
Index: clang/tools/scan-build-py/bin/intercept-build
===================================================================
--- clang/tools/scan-build-py/bin/intercept-build
+++ clang/tools/scan-build-py/bin/intercept-build
@@ -5,12 +5,13 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
import multiprocessing
-multiprocessing.freeze_support()
-
import sys
import os.path
this_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.dirname(this_dir))
from libscanbuild.intercept import intercept_build
-sys.exit(intercept_build())
+
+if __name__ == '__main__':
+ multiprocessing.freeze_support()
+ sys.exit(intercept_build())
Index: clang/tools/scan-build-py/bin/analyze-build
===================================================================
--- clang/tools/scan-build-py/bin/analyze-build
+++ clang/tools/scan-build-py/bin/analyze-build
@@ -5,12 +5,13 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
import multiprocessing
-multiprocessing.freeze_support()
-
import sys
import os.path
this_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.dirname(this_dir))
from libscanbuild.analyze import analyze_build
-sys.exit(analyze_build())
+
+if __name__ == '__main__':
+ multiprocessing.freeze_support()
+ sys.exit(analyze_build())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87051.289536.patch
Type: text/x-patch
Size: 1970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200902/3aed1fdc/attachment.bin>
More information about the cfe-commits
mailing list