diff options
author | alexv-smirnov <alex@ydb.tech> | 2023-03-15 19:59:12 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2023-03-15 19:59:12 +0300 |
commit | 056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11 (patch) | |
tree | 4740980126f32e3af7937ba0ca5f83e59baa4ab0 /build/plugins/llvm_bc.py | |
parent | 269126dcced1cc8b53eb4398b4a33e5142f10290 (diff) | |
download | ydb-056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11.tar.gz |
add library/cpp/actors, ymake build to ydb oss export
Diffstat (limited to 'build/plugins/llvm_bc.py')
-rw-r--r-- | build/plugins/llvm_bc.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/build/plugins/llvm_bc.py b/build/plugins/llvm_bc.py new file mode 100644 index 0000000000..7666c21907 --- /dev/null +++ b/build/plugins/llvm_bc.py @@ -0,0 +1,33 @@ +import sys + +from _common import rootrel_arc_src, sort_by_keywords, skip_build_root, stripext + + +def onllvm_bc(unit, *args): + free_args, kwds = sort_by_keywords({'SYMBOLS': -1, 'NAME': 1, 'NO_COMPILE': 0}, args) + name = kwds['NAME'][0] + symbols = kwds.get('SYMBOLS') + obj_suf = unit.get('OBJ_SUF') + skip_compile_step = 'NO_COMPILE' in kwds + merged_bc = name + '_merged' + obj_suf + '.bc' + out_bc = name + '_optimized' + obj_suf + '.bc' + bcs = [] + for x in free_args: + rel_path = rootrel_arc_src(x, unit) + bc_path = '${ARCADIA_BUILD_ROOT}/' + skip_build_root(rel_path) + obj_suf + '.bc' + if not skip_compile_step: + if x.endswith('.c'): + llvm_compile = unit.onllvm_compile_c + elif x.endswith('.ll'): + llvm_compile = unit.onllvm_compile_ll + else: + llvm_compile = unit.onllvm_compile_cxx + llvm_compile([rel_path, bc_path]) + bcs.append(bc_path) + unit.onllvm_link([merged_bc] + bcs) + opt_opts = ['-O2', '-globalopt', '-globaldce'] + if symbols: + # XXX: '#' used instead of ',' to overcome ymake tendency to split everything by comma + opt_opts += ['-internalize', '-internalize-public-api-list=' + '#'.join(symbols)] + unit.onllvm_opt([merged_bc, out_bc] + opt_opts) + unit.onresource([out_bc, '/llvm_bc/' + name]) |