msvc_linker.conf 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. LINK_EXE_CMD=${_WINE_LINK_PREFIX} ${_MSVC_LINK_OLD}
  2. LINK_LIB_CMD=${_WINE_LIB_PREFIX} ${_MSVC_LIB_OLD}
  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:\"${quo:_MSVC_TC_KIT_LIBS}/um/$_MSVC_ARCH\" \
  44. /LIBPATH:\"${quo:_MSVC_TC_KIT_LIBS}/ucrt/$_MSVC_ARCH\" \
  45. /LIBPATH:\"${quo:_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. LDFLAGS_GLOBAL=
  89. LDFLAGS=
  90. OBJADDE=
  91. OBJADDE_LIB=
  92. OBJADDE_LIB_GLOBAL=
  93. LINK_EXE_FLAGS=$LINK_EXE_FLAGS_PER_TYPE
  94. LINK_EXE_VFS_FLAGS=
  95. when ($_UNDER_WINE_LINK != "yes") {
  96. LINK_EXE_VFS_FLAGS=/vfsoverlay:${BINDIR}/vfsoverlay.yaml
  97. }
  98. LINK_EXE_FLAGS+=${LINK_EXE_VFS_FLAGS}
  99. GENERATE_COMMON_LIB_VFS_CMD=\
  100. ${YMAKE_PYTHON3} ${input:"build/scripts/generate_win_vfs.py"} \
  101. ${BINDIR} \
  102. ${_FLAGS_COMMON_LIBPATHS}
  103. GENERATE_COMMON_LIB_VFS=
  104. when ($_UNDER_WINE_LINK != "yes") {
  105. GENERATE_COMMON_LIB_VFS=${GENERATE_COMMON_LIB_VFS_CMD}
  106. }
  107. LINK_IMPLIB=/IMPLIB:${rootrel;output;pre=$MODULE_PREFIX;suf=.lib;noext:REALPRJNAME}
  108. _LINK_EXTRA_OUTPUT=
  109. when (!$NO_DEBUGINFO || $NO_DEBUGINFO == "no" || $NO_DEBUGINFO == "0") {
  110. _LINK_EXTRA_OUTPUT=/PDB:${rootrel;output;pre=$MODULE_PREFIX;suf=.pdb;noext:REALPRJNAME}
  111. }
  112. LINK_EXTRA_OUTPUT=$_LINK_EXTRA_OUTPUT
  113. LIB_WRAPPER=${FIX_MSVC_OUTPUT} lib
  114. LINK_WRAPPER=${FIX_MSVC_OUTPUT} link
  115. when ($_UNDER_WINE_LINK == "yes") {
  116. LINK_WRAPPER=
  117. }
  118. when ($_UNDER_WINE_LIB == "yes") {
  119. LIB_WRAPPER=
  120. }
  121. LINK_WRAPPER_DYNLIB=\
  122. ${YMAKE_PYTHON} ${input:"build/scripts/link_dyn_lib.py"} ${hide;input:"build/scripts/fix_py2_protobuf.py"} \
  123. --arch WINDOWS \
  124. --target $TARGET
  125. EXPORTS_VALUE=
  126. LINK_IMPLIB_VALUE=
  127. when ($EXPORTS_FILE) {
  128. LINK_IMPLIB_VALUE=$LINK_IMPLIB
  129. EXPORTS_VALUE=/DEF:${input:EXPORTS_FILE}
  130. }
  131. GENERATE_MF_CMD=\
  132. $YMAKE_PYTHON ${input:"build/scripts/generate_mf.py"} ${hide;input:"build/scripts/process_command_files.py"} \
  133. --build-root $ARCADIA_BUILD_ROOT \
  134. --module-name $REALPRJNAME \
  135. -o ${rootrel;output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mf:REALPRJNAME} \
  136. -t $MODULE_TYPE \
  137. --ya-start-command-file \
  138. -Ya,lics $LICENSE_NAMES \
  139. -Ya,peers ${rootrel:PEERS} \
  140. -Ya,credits ${input:CREDITS_TEXTS_FILE} $CREDITS_FLAGS \
  141. --ya-end-command-file
  142. _EXTRA_OBJS=
  143. _GENERATE_EXTRA_OBJS=
  144. # we split srcs_global into two groups: libs and objs
  145. # # each group can be in its own command file
  146. # first group need /WHOLEARCHIVE: prefix which will be added in fix_msvc_output.py or run_msvc_wine.py
  147. # the tail of link commands will be added in the third command file
  148. _MSVC_SRCS_GLOBALS=\
  149. --start-wa --ya-start-command-file ${qe;rootrel;ext=.lib:SRCS_GLOBAL} --ya-end-command-file --end-wa \
  150. --ya-start-command-file ${qe;rootrel;ext=.obj:SRCS_GLOBAL} --ya-end-command-file
  151. REAL_LINK_DYN_LIB_CMDLINE=\
  152. ${GENERATE_COMMON_LIB_VFS} && \
  153. ${TOOLCHAIN_ENV} \
  154. ${cwd:ARCADIA_BUILD_ROOT} \
  155. ${LINK_WRAPPER} \
  156. ${LINK_WRAPPER_DYNLIB} \
  157. ${LINK_EXE_CMD} \
  158. ${LINK_IMPLIB_VALUE} \
  159. /DLL \
  160. /OUT:${qe;rootrel:TARGET} \
  161. ${LINK_EXTRA_OUTPUT} \
  162. ${EXPORTS_VALUE} \
  163. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  164. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  165. $_MSVC_SRCS_GLOBALS \
  166. --ya-start-command-file \
  167. ${VCS_C_OBJ_RR} \
  168. ${qe;rootrel:AUTO_INPUT} \
  169. ${qe;rootrel;ext=.lib;tags_cut:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib;tags_cut:PEERS} \
  170. $LINK_EXE_FLAGS \
  171. $LINK_STDLIBS $LDFLAGS \
  172. $LDFLAGS_GLOBAL \
  173. $OBJADDE \
  174. --ya-end-command-file
  175. REAL_LINK_DYN_LIB=$REAL_LINK_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  176. SWIG_DLL_JAR_CMD=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_SWIG_DLL_JAR_CMD
  177. _MSVC_HEAD_LINK_LIB=${TOOLCHAIN_ENV} ${cwd:ARCADIA_BUILD_ROOT} ${LIB_WRAPPER} ${LINK_LIB_CMD}
  178. _MSVC_TAIL_LINK_LIB=\
  179. --ya-start-command-file \
  180. ${qe;rootrel:AUTO_INPUT} \
  181. $LINK_LIB_FLAGS \
  182. --ya-end-command-file \
  183. ${hide;kv:"soe"} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"}
  184. LINK_LIB=${GENERATE_MF} && $_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:TARGET} $_MSVC_TAIL_LINK_LIB
  185. GLOBAL_LINK_LIB=$_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:GLOBAL_TARGET} $_MSVC_TAIL_LINK_LIB
  186. LINK_EXE_CMDLINE=\
  187. ${GENERATE_MF} && \
  188. ${_GENERATE_EXTRA_OBJS} && \
  189. $GENERATE_VCS_C_INFO_NODEP && \
  190. ${GENERATE_COMMON_LIB_VFS} && \
  191. ${TOOLCHAIN_ENV} \
  192. ${cwd:ARCADIA_BUILD_ROOT} \
  193. ${LINK_WRAPPER} \
  194. ${LINK_EXE_CMD} \
  195. /OUT:${qe;rootrel:TARGET} \
  196. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  197. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  198. ${LINK_EXTRA_OUTPUT} \
  199. $_MSVC_SRCS_GLOBALS \
  200. --ya-start-command-file \
  201. ${VCS_C_OBJ_RR} \
  202. ${_EXTRA_OBJS} \
  203. ${qe;rootrel:AUTO_INPUT} \
  204. $LINK_EXE_FLAGS \
  205. $LINK_STDLIBS \
  206. $LDFLAGS \
  207. $LDFLAGS_GLOBAL \
  208. $OBJADDE \
  209. ${qe;rootrel;ext=.lib;tags_cut:PEERS} ${qe;rootrel;suf=.lib;noext;ext=.dll;tags_cut:PEERS} \
  210. --ya-end-command-file \
  211. ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"}
  212. LINK_EXE=$LINK_EXE_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  213. 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"}
  214. LINK_EXEC_DYN_LIB_CMDLINE=\
  215. ${GENERATE_MF} && \
  216. $GENERATE_VCS_C_INFO_NODEP && \
  217. ${GENERATE_COMMON_LIB_VFS} && \
  218. ${TOOLCHAIN_ENV} \
  219. ${cwd:ARCADIA_BUILD_ROOT} \
  220. ${LINK_WRAPPER} \
  221. ${LINK_WRAPPER_DYNLIB} \
  222. ${LINK_EXE_CMD} \
  223. /OUT:${qe;rootrel:TARGET} \
  224. ${LINK_EXTRA_OUTPUT} \
  225. ${EXPORTS_VALUE} \
  226. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  227. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  228. $_MSVC_SRCS_GLOBALS \
  229. '--ya-start-command-file \
  230. ${VCS_C_OBJ_RR} \
  231. ${qe;rootrel:AUTO_INPUT} \
  232. ${qe;rootrel;ext=.lib;tags_cut:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib;tags_cut:PEERS} \
  233. $LINK_EXE_FLAGS \
  234. $LINK_STDLIBS \
  235. $LDFLAGS $LDFLAGS_GLOBAL \
  236. $OBJADDE \
  237. --ya-end-command-file \
  238. ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"}
  239. LINK_EXEC_DYN_LIB=$LINK_EXEC_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  240. macro PACK_GLOBALS_IN_LIBRARY() {
  241. ENABLE(UNUSED_MACRO)
  242. }
  243. LINK_GLOBAL_FAT_OBJECT=\
  244. ${TOOLCHAIN_ENV} \
  245. ${cwd:ARCADIA_BUILD_ROOT} \
  246. ${LIB_WRAPPER} \
  247. ${LINK_LIB_CMD} \
  248. /OUT:${qe;rootrel;output;suf=.global.lib:REALPRJNAME} \
  249. --ya-start-command-file \
  250. ${qe;rootrel;ext=.lib:SRCS_GLOBAL} \
  251. ${qe;rootrel;ext=.obj:SRCS_GLOBAL} \
  252. ${qe;rootrel:AUTO_INPUT} \
  253. $LINK_LIB_FLAGS \
  254. --ya-end-command-file
  255. LINK_PEERS_FAT_OBJECT=\
  256. ${TOOLCHAIN_ENV} \
  257. ${cwd:ARCADIA_BUILD_ROOT} \
  258. ${LIB_WRAPPER} \
  259. ${LINK_LIB_CMD} \
  260. /OUT:${qe;rootrel:TARGET} \
  261. --ya-start-command-file \
  262. ${qe;rootrel:PEERS} \
  263. $LINK_LIB_FLAGS \
  264. --ya-end-command-file
  265. LINK_FAT_OBJECT=\
  266. ${GENERATE_MF} && \
  267. $GENERATE_VCS_C_INFO_NODEP && \
  268. $LINK_GLOBAL_FAT_OBJECT && \
  269. $LINK_PEERS_FAT_OBJECT \
  270. ${hide;kv:"p LD"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}