msvc_linker.conf 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. # we split srcs_global into two groups: libs and objs
  123. # # each group can be in its own command file
  124. # first group need /WHOLEARCHIVE: prefix which will be added in fix_msvc_output.py or run_msvc_wine.py
  125. # the tail of link commands will be added in the third command file
  126. _MSVC_SRCS_GLOBALS=\
  127. --start-wa --ya-start-command-file ${qe;rootrel;ext=.lib:SRCS_GLOBAL} --ya-end-command-file --end-wa \
  128. --ya-start-command-file ${qe;rootrel;ext=.obj:SRCS_GLOBAL} --ya-end-command-file
  129. REAL_LINK_DYN_LIB_CMDLINE=\
  130. ${TOOLCHAIN_ENV} \
  131. ${cwd:ARCADIA_BUILD_ROOT} \
  132. ${LINK_WRAPPER} \
  133. ${LINK_WRAPPER_DYNLIB} \
  134. ${LINK_EXE_CMD} \
  135. ${LINK_IMPLIB_VALUE} \
  136. /DLL \
  137. /OUT:${qe;rootrel:TARGET} \
  138. ${LINK_EXTRA_OUTPUT} \
  139. ${EXPORTS_VALUE} \
  140. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  141. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  142. $_MSVC_SRCS_GLOBALS \
  143. --ya-start-command-file \
  144. ${VCS_C_OBJ_RR} \
  145. ${qe;rootrel:AUTO_INPUT} \
  146. ${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \
  147. $LINK_EXE_FLAGS \
  148. $LINK_STDLIBS $LDFLAGS \
  149. $LDFLAGS_GLOBAL \
  150. $OBJADDE \
  151. --ya-end-command-file
  152. REAL_LINK_DYN_LIB=$REAL_LINK_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  153. SWIG_DLL_JAR_CMD=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $REAL_SWIG_DLL_JAR_CMD
  154. _MSVC_HEAD_LINK_LIB=${TOOLCHAIN_ENV} ${cwd:ARCADIA_BUILD_ROOT} ${LIB_WRAPPER} ${LINK_LIB_CMD}
  155. _MSVC_TAIL_LINK_LIB=\
  156. --ya-start-command-file \
  157. ${qe;rootrel:AUTO_INPUT} \
  158. $LINK_LIB_FLAGS \
  159. --ya-end-command-file \
  160. ${hide;kv:"soe"} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"}
  161. LINK_LIB=${GENERATE_MF} && $_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:TARGET} $_MSVC_TAIL_LINK_LIB
  162. GLOBAL_LINK_LIB=$_MSVC_HEAD_LINK_LIB /OUT:${qe;rootrel:GLOBAL_TARGET} $_MSVC_TAIL_LINK_LIB
  163. LINK_EXE_CMDLINE=\
  164. ${GENERATE_MF} && \
  165. $GENERATE_VCS_C_INFO_NODEP && \
  166. ${TOOLCHAIN_ENV} \
  167. ${cwd:ARCADIA_BUILD_ROOT} \
  168. ${LINK_WRAPPER} \
  169. ${LINK_EXE_CMD} \
  170. /OUT:${qe;rootrel:TARGET} \
  171. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  172. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  173. ${LINK_EXTRA_OUTPUT} \
  174. $_MSVC_SRCS_GLOBALS \
  175. --ya-start-command-file \
  176. ${VCS_C_OBJ_RR} \
  177. ${qe;rootrel:AUTO_INPUT} \
  178. $LINK_EXE_FLAGS \
  179. $LINK_STDLIBS \
  180. $LDFLAGS \
  181. $LDFLAGS_GLOBAL \
  182. $OBJADDE \
  183. ${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \
  184. --ya-end-command-file \
  185. ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"}
  186. LINK_EXE=$LINK_EXE_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  187. 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"}
  188. LINK_EXEC_DYN_LIB_CMDLINE=\
  189. ${GENERATE_MF} && \
  190. $GENERATE_VCS_C_INFO_NODEP && \
  191. ${TOOLCHAIN_ENV} \
  192. ${cwd:ARCADIA_BUILD_ROOT} \
  193. ${LINK_WRAPPER} \
  194. ${LINK_WRAPPER_DYNLIB} \
  195. ${LINK_EXE_CMD} \
  196. /OUT:${qe;rootrel:TARGET} \
  197. ${LINK_EXTRA_OUTPUT} \
  198. ${EXPORTS_VALUE} \
  199. ${pre=--whole-archive-peers :WHOLE_ARCHIVE_PEERS} \
  200. ${pre=--whole-archive-libs :_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL} \
  201. $_MSVC_SRCS_GLOBALS \
  202. '--ya-start-command-file \
  203. ${VCS_C_OBJ_RR} \
  204. ${qe;rootrel:AUTO_INPUT} \
  205. ${qe;rootrel;ext=.lib:PEERS} ${qe;rootrel;ext=.dll;noext;suf=.lib:PEERS} \
  206. $LINK_EXE_FLAGS \
  207. $LINK_STDLIBS \
  208. $LDFLAGS $LDFLAGS_GLOBAL \
  209. $OBJADDE \
  210. --ya-end-command-file \
  211. ${hide;kv:"soe"} ${hide;kv:"p LD"} ${hide;kv:"pc blue"}
  212. LINK_EXEC_DYN_LIB=$LINK_EXEC_DYN_LIB_IMPL($_WHOLE_ARCHIVE_PEERS_VALUE)
  213. macro PACK_GLOBALS_IN_LIBRARY() {
  214. ENABLE(UNUSED_MACRO)
  215. }
  216. LINK_GLOBAL_FAT_OBJECT=\
  217. ${TOOLCHAIN_ENV} \
  218. ${cwd:ARCADIA_BUILD_ROOT} \
  219. ${LIB_WRAPPER} \
  220. ${LINK_LIB_CMD} \
  221. /OUT:${output;qe;rootrel:REALPRJNAME.global.lib} \
  222. --ya-start-command-file \
  223. ${qe;rootrel;ext=.lib:SRCS_GLOBAL} \
  224. ${qe;rootrel;ext=.obj:SRCS_GLOBAL} \
  225. ${qe;rootrel:AUTO_INPUT} \
  226. $LINK_LIB_FLAGS \
  227. --ya-end-command-file
  228. LINK_PEERS_FAT_OBJECT=\
  229. ${TOOLCHAIN_ENV} \
  230. ${cwd:ARCADIA_BUILD_ROOT} \
  231. ${LIB_WRAPPER} \
  232. ${LINK_LIB_CMD} \
  233. /OUT:${qe;rootrel;output:TARGET} \
  234. --ya-start-command-file \
  235. ${qe;rootrel:PEERS} \
  236. $LINK_LIB_FLAGS \
  237. --ya-end-command-file
  238. LINK_FAT_OBJECT=\
  239. ${GENERATE_MF} && \
  240. $GENERATE_VCS_C_INFO_NODEP && \
  241. $LINK_GLOBAL_FAT_OBJECT && \
  242. $LINK_PEERS_FAT_OBJECT \
  243. ${kv;hide:"p LD"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}