aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkickbutt <kickbutt@yandex-team.com>2024-02-03 13:02:23 +0300
committerkickbutt <kickbutt@yandex-team.com>2024-02-03 13:24:17 +0300
commitfc1e67a2ad8c64bea6ca9301aa220764eac1dd03 (patch)
tree4a0fb07462b754b81bb513c4dbfeaf01654cc9b1
parent269e545acb165a523d243928f9586b107933e7c3 (diff)
downloadydb-fc1e67a2ad8c64bea6ca9301aa220764eac1dd03.tar.gz
Fix bug after rXXXXXX
-rw-r--r--build/scripts/link_exe.py33
-rw-r--r--build/ymake.core.conf3
2 files changed, 21 insertions, 15 deletions
diff --git a/build/scripts/link_exe.py b/build/scripts/link_exe.py
index c20875c77a..710f3b77fd 100644
--- a/build/scripts/link_exe.py
+++ b/build/scripts/link_exe.py
@@ -59,6 +59,10 @@ class CUDAManager:
def has_cuda_fatbins(self, cmd):
return bool(set(cmd) & self.fatbin_libs)
+ @property
+ def can_prune_libs(self):
+ return self.prune_args and self.nvprune_exe
+
def _known_fatbin_libs(self, libs):
libs_wo_device_code = {
'-lcudart_static'
@@ -103,14 +107,24 @@ def process_cuda_libraries(cmd, cuda_manager, build_root):
os.makedirs(path)
yield path
+ # add custom linker script
+ to_dirpath = next(tmpdir_generator('cuda_linker_script'))
+ script_path = os.path.join(to_dirpath, 'script')
+ with open(script_path, 'w') as f:
+ cuda_manager.write_linker_script(f)
+ flags_with_linker = list(cmd) + ['-Wl,--script={}'.format(script_path)]
+
+ if not cuda_manager.can_prune_libs:
+ return flags_with_linker
+
tmpdir_gen = tmpdir_generator('cuda_pruned_libs')
- flags = []
+ flags_pruned = []
cuda_deps = set()
# Because each directory flag only affects flags that follow it,
# for correct pruning we need to process that in reversed order
- for flag in reversed(cmd):
+ for flag in reversed(flags_with_linker):
if flag in cuda_manager.fatbin_libs:
cuda_deps.add('lib' + flag[2:] + '.a')
flag += '_pruned'
@@ -130,21 +144,12 @@ def process_cuda_libraries(cmd, cuda_manager, build_root):
# do not remove current directory
# because it can contain other libraries we want link to
# instead we just add new directory with pruned libs
- flags.append('-L' + to_dirpath)
+ flags_pruned.append('-L' + to_dirpath)
- flags.append(flag)
+ flags_pruned.append(flag)
assert not cuda_deps, ('Unresolved CUDA deps: ' + ','.join(cuda_deps))
- flags = list(reversed(flags))
-
- # add custom linker script
- to_dirpath = next(tmpdir_generator('cuda_linker_script'))
- script_path = os.path.join(to_dirpath, 'script')
- with open(script_path, 'w') as f:
- cuda_manager.write_linker_script(f)
- flags.append('-Wl,--script={}'.format(script_path))
-
- return flags
+ return reversed(flags_pruned)
def remove_excessive_flags(cmd):
diff --git a/build/ymake.core.conf b/build/ymake.core.conf
index 62762972d6..1446ee131e 100644
--- a/build/ymake.core.conf
+++ b/build/ymake.core.conf
@@ -1045,9 +1045,10 @@ module _LINK_UNIT: _BASE_UNIT {
when ($CUDA_ARCHITECTURES && $USE_DYNAMIC_CUDA != "yes") {
LINK_SCRIPT_EXE_FLAGS+=--cuda-architectures $CUDA_ARCHITECTURES
LINK_SCRIPT_EXE_FLAGS+=--nvprune-exe $CUDA_ROOT/bin/nvprune
- LINK_SCRIPT_EXE_FLAGS+=--build-root $(BUILD_ROOT)
}
+ LINK_SCRIPT_EXE_FLAGS+=--build-root $(BUILD_ROOT)
+
when ($OPENSOURCE == "yes" && $AUTOCHECK == "yes") {
# FIXME: Replace AUTOCHECK == yes with _not a host platform_ check after YMAKE-218
MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY