msvc_linker.conf 8.0 KB

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