diff options
author | pg <pg@yandex-team.com> | 2025-02-14 02:27:33 +0300 |
---|---|---|
committer | pg <pg@yandex-team.com> | 2025-02-14 02:47:29 +0300 |
commit | c26bb8abd161c590e8cb0e7280a14c335c1eb893 (patch) | |
tree | 23ae852c59e5ef1757d8192b28ae4185ff2b2d62 /build | |
parent | b4b061018c68181520d2e24e6c2484532e483a92 (diff) | |
download | ydb-c26bb8abd161c590e8cb0e7280a14c335c1eb893.tar.gz |
also support dll linking
commit_hash:ebafc271047aa3ae660b813c3dcaee05324895bf
Diffstat (limited to 'build')
-rw-r--r-- | build/conf/linkers/ld.conf | 2 | ||||
-rw-r--r-- | build/scripts/link_dyn_lib.py | 35 | ||||
-rw-r--r-- | build/scripts/link_exe.py | 11 | ||||
-rw-r--r-- | build/ymake.core.conf | 1 |
4 files changed, 28 insertions, 21 deletions
diff --git a/build/conf/linkers/ld.conf b/build/conf/linkers/ld.conf index 79006c21ab..fecd6699cc 100644 --- a/build/conf/linkers/ld.conf +++ b/build/conf/linkers/ld.conf @@ -244,6 +244,7 @@ REAL_LINK_EXEC_DYN_LIB_CMDLINE =\ $YMAKE_PYTHON ${input:"build/scripts/link_dyn_lib.py"} \ ${hide;input:"build/scripts/link_exe.py"} \ --target $TARGET +REAL_LINK_EXEC_DYN_LIB_CMDLINE+=--start-plugins ${ext=.pyplugin:SRCS_GLOBAL} --end-plugins REAL_LINK_EXEC_DYN_LIB_CMDLINE+=$_LD_LINKER_OUTPUT REAL_LINK_EXEC_DYN_LIB_CMDLINE+=\ $_ROOT_FLAGS \ @@ -271,6 +272,7 @@ REAL_LINK_DYN_LIB_CMDLINE =\ $YMAKE_PYTHON ${input:"build/scripts/link_dyn_lib.py"} \ ${hide;input:"build/scripts/link_exe.py"} \ --target $TARGET +REAL_LINK_DYN_LIB_CMDLINE+=--start-plugins ${ext=.pyplugin:SRCS_GLOBAL} --end-plugins REAL_LINK_DYN_LIB_CMDLINE+=$_LD_LINKER_OUTPUT REAL_LINK_DYN_LIB_CMDLINE+=\ ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ diff --git a/build/scripts/link_dyn_lib.py b/build/scripts/link_dyn_lib.py index 53757a7c75..f8e757a3c0 100644 --- a/build/scripts/link_dyn_lib.py +++ b/build/scripts/link_dyn_lib.py @@ -1,6 +1,7 @@ from __future__ import print_function import sys import os +import json import subprocess import tempfile import collections @@ -129,8 +130,6 @@ def fix_windows_param(ex): return ['/DEF:{}'.format(def_file.name)] -MUSL_LIBS = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil' - CUDA_LIBRARIES = { '-lcublas_static': '-lcublas', '-lcublasLt_static': '-lcublasLt', @@ -179,14 +178,6 @@ def fix_cmd(arch, c): return sum((do_fix(x) for x in c), []) -def fix_cmd_for_musl(cmd): - flags = [] - for flag in cmd: - if flag not in MUSL_LIBS: - flags.append(flag) - return flags - - def fix_cmd_for_dynamic_cuda(cmd): flags = [] for flag in cmd: @@ -208,7 +199,7 @@ def fix_blas_resolving(cmd): return cmd -def parse_args(): +def parse_args(args): parser = optparse.OptionParser() parser.disable_interspersed_args() parser.add_option('--arch') @@ -218,7 +209,6 @@ def parse_args(): parser.add_option('--build-root') parser.add_option('--fix-elf') parser.add_option('--linker-output') - parser.add_option('--musl', action='store_true') parser.add_option('--dynamic-cuda', action='store_true') parser.add_option('--cuda-architectures', help='List of supported CUDA architectures, separated by ":" (e.g. "sm_52:compute_70:lto_90a"') @@ -229,11 +219,26 @@ def parse_args(): parser.add_option('--custom-step') parser.add_option('--python') thinlto_cache.add_options(parser) - return parser.parse_args() + return parser.parse_args(args) if __name__ == '__main__': - opts, args = parse_args() + args = sys.argv[1:] + plugins = [] + + if '--start-plugins' in args: + ib = args.index('--start-plugins') + ie = args.index('--end-plugins') + plugins = args[ib + 1:ie] + args = args[:ib] + args[ie + 1:] + + for p in plugins: + res = subprocess.check_output([sys.executable, p] + args).decode().strip() + + if res: + args = json.loads(res) + + opts, args = parse_args(args) assert opts.arch assert opts.target @@ -242,8 +247,6 @@ if __name__ == '__main__': cmd = fix_cmd(opts.arch, cmd) cmd = fix_py2(cmd) - if opts.musl: - cmd = fix_cmd_for_musl(cmd) if opts.dynamic_cuda: cmd = fix_cmd_for_dynamic_cuda(cmd) else: diff --git a/build/scripts/link_exe.py b/build/scripts/link_exe.py index de5e215ab5..cc47d689f3 100644 --- a/build/scripts/link_exe.py +++ b/build/scripts/link_exe.py @@ -335,10 +335,13 @@ def parse_args(args): if __name__ == '__main__': args = sys.argv[1:] - ib = args.index('--start-plugins') - ie = args.index('--end-plugins') - plugins = args[ib + 1:ie] - args = args[:ib] + args[ie + 1:] + plugins = [] + + if '--start-plugins' in args: + ib = args.index('--start-plugins') + ie = args.index('--end-plugins') + plugins = args[ib + 1:ie] + args = args[:ib] + args[ie + 1:] for p in plugins: res = subprocess.check_output([sys.executable, p] + args).decode().strip() diff --git a/build/ymake.core.conf b/build/ymake.core.conf index f100865d53..d35952e8da 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -769,7 +769,6 @@ module _BASE_UNIT: _BARE_UNIT { when ($MUSL == "yes") { CFLAGS += -D_musl_ - LINK_DYN_LIB_FLAGS += --musl PEERDIR+=contrib/libs/musl/include } |