diff options
author | zhukoff-pavel <zhukoff-pavel@yandex-team.com> | 2024-08-28 10:40:30 +0300 |
---|---|---|
committer | zhukoff-pavel <zhukoff-pavel@yandex-team.com> | 2024-08-28 11:03:37 +0300 |
commit | 9f71049204d63d8b302cf8d2608843e70ee18379 (patch) | |
tree | f79881f797ec169856c551c3be5d1137119796d2 | |
parent | 5d69584883acf76288028d9eda6f5154bad71f03 (diff) | |
download | ydb-9f71049204d63d8b302cf8d2608843e70ee18379.tar.gz |
mock getpid func
171c556f349e96400867de4937fe0c703849c0c8
-rw-r--r-- | build/scripts/compile_cuda.py | 17 | ||||
-rwxr-xr-x | build/ymake_conf.py | 4 |
2 files changed, 14 insertions, 7 deletions
diff --git a/build/scripts/compile_cuda.py b/build/scripts/compile_cuda.py index 69b93cec91..cd37a95c60 100644 --- a/build/scripts/compile_cuda.py +++ b/build/scripts/compile_cuda.py @@ -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. diff --git a/build/ymake_conf.py b/build/ymake_conf.py index bdb3c7e8d9..67f8187df3 100755 --- a/build/ymake_conf.py +++ b/build/ymake_conf.py @@ -2423,10 +2423,12 @@ class Cuda(object): def print_macros(self): mtime = ' ' + custom_pid = ' ' if self.build.host_target[1].is_linux: mtime = ' --mtime ${tool:"tools/mtime0"} ' + custom_pid = '--custom-pid ${tool:"tools/custom_pid"} ' if not self.cuda_use_clang.value: - cmd = '$YMAKE_PYTHON ${input:"build/scripts/compile_cuda.py"}' + mtime + '$NVCC_OLD $NVCC_STD $NVCC_FLAGS -c ${input:SRC} -o ${output;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:SRC} ${pre=-I:_C__INCLUDE} --cflags $C_FLAGS_PLATFORM $CXXFLAGS $NVCC_STD $NVCC_CFLAGS $SRCFLAGS ${input;hide:"build/platform/cuda/cuda_runtime_include.h"} $NVCC_ENV $CUDA_HOST_COMPILER_ENV ${kv;hide:"p CC"} ${kv;hide:"pc light-green"}' # noqa E501 + cmd = '$YMAKE_PYTHON ${input:"build/scripts/compile_cuda.py"}' + mtime + custom_pid + '$NVCC_OLD $NVCC_STD $NVCC_FLAGS -c ${input:SRC} -o ${output;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:SRC} ${pre=-I:_C__INCLUDE} --cflags $C_FLAGS_PLATFORM $CXXFLAGS $NVCC_STD $NVCC_CFLAGS $SRCFLAGS ${input;hide:"build/platform/cuda/cuda_runtime_include.h"} $NVCC_ENV $CUDA_HOST_COMPILER_ENV ${kv;hide:"p CC"} ${kv;hide:"pc light-green"}' # noqa E501 else: cmd = '$CXX_COMPILER_OLD --cuda-path=$CUDA_ROOT $C_FLAGS_PLATFORM -c ${input:SRC} -o ${output;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:SRC} ${pre=-I:_C__INCLUDE} $CXXFLAGS $SRCFLAGS $TOOLCHAIN_ENV ${kv;hide:"p CU"} ${kv;hide:"pc green"}' # noqa E501 |