msvc_linker.conf 8.2 KB

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