diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /build/conf/linkers | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'build/conf/linkers')
-rw-r--r-- | build/conf/linkers/ld.conf | 383 | ||||
-rw-r--r-- | build/conf/linkers/msvc_linker.conf | 271 |
2 files changed, 654 insertions, 0 deletions
diff --git a/build/conf/linkers/ld.conf b/build/conf/linkers/ld.conf new file mode 100644 index 0000000000..655c09dc66 --- /dev/null +++ b/build/conf/linkers/ld.conf @@ -0,0 +1,383 @@ +_LD_FLAGS_1= +_LD_FLAGS_2= +when ($MUSL == "yes") { + _LD_FLAGS_1=-Wl,--no-as-needed + when ($GCC == "yes") { + # MUSL_BFD: musl build uses --no-dynamic-linker linker flag + # which gold doesn't know about. And we can only specify linker + # type, not it's path as we do for Clang through linker selector. + _LD_FLAGS_2=-fuse-ld=bfd + } +} +elsewhen ($OS_LINUX == "yes") { + _LD_FLAGS_1=-ldl -lrt -Wl,--no-as-needed + when ($GCC == "yes") { + _LD_FLAGS_2=-Wl,-Bstatic -latomic -Wl,-Bdynamic + } +} +elsewhen ($OS_ANDROID == "yes") { + _LD_FLAGS_1=-ldl -Wl,--no-as-needed + when ($_DEFAULT_LINKER_ID == "lld" && $_ANDROID_API_LESS_THEN_29 == "yes") { + # https://github.com/android/ndk/issues/1196 + _LD_FLAGS_2=-Wl,--no-rosegment + } +} +elsewhen ($OS_DARWIN == "yes") { + _LD_FLAGS_1=-Wl,-no_deduplicate + when ($CLANG != "yes") { + _LD_FLAGS_2=-Wl,-no_compact_unwind + } +} + +_LD_FLAGS_IOS_MAPSMOBI_ARM= +when ($OS_IOS == "yes" && $MAPSMOBI_BUILD_TARGET == "yes" && $ARCH_ARM) { + _LD_FLAGS_IOS_MAPSMOBI_ARM=-fembed-bitcode -Wl,-bitcode_verify +} + +_LD_FLAGS_PROFILER_TYPE= +when ($_BUILD_PROFILER_TYPE == "gprof") { + _LD_FLAGS_PROFILER_TYPE=-pg +} + +_LD_FLAGS_COVERAGE= +when ($_BUILD_COVERAGE == "yes") { + _LD_FLAGS_COVERAGE=-fprofile-arcs -ftest-coverage +} + +_LD_FLAGS = +_LD_FLAGS+=$_LD_FLAGS_1 +_LD_FLAGS+=$_LD_FLAGS_2 +_LD_FLAGS+=$_LD_FLAGS_IOS_MAPSMOBI_ARM +_LD_FLAGS+=$_LD_FLAGS_PROFILER_TYPE +_LD_FLAGS+=$_LD_FLAGS_COVERAGE +_LD_FLAGS+=$LD_SDK_VERSION + +LDFLAGS+=$USER_LDFLAGS $_LD_FLAGS +LDFLAGS_GLOBAL+= + +_START_GROUP= +_END_GROUP= +START_WHOLE_ARCHIVE_VALUE= +END_WHOLE_ARCHIVE_VALUE= +LD_STRIP_FLAG= +_SONAME_OPTION= +_LD_SRCS_GLOBALS=--start-wa ${rootrel;ext=.a:SRCS_GLOBAL} --end-wa ${rootrel;ext=.o:SRCS_GLOBAL} ${rootrel;ext=.supp:SRCS_GLOBAL} +when ($OS_LINUX == "yes" || $OS_ANDROID == "yes" || $OS_CYGWIN == "yes" || $OS_NONE == "yes") { + _START_GROUP=-Wl,--start-group + _END_GROUP=-Wl,--end-group + START_WHOLE_ARCHIVE_VALUE=-Wl,--whole-archive + END_WHOLE_ARCHIVE_VALUE=-Wl,--no-whole-archive + LD_STRIP_FLAG=-s + _SONAME_OPTION=-soname + _LD_SRCS_GLOBALS=-Wl,--whole-archive ${rootrel;ext=.a:SRCS_GLOBAL} -Wl,--no-whole-archive ${rootrel;ext=.o:SRCS_GLOBAL} ${rootrel;ext=.supp:SRCS_GLOBAL} +} + +when ($_LD_WHOLE_ARCHIVE == "yes") { +} + +when ($OS_DARWIN == "yes" || $OS_IOS == "yes") { + _SONAME_OPTION=-install_name +} + +_LD_LINKER_OUTPUT= +_LD_LINKER_OUTPUT_FLAG=--linker-output ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION.linker.txt:REALPRJNAME} + +# Enable section-level DCE (dead code elimination): +# remove whole unused code and data sections +# (needs `-ffunction-sections` and `-fdata-sections` to be useful) +# +# NOTE: CGO linker doesn't seem to support DCE, but shares common LDFLAGS +_LD_DCE_FLAG_GC_SECTIONS= +_LD_DCE_FLAG_PRINT_SECTIONS= +when ($OS_DARWIN == "yes") { + _LD_DCE_FLAG_GC_SECTIONS=-Wl,-dead_strip +} +elsewhen ($OS_LINUX == "yes" || $OS_ANDROID == "yes") { + _LD_DCE_FLAG_GC_SECTIONS=-Wl,--gc-sections + when ($LINKER_DCE_PRINT_SECTIONS == "yes") { + _LD_DCE_FLAG_PRINT_SECTIONS=-Wl,--print-gc-sections + _LD_LINKER_OUTPUT=$_LD_LINKER_OUTPUT_FLAG + } +} +LD_DCE_FLAG = +LD_DCE_FLAG+=$_LD_DCE_FLAG_GC_SECTIONS +LD_DCE_FLAG+=$_LD_DCE_FLAG_PRINT_SECTIONS +DCE_FLAG= + +_LD_ICF_FLAG= +_LD_ICF_FLAG_PRINT_SECTIONS= +when ($_DEFAULT_LINKER_ID == "lld") { + # Enable ICF (identical code folding pass) in safe mode + # https://research.google/pubs/pub36912/ + _LD_ICF_FLAG=-Wl,-icf=safe + when ($LINKER_ICF_PRINT_SECTIONS == "yes") { + _LD_ICF_FLAG_PRINT_SECTIONS=-Wl,--print-icf-sections + _LD_LINKER_OUTPUT=$_LD_LINKER_OUTPUT_FLAG + } +} +LD_ICF_FLAG = +LD_ICF_FLAG+=$_LD_ICF_FLAG +LD_ICF_FLAG+=$_LD_ICF_FLAG_PRINT_SECTIONS +ICF_FLAG= + +STRIP_FLAG= + +C_LIBRARY_PATH= +C_SYSTEM_LIBRARIES_INTERCEPT= + +_LD_THREAD_LIBRARY= +when ($OS_LINUX == "yes" || $OS_DARWIN == "yes") { + _LD_THREAD_LIBRARY=-lpthread +} + +_LD_USE_STDLIB= +when ($_BUILD_COVERAGE == "yes" || $GCOV_COVERAGE == "yes" || $CLANG_COVERAGE == "yes" || $_BUILD_SANITIZED == "yes") { + _LD_USE_STDLIB= +} +elsewhen ($OS_ANDROID == "yes") { + when ($_ANDROID_NDK_VERSION_LESS_THEN_23 == "yes") { + # Preserve old behaviour: specify runtime libs manually + _LD_USE_STDLIB=-nodefaultlibs + } + otherwise { + # Use toolchain defaults to link with libunwind/clang_rt.builtins + _LD_USE_STDLIB=-nostdlib++ + } +} +elsewhen ($OS_LINUX == "yes" || $OS_DARWIN == "yes" || $OS_IOS == "yes") { + _LD_USE_STDLIB=-nodefaultlibs +} + +_C_SYSTEM_LIBRARIES=$_LD_USE_STDLIB $_LD_THREAD_LIBRARY $_LD_SYS_LIB -lc +when ($MUSL == "yes") { + _C_SYSTEM_LIBRARIES=-nostdlib +} +C_SYSTEM_LIBRARIES=$_C_SYSTEM_LIBRARIES + +OBJADDE= + +LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG= +when ($OS_LINUX == "yes" || $OS_ANDROID == "yes") { + LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG=-rdynamic +} + +NO_EXPORT_DYNAMIC_SYMBOLS= +EXPORTS_VALUE=$LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG +when ($EXPORTS_FILE) { + EXPORTS_VALUE=$LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG -Wl,--version-script=${input:EXPORTS_FILE} +} +when ($NO_EXPORT_DYNAMIC_SYMBOLS == "yes") { + EXPORTS_VALUE= +} + +LINKER_SCRIPT_VALUE=${ext=.ld;pre=-T:SRCS_GLOBAL} + +_LINKER_TIME_TRACE_GRANULARITY=500 +when ($TIME_TRACE_GRANULARITY && $TIME_TRACE_GRANULARITY != "") { + _LINKER_TIME_TRACE_GRANULARITY=$TIME_TRACE_GRANULARITY +} + +_LINKER_TIME_TRACE_FLAG= +when (($TIME_TRACE == "yes" || $LINKER_TIME_TRACE == "yes") && $_DEFAULT_LINKER_ID == "lld") { + _LINKER_TIME_TRACE_FLAG=\ +-Wl,--time-trace \ +-Wl,--time-trace-granularity=$_LINKER_TIME_TRACE_GRANULARITY \ +-Wl,--time-trace-file=${output;rootrel;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.time_trace.json:REALPRJNAME} +} + +_EXE_FLAGS=\ +$C_FLAGS_PLATFORM \ +$BEFORE_PEERS \ +$_START_GROUP \ +${rootrel:PEERS} \ +$_END_GROUP \ +$AFTER_PEERS \ +$EXPORTS_VALUE \ +$LINKER_SCRIPT_VALUE \ +$LDFLAGS \ +$LDFLAGS_GLOBAL \ +$OBJADDE \ +$OBJADDE_LIB \ +$C_LIBRARY_PATH \ +$C_SYSTEM_LIBRARIES_INTERCEPT \ +$C_SYSTEM_LIBRARIES \ +$STRIP_FLAG \ +$DCE_FLAG \ +$ICF_FLAG \ +$_LINKER_TIME_TRACE_FLAG + +_SONAME_FLAG=-Wl,$_SONAME_OPTION,$_SONAME +_SHARED_FLAG=-shared +_EXEC_SHARED_FLAG= +when ($OS_LINUX == "yes") { + _EXEC_SHARED_FLAG=-pie -fPIE -Wl,--unresolved-symbols=ignore-all -rdynamic +} + +_LD_ENV_STYLE=${cwd:ARCADIA_BUILD_ROOT} $TOOLCHAIN_ENV ${kv;hide:"p LD"} ${requirements;hide:LD_REQUIREMENTS} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} + +# Program +GENERATE_MF_CMD=\ +$YMAKE_PYTHON ${input:"build/scripts/generate_mf.py"} \ +--build-root $ARCADIA_BUILD_ROOT \ +--module-name $REALPRJNAME \ +-o ${output;rootrel;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mf:REALPRJNAME} \ +-t $MODULE_TYPE \ +--ya-start-command-file \ +-Ya,lics $LICENSE_NAMES \ +-Ya,peers ${rootrel:PEERS} \ +-Ya,credits ${input:CREDITS_TEXTS_FILE} $CREDITS_FLAGS \ +--ya-end-command-file + +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+=\ +${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ +${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ +$_LD_ARCH_FLAG \ +$LINK_SCRIPT_EXE_FLAGS \ +$CXX_COMPILER \ +$_LD_SRCS_GLOBALS \ +$VCS_C_OBJ $AUTO_INPUT -o $TARGET \ +$_EXE_FLAGS \ +$_LD_ENV_STYLE + +REAL_LINK_EXE_TIDY=\ +$YMAKE_PYTHON ${input:"build/scripts/clang_tidy_arch.py"} \ +--build-root $ARCADIA_BUILD_ROOT \ +--source-root $ARCADIA_ROOT \ +--output-file $TARGET \ +$AUTO_INPUT \ +$_LD_ENV_STYLE + +# Executable Shared Library + +REAL_LINK_EXEC_DYN_LIB_CMDLINE =\ +$YMAKE_PYTHON ${input:"build/scripts/link_dyn_lib.py"} \ +--target $TARGET +REAL_LINK_EXEC_DYN_LIB_CMDLINE+=$_LD_LINKER_OUTPUT +REAL_LINK_EXEC_DYN_LIB_CMDLINE+=\ +${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ +${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ +$_LD_ARCH_FLAG \ +$LINK_DYN_LIB_FLAGS \ +$CXX_COMPILER \ +$_LD_SRCS_GLOBALS \ +$VCS_C_OBJ $AUTO_INPUT -o $TARGET \ +$_EXEC_SHARED_FLAG \ +$_SONAME_FLAG \ +$_EXE_FLAGS \ +$_LD_ENV_STYLE + +REAL_LINK_EXEC_DYN_LIB=$REAL_LINK_EXEC_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +# Shared Library + +LINK_DYN_LIB_FLAGS= + +REAL_LINK_DYN_LIB_CMDLINE =\ +$YMAKE_PYTHON ${input:"build/scripts/link_dyn_lib.py"} \ +--target $TARGET +REAL_LINK_DYN_LIB_CMDLINE+=$_LD_LINKER_OUTPUT +REAL_LINK_DYN_LIB_CMDLINE+=\ +${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ +${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ +$_LD_ARCH_FLAG \ +$LINK_DYN_LIB_FLAGS \ +$CXX_COMPILER \ +$_LD_SRCS_GLOBALS \ +$VCS_C_OBJ $AUTO_INPUT -o $TARGET \ +$_SHARED_FLAG \ +$_SONAME_FLAG \ +$_EXE_FLAGS \ +$_LD_ENV_STYLE + +REAL_LINK_DYN_LIB=$REAL_LINK_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +_DWARF_COMMAND= +when ($OS_DARWIN == "yes" && $NO_DEBUGINFO != "yes") { + _DWARF_COMMAND=$DWARF_TOOL $TARGET -o ${output;pre=$MODULE_PREFIX$REALPRJNAME.dSYM/Contents/Resources/DWARF/$MODULE_PREFIX:REALPRJNAME} $_LD_ENV_STYLE +} +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 +when ($TIDY == "yes") { + _REAL_LINK_EXE=$REAL_LINK_EXE_TIDY + _LINK_EXE=$REAL_LINK_EXE + _LINK_DYN_LIB=$REAL_LINK_EXE +} +REAL_LINK_EXE=$_REAL_LINK_EXE +LINK_EXE=$_LINK_EXE +LINK_DYN_LIB=$_LINK_DYN_LIB + +LINK_EXEC_DYN_LIB=\ +$GENERATE_MF && \ +$GENERATE_VCS_C_INFO_NODEP && \ +$REAL_LINK_EXEC_DYN_LIB && \ +$DWARF_COMMAND && \ +$LINK_ADDITIONAL_SECTIONS_COMMAND + +SWIG_DLL_JAR_CMD=\ +$GENERATE_MF && \ +$GENERATE_VCS_C_INFO_NODEP && \ +$REAL_SWIG_DLL_JAR_CMD && \ +$DWARF_COMMAND + +_LD_TAIL_LINK_LIB=$AUTO_INPUT ${requirements;hide:LIB_REQUIREMENTS} ${kv;hide:"p AR"} $TOOLCHAIN_ENV ${kv;hide:"pc light-red"} ${kv;hide:"show_out"} +_LD_ARCHIVER=$YMAKE_PYTHON ${input:"build/scripts/link_lib.py"} ${quo:AR_TOOL} $AR_TYPE $_LD_LLVM_AR_FORMAT $ARCADIA_BUILD_ROOT $_LD_AR_PLUGIN +_LD_LIB_GENERATE_MF=$GENERATE_MF && +when ($TIDY == "yes") { + _LD_ARCHIVER=$YMAKE_PYTHON ${input:"build/scripts/clang_tidy_arch.py"} --source-root $ARCADIA_ROOT --build-root $ARCADIA_BUILD_ROOT --output-file + _LD_LIB_GENERATE_MF= +} +LINK_LIB=$_LD_LIB_GENERATE_MF $_LD_ARCHIVER $TARGET $_LD_TAIL_LINK_LIB +GLOBAL_LINK_LIB=$_LD_ARCHIVER $GLOBAL_TARGET $_LD_TAIL_LINK_LIB + +# "Fat Object" : pre-linked global objects and static library with all dependencies +_LD_LINK_FAT_PREFIX=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $YMAKE_PYTHON ${input:"build/scripts/link_fat_obj.py"} --build-root $ARCADIA_BUILD_ROOT +_LD_LINK_FAT_SRCS_GLOBALS_WA=$_LD_SRCS_GLOBALS +_LD_LINK_FAT_SRCS_GLOBALS_NO_WA=${rootrel;ext=.a:SRCS_GLOBAL} ${rootrel;ext=.o:SRCS_GLOBAL} + +_LD_LINK_FAT_SUFFIX1=$_LD_ARCH_FLAG \ +-Ya,input $AUTO_INPUT $VCS_C_OBJ \ +-Ya,global_srcs + +_LD_LINK_FAT_SUFFIX2=-Ya,peers $PEERS \ +-Ya,linker $CXX_COMPILER \ +$LDFLAGS_GLOBAL $C_FLAGS_PLATFORM $LD_SDK_VERSION \ +-Ya,archiver $_LD_ARCHIVER \ +$TOOLCHAIN_ENV ${kv;hide:"p LD"} ${requirements;hide:LD_REQUIREMENTS} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} + +LINK_FAT_OBJECT=\ +$_LD_LINK_FAT_PREFIX \ +--obj=$TARGET --lib=${output:REALPRJNAME.a} \ +$_LD_LINK_FAT_SUFFIX1 \ +$_LD_LINK_FAT_SRCS_GLOBALS_WA \ +$_LD_LINK_FAT_SUFFIX2 + +LINK_RECURSIVE_LIBRARY=\ +$_LD_LINK_FAT_PREFIX \ +--lib=$TARGET --with-own-obj --with-global-srcs \ +$_LD_LINK_FAT_SUFFIX1 \ +$_LD_LINK_FAT_SRCS_GLOBALS_NO_WA \ +$_LD_LINK_FAT_SUFFIX2 + +LINK_FAT_OBJECT_LIBRARY=\ +$_LD_LINK_FAT_PREFIX \ +--lib=$TARGET $FAT_OBJECT_ARGS $FAT_OBJECT_OUTS \ +$_LD_LINK_FAT_SUFFIX1 \ +$_LD_LINK_FAT_SRCS_GLOBALS_NO_WA \ +$_LD_LINK_FAT_SUFFIX2 + +LIBRT=-lrt +MD5LIB=-lcrypt +LIBRESOLV= +when ($OS_LINUX || $OS_DARWIN || $OS_ANDROID) { + LIBRESOLV=-lresolv +} +PROFFLAG=-pg diff --git a/build/conf/linkers/msvc_linker.conf b/build/conf/linkers/msvc_linker.conf new file mode 100644 index 0000000000..e905024bda --- /dev/null +++ b/build/conf/linkers/msvc_linker.conf @@ -0,0 +1,271 @@ +_MSVC_ARCH= +when ($ARCH_I386 == "yes" || $ARCH_I686 == "yes") { + _MSVC_ARCH=x86 +} +elsewhen ($ARCH_X86_64 == "yes") { + _MSVC_ARCH=x64 +} +elsewhen ($ARCH_ARM == "yes") { + _MSVC_ARCH=arm +} + +_FLAGS_MACHINE=/MACHINE:${toupper:_MSVC_ARCH} + +_FLAGS_IGNORE=/IGNORE:4221 + +_FLAGS_COMMON_IDE_MSVS= +when ($IDE_MSVS == "yes") { + _FLAGS_COMMON_IDE_MSVS=/INCREMENTAL +} +otherwise { + _FLAGS_COMMON_IDE_MSVS=/INCREMENTAL:NO +} + +# TODO(nslus): DEVTOOLS-1868 remove restriction. +_FLAGS_DEBUG_ONLY_DEBUG= +_FLAGS_RELEASE_ONLY_DEBUG= +_FLAGS_COMMON_DEBUG= +when (!$NO_DEBUGINFO || $NO_DEBUGINFO == "no" || $NO_DEBUGINFO == "0") { + when ($IDE_MSVS == "yes") { + when ($CLANG_CL == "yes") { + _FLAGS_DEBUG_ONLY_DEBUG=/DEBUG + } + otherwise { + _FLAGS_DEBUG_ONLY_DEBUG=/DEBUG:FASTLINK + } + _FLAGS_RELEASE_ONLY_DEBUG=/DEBUG + } + otherwise { + _FLAGS_COMMON_DEBUG=/DEBUG + } +} + +_FLAGS_COMMON_LIBPATHS= +when ($IDE_MSVS != "yes") { + _FLAGS_COMMON_LIBPATHS=\ +/LIBPATH:"$_MSVC_TC_KIT_LIBS/um/$_MSVC_ARCH" \ +/LIBPATH:"$_MSVC_TC_KIT_LIBS/ucrt/$_MSVC_ARCH" \ +/LIBPATH:"$_MSVC_TC_VC_ROOT/lib/$_MSVC_ARCH" +} + +_FLAGS_COMMON =/NOLOGO /ERRORREPORT:PROMPT /SUBSYSTEM:CONSOLE /TLBID:1 $MSVC_DYNAMICBASE /NXCOMPAT +_FLAGS_COMMON+=$_FLAGS_IGNORE +_FLAGS_COMMON+=$_FLAGS_MACHINE +_FLAGS_COMMON+=$_FLAGS_COMMON_IDE_MSVS +_FLAGS_COMMON+=$_FLAGS_COMMON_DEBUG +_FLAGS_COMMON+=$_FLAGS_COMMON_LIBPATHS + +_FLAGS_DEBUG_ONLY_CLANG_CL= +when ($CLANG_CL == "yes") { + _FLAGS_DEBUG_ONLY_CLANG_CL=/STACK:4194304 +} + +_FLAGS_DEBUG_ONLY =$_FLAGS_DEBUG_ONLY_CLANG_CL +_FLAGS_DEBUG_ONLY+=$_FLAGS_DEBUG_ONLY_DEBUG +_FLAGS_RELEASE_ONLY =$_FLAGS_RELEASE_ONLY_DEBUG + +LINK_EXE_FLAGS_DEBUG =$_FLAGS_COMMON +LINK_EXE_FLAGS_DEBUG+=$_FLAGS_DEBUG_ONLY + +LINK_EXE_FLAGS_RELEASE =$_FLAGS_COMMON +LINK_EXE_FLAGS_RELEASE+=$_FLAGS_RELEASE_ONLY + +LINK_LIB_FLAGS=$_FLAGS_IGNORE $_FLAGS_MACHINE + +LINK_STDLIBS=\ +advapi32.lib \ +comdlg32.lib \ +crypt32.lib \ +dnsapi.lib \ +gdi32.lib \ +iphlpapi.lib \ +kernel32.lib \ +mswsock.lib \ +ole32.lib \ +oleaut32.lib \ +psapi.lib \ +rpcrt4.lib \ +secur32.lib \ +shell32.lib \ +shlwapi.lib \ +user32.lib \ +userenv.lib \ +uuid.lib \ +version.lib \ +winmm.lib \ +winspool.lib \ +ws2_32.lib + +LDFLAGS_GLOBAL= +LDFLAGS= +OBJADDE= + +LINK_EXE_FLAGS=$LINK_EXE_FLAGS_PER_TYPE + +LINK_IMPLIB=/IMPLIB:${output;noext;rootrel;pre=$MODULE_PREFIX:REALPRJNAME.lib} +_LINK_EXTRA_OUTPUT= +when (!$NO_DEBUGINFO || $NO_DEBUGINFO == "no" || $NO_DEBUGINFO == "0") { + _LINK_EXTRA_OUTPUT=/PDB:${output;noext;rootrel;pre=$MODULE_PREFIX:REALPRJNAME.pdb} +} +LINK_EXTRA_OUTPUT=$_LINK_EXTRA_OUTPUT + +LIB_WRAPPER=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} lib +LINK_WRAPPER=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} link +when ($_UNDER_WINE == "yes") { + LIB_WRAPPER= + LINK_WRAPPER= +} + +LINK_WRAPPER_DYNLIB=${YMAKE_PYTHON} ${input:"build/scripts/link_dyn_lib.py"} --arch WINDOWS --target $TARGET + +EXPORTS_VALUE= +LINK_IMPLIB_VALUE= +when ($EXPORTS_FILE) { + LINK_IMPLIB_VALUE=$LINK_IMPLIB + EXPORTS_VALUE=/DEF:${input:EXPORTS_FILE} +} + +GENERATE_MF_CMD=\ +$YMAKE_PYTHON ${input:"build/scripts/generate_mf.py"} \ +--build-root $ARCADIA_BUILD_ROOT \ +--module-name $REALPRJNAME \ +-o ${output;rootrel;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mf:REALPRJNAME} \ +-t $MODULE_TYPE \ +--ya-start-command-file \ +-Ya,lics $LICENSE_NAMES \ +-Ya,peers ${rootrel:PEERS} \ +-Ya,credits ${input:CREDITS_TEXTS_FILE} $CREDITS_FLAGS \ +--ya-end-command-file + +# we split srcs_global into two groups: libs and objs +# # each group can be in its own command file +# first group need /WHOLEARCHIVE: prefix which will be added in fix_msvc_output.py or run_msvc_wine.py +# the tail of link commands will be added in the third command file +_MSVC_SRCS_GLOBALS=\ +--start-wa --ya-start-command-file ${qe;rootrel;ext=.lib:SRCS_GLOBAL} --ya-end-command-file --end-wa \ +--ya-start-command-file ${qe;rootrel;ext=.obj:SRCS_GLOBAL} --ya-end-command-file + +REAL_LINK_DYN_LIB_CMDLINE=\ +${TOOLCHAIN_ENV} \ +${cwd:ARCADIA_BUILD_ROOT} \ +${LINK_WRAPPER} \ +${LINK_WRAPPER_DYNLIB} \ +${LINK_EXE_CMD} \ +${LINK_IMPLIB_VALUE} \ +/DLL \ +/OUT:${qe;rootrel:TARGET} \ +${LINK_EXTRA_OUTPUT} \ +${EXPORTS_VALUE} \ +${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ +${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ +$_MSVC_SRCS_GLOBALS \ +--ya-start-command-file \ +${VCS_C_OBJ_RR} \ +${qe;rootrel:AUTO_INPUT} \ +${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \ +$LINK_EXE_FLAGS \ +$LINK_STDLIBS $LDFLAGS \ +$LDFLAGS_GLOBAL \ +$OBJADDE \ +--ya-end-command-file + +REAL_LINK_DYN_LIB=$REAL_LINK_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +SWIG_DLL_JAR_CMD=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_SWIG_DLL_JAR_CMD + +_MSVC_HEAD_LINK_LIB=${TOOLCHAIN_ENV} ${cwd:ARCADIA_BUILD_ROOT} ${LIB_WRAPPER} ${LINK_LIB_CMD} +_MSVC_TAIL_LINK_LIB=\ +--ya-start-command-file \ +${qe;rootrel:AUTO_INPUT} \ +$LINK_LIB_FLAGS \ +--ya-end-command-file \ +${requirements;hide:LIB_REQUIREMENTS} ${hide;kv:"soe"} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"} + +LINK_LIB=${GENERATE_MF} && $_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:TARGET} $_MSVC_TAIL_LINK_LIB +GLOBAL_LINK_LIB=$_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:GLOBAL_TARGET} $_MSVC_TAIL_LINK_LIB + +LINK_EXE_CMDLINE=\ +${GENERATE_MF} && \ +$GENERATE_VCS_C_INFO_NODEP && \ +${TOOLCHAIN_ENV} \ +${cwd:ARCADIA_BUILD_ROOT} \ +${LINK_WRAPPER} \ +${LINK_EXE_CMD} \ +/OUT:${qe;rootrel:TARGET} \ +${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ +${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ +${LINK_EXTRA_OUTPUT} \ +$_MSVC_SRCS_GLOBALS \ +--ya-start-command-file \ +${VCS_C_OBJ_RR} \ +${qe;rootrel:AUTO_INPUT} \ +$LINK_EXE_FLAGS \ +$LINK_STDLIBS \ +$LDFLAGS \ +$LDFLAGS_GLOBAL \ +$OBJADDE \ +${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \ +--ya-end-command-file \ +${hide;kv:"soe"} ${hide;kv:"p LD"} ${requirements;hide:LD_REQUIREMENTS} ${hide;kv:"pc blue"} + +LINK_EXE=$LINK_EXE_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +LINK_DYN_LIB=${GENERATE_MF} && $GENERATE_VCS_C_INFO_NODEP && $REAL_LINK_DYN_LIB ${hide;kv:"soe"} ${hide;kv:"p LD"} ${requirements;hide:LD_REQUIREMENTS} ${hide;kv:"pc blue"} + +LINK_EXEC_DYN_LIB_CMDLINE=\ +${GENERATE_MF} && \ +$GENERATE_VCS_C_INFO_NODEP && \ +${TOOLCHAIN_ENV} \ +${cwd:ARCADIA_BUILD_ROOT} \ +${LINK_WRAPPER} \ +${LINK_WRAPPER_DYNLIB} \ +${LINK_EXE_CMD} \ +/OUT:${qe;rootrel:TARGET} \ +${LINK_EXTRA_OUTPUT} \ +${EXPORTS_VALUE} \ +${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \ +${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \ +$_MSVC_SRCS_GLOBALS \ +'--ya-start-command-file \ +${VCS_C_OBJ_RR} \ +${qe;rootrel:AUTO_INPUT} \ +${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \ +$LINK_EXE_FLAGS \ +$LINK_STDLIBS \ +$LDFLAGS $LDFLAGS_GLOBAL \ +$OBJADDE \ +--ya-end-command-file \ +${hide;kv:"soe"} ${hide;kv:"p LD"} ${requirements;hide:LD_REQUIREMENTS} ${hide;kv:"pc blue"} + +LINK_EXEC_DYN_LIB=$LINK_EXEC_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE) + +LINK_GLOBAL_FAT_OBJECT=\ +${TOOLCHAIN_ENV} \ +${cwd:ARCADIA_BUILD_ROOT} \ +${LIB_WRAPPER} \ +${LINK_LIB_CMD} \ +/OUT:${qe;rootrel:TARGET} \ +--ya-start-command-file \ +${qe;rootrel;ext=.lib:SRCS_GLOBAL} \ +${qe;rootrel;ext=.obj:SRCS_GLOBAL} \ +${qe;rootrel:AUTO_INPUT} \ +$LINK_LIB_FLAGS \ +--ya-end-command-file + +LINK_PEERS_FAT_OBJECT=\ +${TOOLCHAIN_ENV} \ +${cwd:ARCADIA_BUILD_ROOT} \ +${LIB_WRAPPER} \ +${LINK_LIB_CMD} \ +/OUT:${qe;rootrel;output:REALPRJNAME.lib} \ +--ya-start-command-file \ +${qe;rootrel:PEERS} \ +$LINK_LIB_FLAGS \ +--ya-end-command-file + +LINK_FAT_OBJECT=\ +${GENERATE_MF} && \ +$GENERATE_VCS_C_INFO_NODEP && \ +$LINK_GLOBAL_FAT_OBJECT && \ +$LINK_PEERS_FAT_OBJECT \ +${kv;hide:"p LD"} ${requirements;hide:LD_REQUIREMENTS} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} |