msvc_linker.conf 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. LINK_EXE_CMD=${_WINE_LINK_PREFIX} ${_MSVC_LINK}
  2. LINK_LIB_CMD=${_WINE_LIB_PREFIX} ${_MSVC_LIB}
  3. _MSVC_ARCH=
  4. when ($ARCH_I386 == "yes" || $ARCH_I686 == "yes") {
  5. _MSVC_ARCH=x86
  6. }
  7. elsewhen ($ARCH_X86_64 == "yes") {
  8. _MSVC_ARCH=x64
  9. }
  10. elsewhen ($ARCH_ARM == "yes") {
  11. _MSVC_ARCH=arm
  12. }
  13. _FLAGS_MACHINE=/MACHINE:${toupper:_MSVC_ARCH}
  14. _FLAGS_IGNORE=/IGNORE:4221
  15. _FLAGS_COMMON_IDE_MSVS=
  16. when ($IDE_MSVS == "yes") {
  17. _FLAGS_COMMON_IDE_MSVS=/INCREMENTAL
  18. }
  19. otherwise {
  20. _FLAGS_COMMON_IDE_MSVS=/INCREMENTAL:NO
  21. }
  22. # TODO(nslus): DEVTOOLS-1868 remove restriction.
  23. _FLAGS_DEBUG_ONLY_DEBUG=
  24. _FLAGS_RELEASE_ONLY_DEBUG=
  25. _FLAGS_COMMON_DEBUG=
  26. when (!$NO_DEBUGINFO || $NO_DEBUGINFO == "no" || $NO_DEBUGINFO == "0") {
  27. when ($IDE_MSVS == "yes") {
  28. when ($CLANG_CL == "yes") {
  29. _FLAGS_DEBUG_ONLY_DEBUG=/DEBUG
  30. }
  31. otherwise {
  32. _FLAGS_DEBUG_ONLY_DEBUG=/DEBUG:FASTLINK
  33. }
  34. _FLAGS_RELEASE_ONLY_DEBUG=/DEBUG
  35. }
  36. otherwise {
  37. _FLAGS_COMMON_DEBUG=/DEBUG
  38. }
  39. }
  40. _FLAGS_COMMON_LIBPATHS=
  41. when ($IDE_MSVS != "yes") {
  42. _FLAGS_COMMON_LIBPATHS=\
  43. /LIBPATH:\""${_MSVC_TC_KIT_LIBS}/um/$_MSVC_ARCH"\" \
  44. /LIBPATH:\""${_MSVC_TC_KIT_LIBS}/ucrt/$_MSVC_ARCH"\" \
  45. /LIBPATH:\""${_MSVC_TC_VC_ROOT}/lib/$_MSVC_ARCH"\"
  46. }
  47. _FLAGS_COMMON =/NOLOGO /ERRORREPORT:PROMPT /SUBSYSTEM:CONSOLE /TLBID:1 $MSVC_DYNAMICBASE /NXCOMPAT
  48. _FLAGS_COMMON+=$_FLAGS_IGNORE
  49. _FLAGS_COMMON+=$_FLAGS_MACHINE
  50. _FLAGS_COMMON+=$_FLAGS_COMMON_IDE_MSVS
  51. _FLAGS_COMMON+=$_FLAGS_COMMON_DEBUG
  52. _FLAGS_COMMON+=$_FLAGS_COMMON_LIBPATHS
  53. _FLAGS_DEBUG_ONLY_CLANG_CL=
  54. when ($CLANG_CL == "yes") {
  55. _FLAGS_DEBUG_ONLY_CLANG_CL=/STACK:4194304
  56. }
  57. _FLAGS_DEBUG_ONLY =$_FLAGS_DEBUG_ONLY_CLANG_CL
  58. _FLAGS_DEBUG_ONLY+=$_FLAGS_DEBUG_ONLY_DEBUG
  59. _FLAGS_RELEASE_ONLY =$_FLAGS_RELEASE_ONLY_DEBUG
  60. LINK_EXE_FLAGS_DEBUG =$_FLAGS_COMMON
  61. LINK_EXE_FLAGS_DEBUG+=$_FLAGS_DEBUG_ONLY
  62. LINK_EXE_FLAGS_RELEASE =$_FLAGS_COMMON
  63. LINK_EXE_FLAGS_RELEASE+=$_FLAGS_RELEASE_ONLY
  64. LINK_LIB_FLAGS=$_FLAGS_IGNORE $_FLAGS_MACHINE
  65. LINK_STDLIBS=\
  66. advapi32.lib \
  67. comdlg32.lib \
  68. crypt32.lib \
  69. dnsapi.lib \
  70. gdi32.lib \
  71. iphlpapi.lib \
  72. kernel32.lib \
  73. mswsock.lib \
  74. ole32.lib \
  75. oleaut32.lib \
  76. psapi.lib \
  77. rpcrt4.lib \
  78. secur32.lib \
  79. shell32.lib \
  80. shlwapi.lib \
  81. user32.lib \
  82. userenv.lib \
  83. uuid.lib \
  84. version.lib \
  85. winmm.lib \
  86. winspool.lib \
  87. ws2_32.lib
  88. LINK_EXE_FLAGS=$LINK_EXE_FLAGS_PER_TYPE
  89. LINK_EXE_VFS_FLAGS=
  90. when ($_UNDER_WINE_LINK != "yes" && $USE_MSVC_LINKER != "yes") {
  91. LINK_EXE_VFS_FLAGS=/vfsoverlay:${BINDIR}/vfsoverlay.yaml
  92. }
  93. LINK_EXE_FLAGS+=${LINK_EXE_VFS_FLAGS}
  94. GENERATE_COMMON_LIB_VFS_CMD=\
  95. ${YMAKE_PYTHON3} ${input:"build/scripts/generate_win_vfs.py"} \
  96. ${BINDIR} \
  97. ${_FLAGS_COMMON_LIBPATHS}
  98. GENERATE_COMMON_LIB_VFS=
  99. when ($_UNDER_WINE_LINK != "yes" && $USE_MSVC_LINKER != "yes") {
  100. GENERATE_COMMON_LIB_VFS=${GENERATE_COMMON_LIB_VFS_CMD}
  101. }
  102. LINK_IMPLIB=/IMPLIB:${rootrel;output;pre=$MODULE_PREFIX;suf=.lib;noext:REALPRJNAME}
  103. _LINK_EXTRA_OUTPUT=
  104. when (!$NO_DEBUGINFO || $NO_DEBUGINFO == "no" || $NO_DEBUGINFO == "0") {
  105. _LINK_EXTRA_OUTPUT=/PDB:${rootrel;output;pre=$MODULE_PREFIX;suf=.pdb;noext:REALPRJNAME}
  106. }
  107. LINK_EXTRA_OUTPUT=$_LINK_EXTRA_OUTPUT
  108. LIB_WRAPPER=${FIX_MSVC_OUTPUT} lib
  109. LINK_WRAPPER=${FIX_MSVC_OUTPUT} link
  110. when ($_UNDER_WINE_LINK == "yes") {
  111. LINK_WRAPPER=
  112. }
  113. when ($_UNDER_WINE_LIB == "yes") {
  114. LIB_WRAPPER=
  115. }
  116. LINK_WRAPPER_DYNLIB=\
  117. ${YMAKE_PYTHON} ${input:"build/scripts/link_dyn_lib.py"} ${hide;input:"build/scripts/fix_py2_protobuf.py"} \
  118. --arch WINDOWS \
  119. --target $TARGET
  120. EXPORTS_VALUE=
  121. LINK_IMPLIB_VALUE=
  122. when ($EXPORTS_FILE) {
  123. LINK_IMPLIB_VALUE=$LINK_IMPLIB
  124. EXPORTS_VALUE=/DEF:${input:EXPORTS_FILE}
  125. }
  126. GENERATE_MF_CMD=\
  127. $YMAKE_PYTHON ${input:"build/scripts/generate_mf.py"} ${hide;input:"build/scripts/process_command_files.py"} \
  128. --build-root $ARCADIA_BUILD_ROOT \
  129. --module-name $REALPRJNAME \
  130. -o ${rootrel;output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mf:REALPRJNAME} \
  131. -t $MODULE_TYPE \
  132. --ya-start-command-file \
  133. -Ya,lics $LICENSE_NAMES \
  134. -Ya,peers ${rootrel:PEERS} \
  135. -Ya,credits ${input:CREDITS_TEXTS_FILE} $CREDITS_FLAGS \
  136. --ya-end-command-file
  137. _EXTRA_OBJS=
  138. _GENERATE_EXTRA_OBJS=
  139. # we split srcs_global into two groups: libs and objs
  140. # # each group can be in its own command file
  141. # first group need /WHOLEARCHIVE: prefix which will be added in fix_msvc_output.py or run_msvc_wine.py
  142. # the tail of link commands will be added in the third command file
  143. _MSVC_SRCS_GLOBALS=\
  144. --start-wa --ya-start-command-file ${qe;rootrel;ext=.lib:SRCS_GLOBAL} --ya-end-command-file --end-wa \
  145. --ya-start-command-file ${qe;rootrel;ext=.obj:SRCS_GLOBAL} --ya-end-command-file
  146. REAL_LINK_DYN_LIB_CMDLINE=\
  147. ${GENERATE_COMMON_LIB_VFS} && \
  148. ${TOOLCHAIN_ENV} \
  149. ${cwd:ARCADIA_BUILD_ROOT} \
  150. ${LINK_WRAPPER} \
  151. ${LINK_WRAPPER_DYNLIB} \
  152. ${LINK_EXE_CMD} \
  153. ${LINK_IMPLIB_VALUE} \
  154. /DLL \
  155. /OUT:${qe;rootrel:TARGET} \
  156. ${LINK_EXTRA_OUTPUT} \
  157. ${EXPORTS_VALUE} \
  158. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  159. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  160. $_MSVC_SRCS_GLOBALS \
  161. --ya-start-command-file \
  162. ${VCS_C_OBJ_RR} \
  163. ${qe;rootrel:AUTO_INPUT} \
  164. ${qe;rootrel;ext=.lib;tags_cut:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib;tags_cut:PEERS} \
  165. $LINK_EXE_FLAGS \
  166. $LINK_STDLIBS $LDFLAGS \
  167. $LDFLAGS_GLOBAL \
  168. $OBJADDE \
  169. --ya-end-command-file
  170. REAL_LINK_DYN_LIB=$REAL_LINK_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  171. SWIG_DLL_JAR_CMD=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_SWIG_DLL_JAR_CMD
  172. _MSVC_HEAD_LINK_LIB=${TOOLCHAIN_ENV} ${cwd:ARCADIA_BUILD_ROOT} ${LIB_WRAPPER} ${LINK_LIB_CMD}
  173. _MSVC_TAIL_LINK_LIB=\
  174. --ya-start-command-file \
  175. ${qe;rootrel:AUTO_INPUT} \
  176. $LINK_LIB_FLAGS \
  177. --ya-end-command-file \
  178. ${hide;kv:"soe"} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"}
  179. LINK_LIB=${GENERATE_MF} && $_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:TARGET} $_MSVC_TAIL_LINK_LIB
  180. GLOBAL_LINK_LIB=$_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:GLOBAL_TARGET} $_MSVC_TAIL_LINK_LIB
  181. LINK_EXE_CMDLINE=\
  182. ${GENERATE_MF} && \
  183. ${_GENERATE_EXTRA_OBJS} && \
  184. $GENERATE_VCS_C_INFO_NODEP && \
  185. ${GENERATE_COMMON_LIB_VFS} && \
  186. ${TOOLCHAIN_ENV} \
  187. ${cwd:ARCADIA_BUILD_ROOT} \
  188. ${LINK_WRAPPER} \
  189. ${LINK_EXE_CMD} \
  190. /OUT:${qe;rootrel:TARGET} \
  191. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  192. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  193. ${LINK_EXTRA_OUTPUT} \
  194. $_MSVC_SRCS_GLOBALS \
  195. --ya-start-command-file \
  196. ${VCS_C_OBJ_RR} \
  197. ${_EXTRA_OBJS} \
  198. ${qe;rootrel:AUTO_INPUT} \
  199. $LINK_EXE_FLAGS \
  200. $LINK_STDLIBS \
  201. $LDFLAGS \
  202. $LDFLAGS_GLOBAL \
  203. $OBJADDE \
  204. ${qe;rootrel;ext=.lib;tags_cut:PEERS} ${qe;rootrel;suf=.lib;noext;ext=.dll;tags_cut:PEERS} \
  205. --ya-end-command-file \
  206. ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"}
  207. LINK_EXE=$LINK_EXE_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  208. LINK_DYN_LIB=${GENERATE_MF} && $GENERATE_VCS_C_INFO_NODEP && $REAL_LINK_DYN_LIB && ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"}
  209. LINK_EXEC_DYN_LIB_CMDLINE=\
  210. ${GENERATE_MF} && \
  211. $GENERATE_VCS_C_INFO_NODEP && \
  212. ${GENERATE_COMMON_LIB_VFS} && \
  213. ${TOOLCHAIN_ENV} \
  214. ${cwd:ARCADIA_BUILD_ROOT} \
  215. ${LINK_WRAPPER} \
  216. ${LINK_WRAPPER_DYNLIB} \
  217. ${LINK_EXE_CMD} \
  218. /OUT:${qe;rootrel:TARGET} \
  219. ${LINK_EXTRA_OUTPUT} \
  220. ${EXPORTS_VALUE} \
  221. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  222. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  223. $_MSVC_SRCS_GLOBALS \
  224. '--ya-start-command-file \
  225. ${VCS_C_OBJ_RR} \
  226. ${qe;rootrel:AUTO_INPUT} \
  227. ${qe;rootrel;ext=.lib;tags_cut:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib;tags_cut:PEERS} \
  228. $LINK_EXE_FLAGS \
  229. $LINK_STDLIBS \
  230. $LDFLAGS $LDFLAGS_GLOBAL \
  231. $OBJADDE \
  232. --ya-end-command-file \
  233. ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"}
  234. LINK_EXEC_DYN_LIB=$LINK_EXEC_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  235. macro PACK_GLOBALS_IN_LIBRARY() {
  236. ENABLE(UNUSED_MACRO)
  237. }
  238. LINK_GLOBAL_FAT_OBJECT=\
  239. ${TOOLCHAIN_ENV} \
  240. ${cwd:ARCADIA_BUILD_ROOT} \
  241. ${LIB_WRAPPER} \
  242. ${LINK_LIB_CMD} \
  243. /OUT:${qe;rootrel;output;suf=.global.lib:REALPRJNAME} \
  244. --ya-start-command-file \
  245. ${qe;rootrel;ext=.lib:SRCS_GLOBAL} \
  246. ${qe;rootrel;ext=.obj:SRCS_GLOBAL} \
  247. ${qe;rootrel:AUTO_INPUT} \
  248. $LINK_LIB_FLAGS \
  249. --ya-end-command-file
  250. LINK_PEERS_FAT_OBJECT=\
  251. ${TOOLCHAIN_ENV} \
  252. ${cwd:ARCADIA_BUILD_ROOT} \
  253. ${LIB_WRAPPER} \
  254. ${LINK_LIB_CMD} \
  255. /OUT:${qe;rootrel:TARGET} \
  256. --ya-start-command-file \
  257. ${qe;rootrel:PEERS} \
  258. $LINK_LIB_FLAGS \
  259. --ya-end-command-file
  260. LINK_FAT_OBJECT=\
  261. ${GENERATE_MF} && \
  262. $GENERATE_VCS_C_INFO_NODEP && \
  263. $LINK_GLOBAL_FAT_OBJECT && \
  264. $LINK_PEERS_FAT_OBJECT \
  265. ${hide;kv:"p LD"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}