msvc_linker.conf 8.2 KB

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