msvc_linker.conf 7.8 KB

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