|
@@ -44,6 +44,10 @@ def main():
|
|
|
if sys.argv[1] == '--mtime':
|
|
|
mtime0 = sys.argv[2]
|
|
|
cmd = 3
|
|
|
+ if sys.argv[cmd] == '--custom-pid':
|
|
|
+ custom_pid = sys.argv[4]
|
|
|
+ cmd = 5
|
|
|
+
|
|
|
command = sys.argv[cmd:spl]
|
|
|
cflags = sys.argv[spl + 1 :]
|
|
|
|
|
@@ -168,15 +172,16 @@ def main():
|
|
|
# generated files (otherwise it also prepends tmpxft_{pid}_00000000-5), and
|
|
|
# cicc derives the module name from its {input}.cpp1.ii file name.
|
|
|
command += ['--keep', '--keep-dir', tempfile.mkdtemp(prefix='compile_cuda.py.')]
|
|
|
- # nvcc generates symbols like __fatbinwrap_{len}_{basename}_{hash} where
|
|
|
+ # nvcc generates symbols like __fatbinwrap_{len}_{basename}_{hash}_{pid} where
|
|
|
# {basename} is {input}.cpp1.ii with non-C chars translated to _, {len} is
|
|
|
- # {basename} length, and {hash} is the hash of first exported symbol in
|
|
|
+ # {basename} length, {hash} is the hash of first exported symbol in
|
|
|
# {input}.cpp1.ii if there is one, otherwise it is based on its modification
|
|
|
# time (converted to string in the local timezone) and the current working
|
|
|
- # directory. To stabilize the names of these symbols we need to fix mtime,
|
|
|
- # timezone, and cwd.
|
|
|
- if mtime0:
|
|
|
- os.environ['LD_PRELOAD'] = mtime0
|
|
|
+ # directory, and {pid} is a pid of nvcc process. To stabilize the names of
|
|
|
+ # these symbols we need to fix mtime, timezone, cwd and pid.
|
|
|
+ preload = [os.environ.get('LD_PRELOAD', ''), mtime0, custom_pid]
|
|
|
+ os.environ['LD_PRELOAD'] = ' '.join(filter(None, preload))
|
|
|
+
|
|
|
os.environ['TZ'] = 'UTC0' # POSIX fixed offset format.
|
|
|
os.environ['TZDIR'] = '/var/empty' # Against counterfeit /usr/share/zoneinfo/$TZ.
|
|
|
|