10
10
import shlex
11
11
import sys
12
12
import sysconfig
13
+ import time
13
14
import warnings
14
15
from glob import glob , escape
15
16
import _osx_support
@@ -688,9 +689,15 @@ def check_extension_import(self, ext):
688
689
def add_multiarch_paths (self ):
689
690
# Debian/Ubuntu multiarch support.
690
691
# https://wiki.ubuntu.com/MultiarchSpec
691
- tmpfile = os .path .join (self .build_temp , 'multiarch' )
692
- if not os .path .exists (self .build_temp ):
693
- os .makedirs (self .build_temp )
692
+
693
+ # Poor man's conflict avoidance. PGO build use $(MAKE), which runs
694
+ # make in a separate, untracked process. Sometimes main and subproces
695
+ # run `make sharedmods` at the same time. One process removes
696
+ # "multiarch" file of the other process.
697
+ tmpfile = os .path .join (
698
+ self .build_temp , f"multiarch-{ os .getpid ()} -{ int (time .time () )} .tmp"
699
+ )
700
+ os .makedirs (self .build_temp , exist_ok = True )
694
701
ret = run_command (
695
702
'%s -print-multiarch > %s 2> /dev/null' % (CC , tmpfile ))
696
703
multiarch_path_component = ''
@@ -713,9 +720,7 @@ def add_multiarch_paths(self):
713
720
opt = ''
714
721
if CROSS_COMPILING :
715
722
opt = '-t' + sysconfig .get_config_var ('HOST_GNU_TYPE' )
716
- tmpfile = os .path .join (self .build_temp , 'multiarch' )
717
- if not os .path .exists (self .build_temp ):
718
- os .makedirs (self .build_temp )
723
+ os .makedirs (self .build_temp , exist_ok = True )
719
724
ret = run_command (
720
725
'dpkg-architecture %s -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
721
726
(opt , tmpfile ))
0 commit comments