diff options
author | hiddenpath <hiddenpath@yandex-team.com> | 2023-08-18 10:40:07 +0300 |
---|---|---|
committer | hiddenpath <hiddenpath@yandex-team.com> | 2023-08-18 14:29:45 +0300 |
commit | 9030145515277a2628ea6ea1af697d28d6896962 (patch) | |
tree | 18dabf47609ce1e591d95d3980b415f704daf39c | |
parent | 7c2bc537e0c2275bac8902f18f61bd888c353c56 (diff) | |
download | ydb-9030145515277a2628ea6ea1af697d28d6896962.tar.gz |
Make libclang.rt_profile depends on sources
-rw-r--r-- | build/conf/linkers/ld.conf | 33 | ||||
-rw-r--r-- | build/scripts/copy_clang_profile_rt.py | 42 | ||||
-rw-r--r-- | build/scripts/ya.make | 1 | ||||
-rw-r--r-- | build/ymake.core.conf | 15 |
4 files changed, 86 insertions, 5 deletions
diff --git a/build/conf/linkers/ld.conf b/build/conf/linkers/ld.conf index 090328de1d..8ad41c57ef 100644 --- a/build/conf/linkers/ld.conf +++ b/build/conf/linkers/ld.conf @@ -191,8 +191,9 @@ LINK_SCRIPT_EXE_FLAGS= REAL_LINK_EXE_CMDLINE =\ $YMAKE_PYTHON ${input:"build/scripts/link_exe.py"} \ --source-root $ARCADIA_ROOT - REAL_LINK_EXE_CMDLINE+=$_LD_LINKER_OUTPUT - REAL_LINK_EXE_CMDLINE+=\ + +REAL_LINK_EXE_CMDLINE+=$_LD_LINKER_OUTPUT +REAL_LINK_EXE_CMDLINE+=\ ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ $_LD_ARCH_FLAG \ @@ -212,6 +213,15 @@ REAL_LINK_EXE_TIDY=\ $AUTO_INPUT \ $_LD_ENV_STYLE +COPY_PROFILE_RUNTIME=\ + $YMAKE_PYTHON3 ${input:"build/scripts/copy_clang_profile_rt.py"} \ + --arch $TARGET_PLATFORM \ + --build-root $ARCADIA_BUILD_ROOT \ + --need-profile-rt $NEED_PROFILE_RUNTIME -- +COPY_PROFILE_RUNTIME+=\ + ${rootrel:PEERS} \ + $LDFLAGS + # Executable Shared Library REAL_LINK_EXEC_DYN_LIB_CMDLINE =\ @@ -271,8 +281,23 @@ otherwise { DWARF_COMMAND=$_DWARF_COMMAND _REAL_LINK_EXE=$REAL_LINK_EXE_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) -_LINK_EXE=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_LINK_EXE && $DWARF_COMMAND && $LINK_ADDITIONAL_SECTIONS_COMMAND && $PACK_IOS_CMD -_LINK_DYN_LIB=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_LINK_DYN_LIB && $DWARF_COMMAND && $LINK_ADDITIONAL_SECTIONS_COMMAND +_LINK_EXE= +_LINK_EXE+=$GENERATE_MF +_LINK_EXE+=&& $GENERATE_VCS_C_INFO_NODEP +_LINK_EXE+=&& $COPY_PROFILE_RUNTIME +_LINK_EXE+=&& $REAL_LINK_EXE +_LINK_EXE+=&& $DWARF_COMMAND +_LINK_EXE+=&& $LINK_ADDITIONAL_SECTIONS_COMMAND +_LINK_EXE+=&& $PACK_IOS_CMD + +_LINK_DYN_LIB= +_LINK_DYN_LIB+=$GENERATE_MF +_LINK_DYN_LIB+=&& $GENERATE_VCS_C_INFO_NODEP +_LINK_DYN_LIB+=&& $COPY_PROFILE_RUNTIME +_LINK_DYN_LIB+=&& $REAL_LINK_DYN_LIB +_LINK_DYN_LIB+=&& $DWARF_COMMAND +_LINK_DYN_LIB+=&& $LINK_ADDITIONAL_SECTIONS_COMMAND + when ($TIDY == "yes") { _REAL_LINK_EXE=$REAL_LINK_EXE_TIDY _LINK_EXE=$REAL_LINK_EXE diff --git a/build/scripts/copy_clang_profile_rt.py b/build/scripts/copy_clang_profile_rt.py new file mode 100644 index 0000000000..b24dde3959 --- /dev/null +++ b/build/scripts/copy_clang_profile_rt.py @@ -0,0 +1,42 @@ +import optparse +import os +import shutil + +import process_command_files as pcf + +CLANG_RT_VERSION = 14 + + +def copy_clang_rt_profile(cmd, build_root, arch) -> None: + profile_rt_lib = None + resource_dir = None + + for arg in cmd: + if arg.startswith(f'contrib/libs/clang{CLANG_RT_VERSION}-rt/lib/profile/libclang_rt.profile'): + profile_rt_lib = arg + if arg.startswith('-resource-dir='): + resource_dir = arg[len('-resource-dir='):] + + profile_rt_path = os.path.join(build_root, profile_rt_lib) + profile_name = os.path.basename(profile_rt_path) + + dst_dir = os.path.join(build_root, resource_dir, 'lib/{}'.format(arch.lower())) + os.makedirs(dst_dir, exist_ok=True) + shutil.copy(profile_rt_path, os.path.join(dst_dir, profile_name)) + + +def parse_args(): + parser = optparse.OptionParser() + parser.disable_interspersed_args() + parser.add_option('--build-root') + parser.add_option('--arch') + parser.add_option('--need-profile-rt') + return parser.parse_args() + + +if __name__ == '__main__': + opts, args = parse_args() + args = pcf.skip_markers(args) + + if opts.need_profile_rt != "no": + copy_clang_rt_profile(args, opts.build_root, opts.arch) diff --git a/build/scripts/ya.make b/build/scripts/ya.make index 69a7bd572d..5448ec7db8 100644 --- a/build/scripts/ya.make +++ b/build/scripts/ya.make @@ -102,6 +102,7 @@ ELSEIF(PY3) TEST_SRCS( build_info_gen.py + copy_clang_profile_rt.py gen_yql_python_udf.py ) ENDIF() diff --git a/build/ymake.core.conf b/build/ymake.core.conf index 0b202d75eb..f94ae435b7 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -9,7 +9,7 @@ FAKEID=314159265358 SANDBOX_FAKEID=${FAKEID}.7600000 -CPP_FAKEID=2023-06-06 +CPP_FAKEID=2023-08-18 GO_FAKEID=11100371 ANDROID_FAKEID=2023-05-17 CLANG_TIDY_FAKEID=2023-06-06 @@ -408,6 +408,14 @@ when ($ALLOCATOR == "LF") { MSVC_DYNAMICBASE=/DYNAMICBASE:NO } +# tag:profile +NEED_PROFILE_RUNTIME=no +when ($BUILD_TYPE == "PROFILE" || $BUILD_TYPE == "COVERAGE" || ($CLANG_COVERAGE && $CLANG_COVERAGE != "no")) { + when($CLANG && ($TARGET_PLATFORM == "LINUX" || $TARGET_PLATFORM == "DARWIN")) { + NEED_PROFILE_RUNTIME=yes + } +} + # tag:sanitize SANITIZER_CFLAGS= @@ -602,6 +610,11 @@ module _BASE_UNIT: _BARE_UNIT { } } + when ($NEED_PROFILE_RUNTIME && $NEED_PROFILE_RUNTIME != "no") { + LDFLAGS+=-resource-dir=contrib/libs/clang-rt + PEERDIR+=contrib/libs/clang14-rt/lib/profile + } + when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") { PEERDIR+=$COMPILER_PLATFORM } |