Skip to content

Commit 188c731

Browse files
pgblinkov
authored andcommitted
also support dll linking
commit_hash:ebafc271047aa3ae660b813c3dcaee05324895bf
1 parent cfc1f45 commit 188c731

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

build/conf/linkers/ld.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ REAL_LINK_EXEC_DYN_LIB_CMDLINE =\
244244
$YMAKE_PYTHON ${input:"build/scripts/link_dyn_lib.py"} \
245245
${hide;input:"build/scripts/link_exe.py"} \
246246
--target $TARGET
247+
REAL_LINK_EXEC_DYN_LIB_CMDLINE+=--start-plugins ${ext=.pyplugin:SRCS_GLOBAL} --end-plugins
247248
REAL_LINK_EXEC_DYN_LIB_CMDLINE+=$_LD_LINKER_OUTPUT
248249
REAL_LINK_EXEC_DYN_LIB_CMDLINE+=\
249250
$_ROOT_FLAGS \
@@ -271,6 +272,7 @@ REAL_LINK_DYN_LIB_CMDLINE =\
271272
$YMAKE_PYTHON ${input:"build/scripts/link_dyn_lib.py"} \
272273
${hide;input:"build/scripts/link_exe.py"} \
273274
--target $TARGET
275+
REAL_LINK_DYN_LIB_CMDLINE+=--start-plugins ${ext=.pyplugin:SRCS_GLOBAL} --end-plugins
274276
REAL_LINK_DYN_LIB_CMDLINE+=$_LD_LINKER_OUTPUT
275277
REAL_LINK_DYN_LIB_CMDLINE+=\
276278
${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \

build/scripts/link_dyn_lib.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import print_function
22
import sys
33
import os
4+
import json
45
import subprocess
56
import tempfile
67
import collections
@@ -129,8 +130,6 @@ def fix_windows_param(ex):
129130
return ['/DEF:{}'.format(def_file.name)]
130131

131132

132-
MUSL_LIBS = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil'
133-
134133
CUDA_LIBRARIES = {
135134
'-lcublas_static': '-lcublas',
136135
'-lcublasLt_static': '-lcublasLt',
@@ -179,14 +178,6 @@ def do_fix(p):
179178
return sum((do_fix(x) for x in c), [])
180179

181180

182-
def fix_cmd_for_musl(cmd):
183-
flags = []
184-
for flag in cmd:
185-
if flag not in MUSL_LIBS:
186-
flags.append(flag)
187-
return flags
188-
189-
190181
def fix_cmd_for_dynamic_cuda(cmd):
191182
flags = []
192183
for flag in cmd:
@@ -208,7 +199,7 @@ def fix_blas_resolving(cmd):
208199
return cmd
209200

210201

211-
def parse_args():
202+
def parse_args(args):
212203
parser = optparse.OptionParser()
213204
parser.disable_interspersed_args()
214205
parser.add_option('--arch')
@@ -218,7 +209,6 @@ def parse_args():
218209
parser.add_option('--build-root')
219210
parser.add_option('--fix-elf')
220211
parser.add_option('--linker-output')
221-
parser.add_option('--musl', action='store_true')
222212
parser.add_option('--dynamic-cuda', action='store_true')
223213
parser.add_option('--cuda-architectures',
224214
help='List of supported CUDA architectures, separated by ":" (e.g. "sm_52:compute_70:lto_90a"')
@@ -229,11 +219,26 @@ def parse_args():
229219
parser.add_option('--custom-step')
230220
parser.add_option('--python')
231221
thinlto_cache.add_options(parser)
232-
return parser.parse_args()
222+
return parser.parse_args(args)
233223

234224

235225
if __name__ == '__main__':
236-
opts, args = parse_args()
226+
args = sys.argv[1:]
227+
plugins = []
228+
229+
if '--start-plugins' in args:
230+
ib = args.index('--start-plugins')
231+
ie = args.index('--end-plugins')
232+
plugins = args[ib + 1:ie]
233+
args = args[:ib] + args[ie + 1:]
234+
235+
for p in plugins:
236+
res = subprocess.check_output([sys.executable, p] + args).decode().strip()
237+
238+
if res:
239+
args = json.loads(res)
240+
241+
opts, args = parse_args(args)
237242

238243
assert opts.arch
239244
assert opts.target
@@ -242,8 +247,6 @@ def parse_args():
242247
cmd = fix_cmd(opts.arch, cmd)
243248
cmd = fix_py2(cmd)
244249

245-
if opts.musl:
246-
cmd = fix_cmd_for_musl(cmd)
247250
if opts.dynamic_cuda:
248251
cmd = fix_cmd_for_dynamic_cuda(cmd)
249252
else:

build/scripts/link_exe.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,13 @@ def parse_args(args):
335335

336336
if __name__ == '__main__':
337337
args = sys.argv[1:]
338-
ib = args.index('--start-plugins')
339-
ie = args.index('--end-plugins')
340-
plugins = args[ib + 1:ie]
341-
args = args[:ib] + args[ie + 1:]
338+
plugins = []
339+
340+
if '--start-plugins' in args:
341+
ib = args.index('--start-plugins')
342+
ie = args.index('--end-plugins')
343+
plugins = args[ib + 1:ie]
344+
args = args[:ib] + args[ie + 1:]
342345

343346
for p in plugins:
344347
res = subprocess.check_output([sys.executable, p] + args).decode().strip()

build/ymake.core.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,6 @@ module _BASE_UNIT: _BARE_UNIT {
769769

770770
when ($MUSL == "yes") {
771771
CFLAGS += -D_musl_
772-
LINK_DYN_LIB_FLAGS += --musl
773772
PEERDIR+=contrib/libs/musl/include
774773
}
775774

0 commit comments

Comments
 (0)