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
This commit is contained in:
Lawrence D'Anna 2020-09-05 11:09:21 -07:00
parent bef38e86b4
commit 0c64282861
3 changed files with 12 additions and 9 deletions

View File

@ -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())

View File

@ -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())

View File

@ -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())