Skip to content

Commit 95b2542

Browse files
committed
Merge branch 'rightlib' into merge-libs-250219-0050
2 parents 0402fc0 + afe5f17 commit 95b2542

File tree

278 files changed

+6559
-2536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+6559
-2536
lines changed

build/conf/linkers/ld.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ GENERATE_MF_CMD=\
205205
--ya-end-command-file
206206

207207
_LINK_SCRIPT_IMPORTS=\
208-
${hide;input:"build/scripts/fix_py2_protobuf.py"} \
209208
${hide;input:"build/scripts/thinlto_cache.py"} \
210209
$_PROCESS_WHOLE_ARCHIVE_SCRIPT
211210

build/conf/linkers/msvc_linker.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ when ($_UNDER_WINE_LIB == "yes") {
113113
}
114114

115115
LINK_WRAPPER_DYNLIB=\
116-
${YMAKE_PYTHON} ${input:"build/scripts/link_dyn_lib.py"} ${hide;input:"build/scripts/fix_py2_protobuf.py"} \
116+
${YMAKE_PYTHON} ${input:"build/scripts/link_dyn_lib.py"} \
117117
--arch WINDOWS \
118118
--target $TARGET
119119

@@ -144,6 +144,7 @@ _GENERATE_EXTRA_OBJS=
144144
# first group need /WHOLEARCHIVE: prefix which will be added in fix_msvc_output.py or run_msvc_wine.py
145145
# the tail of link commands will be added in the third command file
146146
_MSVC_SRCS_GLOBALS=\
147+
--start-plugins ${ext=.pyplugin:SRCS_GLOBAL} --end-plugins \
147148
--start-wa --ya-start-command-file ${qe;rootrel;ext=.lib:SRCS_GLOBAL} --ya-end-command-file --end-wa \
148149
--ya-start-command-file ${qe;rootrel;ext=.obj:SRCS_GLOBAL} --ya-end-command-file
149150

build/scripts/fix_msvc_output.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import subprocess
2-
import os, sys
2+
import os
3+
import sys
4+
import json
5+
36

47
# Explicitly enable local imports
58
# Don't forget to add imported scripts to inputs of the calling command!
69
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
710
import process_command_files as pcf
811
import process_whole_archive_option as pwa
912

10-
from fix_py2_protobuf import fix_py2
11-
1213

1314
def out2err(cmd):
1415
return subprocess.Popen(cmd, stdout=sys.stderr).wait()
@@ -38,13 +39,27 @@ def out2err_cut_first_line(cmd):
3839

3940

4041
if __name__ == '__main__':
41-
mode = sys.argv[1]
42-
args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(pcf.skip_markers(sys.argv[2:]))
42+
args = sys.argv[1:]
43+
mode = args[0]
44+
plugins = []
45+
46+
if mode == 'link' and '--start-plugins' in args:
47+
ib = args.index('--start-plugins')
48+
ie = args.index('--end-plugins')
49+
plugins = args[ib + 1:ie]
50+
args = args[:ib] + args[ie + 1:]
51+
52+
for p in plugins:
53+
res = subprocess.check_output([sys.executable, p] + args).decode().strip()
54+
55+
if res:
56+
args = json.loads(res)
57+
58+
args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(pcf.skip_markers(args[1:]))
4359
cmd = pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers, wa_libs).construct_cmd(args)
4460
run = out2err
4561
if mode in ('cl', 'ml'):
4662
# First line of cl.exe and ml64.exe stdout is useless: it prints input file
4763
run = out2err_cut_first_line
48-
if mode == 'link':
49-
cmd = fix_py2(cmd, have_comand_files=True, prefix='', suffix='lib')
64+
5065
sys.exit(run(cmd))

build/scripts/link_dyn_lib.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import link_exe
1616

1717
from process_whole_archive_option import ProcessWholeArchiveOption
18-
from fix_py2_protobuf import fix_py2
1918

2019

2120
def shlex_join(cmd):
@@ -245,7 +244,6 @@ def parse_args(args):
245244

246245
cmd = fix_blas_resolving(args)
247246
cmd = fix_cmd(opts.arch, cmd)
248-
cmd = fix_py2(cmd)
249247

250248
if opts.dynamic_cuda:
251249
cmd = fix_cmd_for_dynamic_cuda(cmd)

build/scripts/link_exe.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import thinlto_cache
1515

1616
from process_whole_archive_option import ProcessWholeArchiveOption
17-
from fix_py2_protobuf import fix_py2
1817

1918

2019
def get_leaks_suppressions(cmd):
@@ -353,7 +352,6 @@ def parse_args(args):
353352
args = pcf.skip_markers(args)
354353

355354
cmd = fix_blas_resolving(args)
356-
cmd = fix_py2(cmd)
357355
cmd = remove_excessive_flags(cmd)
358356
cmd = fix_sanitize_flag(cmd, opts)
359357

build/scripts/ya.make

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ IF (PY2)
1717
fetch_from_mds.py
1818
fetch_from_sandbox.py
1919
fetch_resource.py
20-
fix_py2_protobuf.py
2120
gen_java_codenav_entry.py
2221
gen_py3_reg.py
2322
go_tool.py
@@ -71,7 +70,6 @@ ELSEIF (PY3)
7170
find_time_trace.py
7271
fix_java_command_file_cp.py
7372
fix_msvc_output.py
74-
fix_py2_protobuf.py
7573
fs_tools.py
7674
gen_aar_gradle_script.py
7775
gen_java_codenav_protobuf.py

build/ymake.core.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ XARGS=$YMAKE_PYTHON ${input:"build/scripts/xargs.py"} -- ${BINDIR}/__args
533533

534534
WRITER_PY=$YMAKE_PYTHON ${input:"build/scripts/writer.py"} ${hide;input:"build/scripts/process_command_files.py"}
535535
FS_TOOLS=$YMAKE_PYTHON3 ${input:"build/scripts/fs_tools.py"} ${hide;input:"build/scripts/process_command_files.py"}
536-
FIX_MSVC_OUTPUT=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} ${hide;input:"build/scripts/process_command_files.py"} ${hide;input:"build/scripts/fix_py2_protobuf.py"}
536+
FIX_MSVC_OUTPUT=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} ${hide;input:"build/scripts/process_command_files.py"}
537537
_PROCESS_WHOLE_ARCHIVE_SCRIPT=${hide;input:"build/scripts/process_command_files.py"} ${hide;input:"build/scripts/process_whole_archive_option.py"}
538538

539539
COPY_CMD=$FS_TOOLS copy

contrib/libs/cxxsupp/libcxx/include/__config_site

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#define _LIBCPP_ABI_VERSION 1
44
#define _LIBCPP_ABI_NAMESPACE __y1
55

6-
#define _LIBCPP_DISABLE_NODISCARD_EXT
76
#define _LIBCPP_PSTL_CPU_BACKEND_THREAD
87

98
#ifndef _YNDX_LIBCPP_ENABLE_EXTENSIONS

build/scripts/fix_py2_protobuf.py renamed to contrib/libs/protobuf_old/protoherobora.py

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,58 @@
1+
#!/usr/bin/env python3
2+
13
import subprocess
2-
import os, sys
4+
import os
5+
import sys
6+
import json
7+
8+
9+
# TODO: dedup
10+
def is_cmdfile_arg(arg):
11+
# type: (str) -> bool
12+
return arg.startswith('@')
13+
14+
15+
def cmdfile_path(arg):
16+
# type: (str) -> str
17+
return arg[1:]
18+
19+
20+
def read_from_command_file(arg):
21+
# type: (str) -> list[str]
22+
with open(arg) as afile:
23+
return afile.read().splitlines()
324

4-
# Explicitly enable local imports
5-
# Don't forget to add imported scripts to inputs of the calling command!
6-
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
7-
import process_command_files as pcf
25+
26+
def skip_markers(args):
27+
# type: (list[str]) -> list[str]
28+
res = []
29+
for arg in args:
30+
if arg == '--ya-start-command-file' or arg == '--ya-end-command-file':
31+
continue
32+
res.append(arg)
33+
return res
34+
35+
36+
def iter_args(
37+
args, # type: list[str]
38+
):
39+
for arg in args:
40+
if not is_cmdfile_arg(arg):
41+
if arg == '--ya-start-command-file' or arg == '--ya-end-command-file':
42+
continue
43+
yield arg
44+
else:
45+
for cmdfile_arg in read_from_command_file(cmdfile_path(arg)):
46+
yield cmdfile_arg
47+
48+
49+
def get_args(args):
50+
# type: (list[str]) -> list[str]
51+
return list(iter_args(args))
52+
# end TODO
853

954

1055
def run(*args):
11-
# print >>sys.stderr, args
1256
return subprocess.check_output(list(args), shell=False).strip()
1357

1458

@@ -80,10 +124,20 @@ def rename_syms(where, ret, libs):
80124
return ret
81125

82126

127+
def find_lld(args):
128+
for x in args:
129+
if 'lld-link' in x:
130+
return x
131+
132+
raise IndexError()
133+
134+
83135
def fix_py2(cmd, have_comand_files=False, prefix='lib', suffix='a'):
84136
args = cmd
137+
85138
if have_comand_files:
86-
args = pcf.get_args(cmd)
139+
args = get_args(cmd)
140+
87141
if 'protobuf_old' not in str(args):
88142
return cmd
89143

@@ -99,7 +153,10 @@ def need_rename(x):
99153
old = []
100154
lib = []
101155

102-
where = os.path.dirname(cmd[0]) + '/'
156+
try:
157+
where = os.path.dirname(cmd[cmd.index('--objcopy-exe') + 1]) + '/'
158+
except ValueError:
159+
where = os.path.dirname(find_lld(cmd)) + '/'
103160

104161
for x in args:
105162
if need_rename(x):
@@ -113,9 +170,9 @@ def need_rename(x):
113170
return old + [name]
114171

115172
for file in cmd:
116-
if pcf.is_cmdfile_arg(file):
117-
cmd_file_path = pcf.cmdfile_path(file)
118-
args = pcf.read_from_command_file(cmd_file_path)
173+
if is_cmdfile_arg(file):
174+
cmd_file_path = cmdfile_path(file)
175+
args = read_from_command_file(cmd_file_path)
119176
if not 'protobuf_old' in str(args):
120177
continue
121178
with open(cmd_file_path, 'w') as afile:
@@ -125,3 +182,14 @@ def need_rename(x):
125182
afile.write(name)
126183

127184
return cmd
185+
186+
187+
if __name__ == '__main__':
188+
args = sys.argv[1:]
189+
190+
if 'lld-link' in str(args):
191+
cmd = fix_py2(args, have_comand_files=True, prefix='', suffix='lib')
192+
else:
193+
cmd = fix_py2(args)
194+
195+
sys.stdout.write(json.dumps(cmd))

contrib/libs/protobuf_old/ya.make

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
LIBRARY()
44

5+
LD_PLUGIN(protoherobora.py)
6+
57
LICENSE(
68
BSD-3-Clause AND
79
Protobuf-License

0 commit comments

Comments
 (0)