[clang] 0c64282 - scan-build-py: fix multiprocessing error
Lawrence D'Anna via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 5 11:10:44 PDT 2020
Author: Lawrence D'Anna
Date: 2020-09-05T11:10:14-07:00
New Revision: 0c642828612dbde30decff6fb080af4de9a173bd
URL: https://github.com/llvm/llvm-project/commit/0c642828612dbde30decff6fb080af4de9a173bd
DIFF: https://github.com/llvm/llvm-project/commit/0c642828612dbde30decff6fb080af4de9a173bd.diff
LOG: scan-build-py: fix multiprocessing error
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.
Reviewed By: ldionne
Differential Revision: https://reviews.llvm.org/D87051
Added:
Modified:
clang/tools/scan-build-py/bin/analyze-build
clang/tools/scan-build-py/bin/intercept-build
clang/tools/scan-build-py/bin/scan-build
Removed:
################################################################################
diff --git a/clang/tools/scan-build-py/bin/analyze-build b/clang/tools/scan-build-py/bin/analyze-build
index 6c285874a208..0884ef2234bf 100755
--- a/clang/tools/scan-build-py/bin/analyze-build
+++ b/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())
diff --git a/clang/tools/scan-build-py/bin/intercept-build b/clang/tools/scan-build-py/bin/intercept-build
index 23f5104782ca..d9757b77b5c7 100755
--- a/clang/tools/scan-build-py/bin/intercept-build
+++ b/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())
diff --git a/clang/tools/scan-build-py/bin/scan-build b/clang/tools/scan-build-py/bin/scan-build
index 156da064a2b4..be4e51887e30 100755
--- a/clang/tools/scan-build-py/bin/scan-build
+++ b/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())
More information about the cfe-commits
mailing list