nim.cfg 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. # Configuration file for the Nim Compiler.
  2. # (c) 2017 Andreas Rumpf
  3. # Feel free to edit the default values as you need.
  4. # You may set environment variables with
  5. # @putenv "key" "val"
  6. # Environment variables can be accessed like so:
  7. # gcc.path %= "$CC_PATH"
  8. cc = gcc
  9. # additional options always passed to the compiler:
  10. --parallel_build: "0" # 0 to auto-detect number of processors
  11. hint[LineTooLong]=off
  12. #hint[XDeclaredButNotUsed]=off
  13. # Examples of how to setup a cross-compiler:
  14. # Cross-compiling for Raspberry Pi.
  15. # (This compiler is available in gcc-arm-linux-gnueabihf package on Ubuntu)
  16. arm.linux.gcc.exe = "arm-linux-gnueabihf-gcc"
  17. arm.linux.gcc.linkerexe = "arm-linux-gnueabihf-gcc"
  18. # For OpenWRT, you will also need to adjust PATH to point to your toolchain.
  19. mips.linux.gcc.exe = "mips-openwrt-linux-gcc"
  20. mips.linux.gcc.linkerexe = "mips-openwrt-linux-gcc"
  21. path="$lib/deprecated/core"
  22. path="$lib/deprecated/pure"
  23. path="$lib/pure/collections"
  24. path="$lib/pure/concurrency"
  25. path="$lib/impure"
  26. path="$lib/wrappers"
  27. path="$lib/wrappers/linenoise"
  28. path="$lib/windows"
  29. path="$lib/posix"
  30. path="$lib/js"
  31. path="$lib/pure/unidecode"
  32. path="$lib/arch"
  33. path="$lib/core"
  34. path="$lib/pure"
  35. @if nimbabel:
  36. @if not windows:
  37. nimblepath="/opt/nimble/pkgs/"
  38. @else:
  39. # TODO:
  40. @end
  41. nimblepath="$home/.nimble/pkgs/"
  42. @end
  43. @if danger or quick:
  44. obj_checks:off
  45. field_checks:off
  46. range_checks:off
  47. bound_checks:off
  48. overflow_checks:off
  49. assertions:off
  50. stacktrace:off
  51. linetrace:off
  52. debugger:off
  53. line_dir:off
  54. dead_code_elim:on
  55. @if nimHasNilChecks:
  56. nilchecks:off
  57. @end
  58. @end
  59. @if release or danger:
  60. stacktrace:off
  61. excessiveStackTrace:off
  62. linetrace:off
  63. debugger:off
  64. line_dir:off
  65. opt:speed
  66. define:release
  67. @end
  68. @if false: # not danger: # this does not work yet.
  69. clang.options.always %= "${clang.options.always} -fsanitize=null -fsanitize-undefined-trap-on-error"
  70. gcc.options.always %= "${gcc.options.always} -fsanitize=null -fsanitize-undefined-trap-on-error"
  71. @end
  72. @if unix and mingw:
  73. # Cross compile for Windows from Linux/OSX using MinGW
  74. i386.windows.gcc.exe = "i686-w64-mingw32-gcc"
  75. i386.windows.gcc.linkerexe = "i686-w64-mingw32-gcc"
  76. i386.windows.gcc.cpp.exe = "i686-w64-mingw32-g++"
  77. i386.windows.gcc.cpp.linkerexe = "i686-w64-mingw32-g++"
  78. amd64.windows.gcc.exe = "x86_64-w64-mingw32-gcc"
  79. amd64.windows.gcc.linkerexe = "x86_64-w64-mingw32-gcc"
  80. amd64.windows.gcc.cpp.exe = "x86_64-w64-mingw32-g++"
  81. amd64.windows.gcc.cpp.linkerexe = "x86_64-w64-mingw32-g++"
  82. @if macosx:
  83. i386.windows.gcc.path = "/usr/local/bin"
  84. amd64.windows.gcc.path = "/usr/local/bin"
  85. @else:
  86. i386.windows.gcc.path = "/usr/bin"
  87. amd64.windows.gcc.path = "/usr/bin"
  88. @end
  89. os = windows
  90. gcc.options.linker = ""
  91. gcc.cpp.options.linker = ""
  92. @end
  93. @if unix:
  94. @if not bsd or haiku:
  95. # -fopenmp
  96. gcc.options.linker = "-ldl"
  97. gcc.cpp.options.linker = "-ldl"
  98. clang.options.linker = "-ldl"
  99. clang.cpp.options.linker = "-ldl"
  100. tcc.options.linker = "-ldl"
  101. @end
  102. @if bsd:
  103. # BSD got posix_spawn only recently, so we deactivate it for osproc:
  104. define:useFork
  105. # at least NetBSD has problems with thread local storage:
  106. tlsEmulation:on
  107. @end
  108. @if haiku:
  109. gcc.options.linker = "-Wl,--as-needed -lnetwork"
  110. gcc.cpp.options.linker = "-Wl,--as-needed -lnetwork"
  111. clang.options.linker = "-Wl,--as-needed -lnetwork"
  112. clang.cpp.options.linker = "-Wl,--as-needed -lnetwork"
  113. tcc.options.linker = "-Wl,--as-needed -lnetwork"
  114. @end
  115. @end
  116. @if android:
  117. cc = clang
  118. @if termux:
  119. gcc.options.linker = "-landroid-glob"
  120. gcc.cpp.options.linker = "-landroid-glob"
  121. clang.options.linker = "-landroid-glob"
  122. clang.cpp.options.linker = "-landroid-glob"
  123. tcc.options.linker = "-landroid-glob"
  124. @end
  125. @end
  126. @if nintendoswitch:
  127. cc = "switch_gcc"
  128. switch_gcc.options.linker = "-g -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE"
  129. switch_gcc.cpp.options.linker = "-g -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE"
  130. switch_gcc.options.always = "-g -Wall -O2 -ffunction-sections -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -D__SWITCH__"
  131. switch_gcc.cpp.options.always = "-g -Wall -O2 -ffunction-sections -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -D__SWITCH__ -fno-rtti -fno-exceptions -std=gnu++11"
  132. @end
  133. # Configuration for the Intel C/C++ compiler:
  134. @if windows:
  135. icl.options.speed = "/Ox /arch:SSE2"
  136. icl.options.always = "/nologo"
  137. @end
  138. # Configuration for the GNU C/C++ compiler:
  139. @if windows:
  140. #gcc.path = r"$nim\dist\mingw\bin"
  141. @if gcc or tcc:
  142. tlsEmulation:on
  143. @end
  144. @end
  145. gcc.maxerrorsimpl = "-fmax-errors=3"
  146. @if macosx or freebsd or openbsd:
  147. cc = clang
  148. tlsEmulation:on
  149. gcc.options.always %= "-w ${gcc.maxerrorsimpl}"
  150. gcc.cpp.options.always %= "-w ${gcc.maxerrorsimpl} -fpermissive"
  151. @elif windows:
  152. gcc.options.always %= "-w ${gcc.maxerrorsimpl} -mno-ms-bitfields"
  153. gcc.cpp.options.always %= "-w ${gcc.maxerrorsimpl} -fpermissive -mno-ms-bitfields"
  154. @else:
  155. gcc.options.always %= "-w ${gcc.maxerrorsimpl}"
  156. gcc.cpp.options.always %= "-w ${gcc.maxerrorsimpl} -fpermissive"
  157. @end
  158. # Configuration for Objective-C compiler:
  159. #
  160. # Options for GNUStep. GNUStep configuration varies wildly, so you'll probably
  161. # have to add additional compiler and linker flags on a per-project basis.
  162. gcc.objc.options.linker = "-lobjc -lgnustep-base"
  163. llvm_gcc.objc.options.linker = "-lobjc -lgnustep-base"
  164. clang.objc.options.linker = "-lobjc -lgnustep-base"
  165. # Options for Mac OS X. Mac OS X uses its own Objective-C stack that is
  166. # totally different from GNUStep.
  167. @if macosx:
  168. gcc.objc.options.linker = "-framework Foundation"
  169. llvm_gcc.objc.options.linker = "-framework Foundation"
  170. clang.objc.options.linker = "-framework Foundation"
  171. @end
  172. # Options for FreeBSD, OpenBSD, NetBSD linker to add locations for searching
  173. # shared libraries.
  174. @if freebsd or openbsd or netbsd:
  175. gcc.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  176. gcc.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  177. llvm_gcc.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  178. llvm_gcc.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  179. clang.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  180. clang.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  181. cincludes: "/usr/local/include"
  182. clibdir: "/usr/local/lib"
  183. @end
  184. @if freebsd or openbsd:
  185. cincludes: "/usr/local/include"
  186. clibdir: "/usr/local/lib"
  187. @elif netbsd:
  188. cincludes: "/usr/pkg/include"
  189. clibdir: "/usr/pkg/lib"
  190. @end
  191. # Configuration for the VxWorks
  192. # This has been tested with VxWorks 6.9 only
  193. @if vxworks:
  194. # For now we only support compiling RTPs applications (i.e. no DKMs)
  195. gcc.options.always = "-mrtp -fno-strict-aliasing -D_C99 -D_HAS_C9X -std=c99 -fasm -Wall -Wno-write-strings"
  196. # The linker config must add the VxWorks common library for the selected
  197. # processor which is usually found in:
  198. # "$WIND_BASE/target/lib/usr/lib/PROCESSOR_FAMILY/PROCESSOR_TYPE/common",
  199. # where PROCESSOR_FAMILY and PROCESSOR_TYPE are those supported by the VxWorks
  200. # compiler (e.g. ppc/PPC32 or mips/MIPSI64, etc)
  201. # For now we only support the PowerPC CPU
  202. gcc.options.linker %= "-L $WIND_BASE/target/lib/usr/lib/ppc/PPC32/common -mrtp -fno-strict-aliasing -D_C99 -D_HAS_C9X -std=c99 -fasm -Wall -Wno-write-strings"
  203. @end
  204. gcc.options.speed = "-O3 -fno-strict-aliasing -fno-ident"
  205. gcc.options.size = "-Os -fno-ident"
  206. @if windows:
  207. gcc.options.debug = "-g3 -Og -gdwarf-3"
  208. @else:
  209. gcc.options.debug = "-g3 -Og"
  210. @end
  211. gcc.cpp.options.speed = "-O3 -fno-strict-aliasing -fno-ident"
  212. gcc.cpp.options.size = "-Os -fno-ident"
  213. gcc.cpp.options.debug = "-g3 -Og"
  214. #passl = "-pg"
  215. # Configuration for the LLVM GCC compiler:
  216. llvm_gcc.options.debug = "-g"
  217. llvm_gcc.options.always = "-w"
  218. llvm_gcc.options.speed = "-O2"
  219. llvm_gcc.options.size = "-Os"
  220. # Configuration for the LLVM CLang compiler:
  221. clang.options.debug = "-g"
  222. clang.cpp.options.debug = "-g"
  223. clang.options.always = "-w -ferror-limit=3"
  224. clang.options.speed = "-O3"
  225. clang.options.size = "-Os"
  226. @if windows:
  227. clang_cl.cpp.options.always %= "${clang_cl.options.always} /EHsc"
  228. @if not release and not safety and not danger:
  229. clang_cl.options.linker = "/Z7"
  230. clang_cl.cpp.options.linker = "/Z7"
  231. @end
  232. clang.options.debug = "-g -gcodeview"
  233. clang.cpp.options.debug = "-g -gcodeview"
  234. @if not release and not safety and not danger:
  235. clang.options.linker = "-g"
  236. clang.cpp.options.linker = "-g"
  237. @end
  238. @end
  239. # Configuration for the Visual C/C++ compiler:
  240. # VCCEXE is a tool that invokes the Visual Studio Developer Command Prompt
  241. # before calling the compiler.
  242. # Please make sure either Visual Studio or C++ Build SKU is installed when using the vcc compiler backend.
  243. vcc.exe = "vccexe.exe"
  244. vcc.cpp.exe = "vccexe.exe"
  245. vcc.linkerexe = "vccexe.exe"
  246. vcc.cpp.linkerexe = "vccexe.exe"
  247. vcc.options.always = "/nologo"
  248. vcc.cpp.options.always = "/nologo /EHsc"
  249. vcc.options.debug = "/Zi /FS /Od"
  250. vcc.cpp.options.debug = "/Zi /FS /Od"
  251. vcc.options.speed = "/O2"
  252. vcc.cpp.options.speed = "/O2"
  253. vcc.options.size = "/O1"
  254. vcc.cpp.options.size = "/O1"
  255. # Configuration for the Tiny C Compiler:
  256. tcc.options.always = "-w"
  257. # Configuration for the Genode toolchain
  258. @if genode:
  259. noCppExceptions # avoid std C++
  260. tlsEmulation:on # no TLS segment register magic
  261. @if i386 or amd64:
  262. gcc.exe = "genode-x86-gcc"
  263. gcc.cpp.exe = "genode-x86-g++"
  264. gcc.cpp.linkerexe = "genode-x86-ld"
  265. @elif arm:
  266. gcc.exe = "genode-arm-gcc"
  267. gcc.cpp.exe = "genode-arm-g++"
  268. gcc.cpp.linkerexe = "genode-arm-ld"
  269. @elif arm64:
  270. gcc.exe = "genode-aarch64-gcc"
  271. gcc.cpp.exe = "genode-aarch64-g++"
  272. gcc.cpp.linkerexe = "genode-aarch64-ld"
  273. @elif riscv64:
  274. gcc.exe = "genode-riscv-gcc"
  275. gcc.cpp.exe = "genode-riscv-g++"
  276. gcc.cpp.linkerexe = "genode-riscv-ld"
  277. @end
  278. @end
  279. @if arm or arm64:
  280. --define:nimEmulateOverflowChecks
  281. @end
  282. @if nimv019:
  283. --multimethods:on
  284. --define:nimOldCaseObjects
  285. --define:nimOldShiftRight
  286. @end
  287. @if lto or lto_incremental:
  288. @if lto_incremental:
  289. vcc.options.always%= "${vcc.options.always} /GL /Gw /Gy"
  290. vcc.cpp.options.always%= "${vcc.cpp.options.always} /GL /Gw /Gy"
  291. vcc.options.linker %= "${vcc.options.linker} /link /LTCG:incremental"
  292. vcc.cpp.options.linker %= "${vcc.cpp.options.linker} /link /LTCG:incremental"
  293. @else:
  294. vcc.options.always%= "${vcc.options.always} /GL"
  295. vcc.cpp.options.always%= "${vcc.cpp.options.always} /GL"
  296. vcc.options.linker %= "${vcc.options.linker} /link /LTCG"
  297. vcc.cpp.options.linker %= "${vcc.cpp.options.linker} /link /LTCG"
  298. @end
  299. clang_cl.options.always%= "${clang_cl.options.always} -flto"
  300. clang_cl.cpp.options.always%= "${clang.cpp.options.always} -flto"
  301. clang.options.always%= "${clang.options.always} -flto"
  302. clang.cpp.options.always%= "${clang.cpp.options.always} -flto"
  303. icl.options.always %= "${icl.options.always} /Qipo"
  304. icl.cpp.options.always %= "${icl.cpp.options.always} /Qipo"
  305. gcc.options.always %= "${gcc.options.always} -flto"
  306. gcc.cpp.options.always %= "${gcc.cpp.options.always} -flto"
  307. clang.options.linker %= "${clang.options.linker} -fuse-ld=lld -flto"
  308. clang.cpp.options.linker %= "${clang.cpp.options.linker} -fuse-ld=lld -flto"
  309. gcc.options.linker %= "${gcc.options.linker} -flto"
  310. gcc.cpp.options.linker %= "${gcc.cpp.options.linker} -flto"
  311. @end
  312. @if strip:
  313. gcc.options.linker %= "${gcc.options.linker} -s"
  314. gcc.cpp.options.linker %= "${gcc.cpp.options.linker} -s"
  315. clang.options.linker %= "${clang.options.linker} -s"
  316. clang.cpp.options.linker %= "${clang.cpp.options.linker} -s"
  317. @end