nim.cfg 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. @if macosx or freebsd:
  146. cc = clang
  147. tlsEmulation:on
  148. gcc.options.always = "-w"
  149. gcc.cpp.options.always = "-w -fpermissive"
  150. @elif windows:
  151. gcc.options.always = "-w -mno-ms-bitfields"
  152. gcc.cpp.options.always = "-w -fpermissive -mno-ms-bitfields"
  153. @else:
  154. gcc.options.always = "-w"
  155. gcc.cpp.options.always = "-w -fpermissive"
  156. @end
  157. # Configuration for Objective-C compiler:
  158. #
  159. # Options for GNUStep. GNUStep configuration varies wildly, so you'll probably
  160. # have to add additional compiler and linker flags on a per-project basis.
  161. gcc.objc.options.linker = "-lobjc -lgnustep-base"
  162. llvm_gcc.objc.options.linker = "-lobjc -lgnustep-base"
  163. clang.objc.options.linker = "-lobjc -lgnustep-base"
  164. # Options for Mac OS X. Mac OS X uses its own Objective-C stack that is
  165. # totally different from GNUStep.
  166. @if macosx:
  167. gcc.objc.options.linker = "-framework Foundation"
  168. llvm_gcc.objc.options.linker = "-framework Foundation"
  169. clang.objc.options.linker = "-framework Foundation"
  170. @end
  171. # Options for FreeBSD, OpenBSD, NetBSD linker to add locations for searching
  172. # shared libraries.
  173. @if freebsd or openbsd or netbsd:
  174. gcc.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  175. gcc.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  176. llvm_gcc.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  177. llvm_gcc.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  178. clang.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  179. clang.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  180. @end
  181. # Configuration for the VxWorks
  182. # This has been tested with VxWorks 6.9 only
  183. @if vxworks:
  184. # For now we only support compiling RTPs applications (i.e. no DKMs)
  185. gcc.options.always = "-mrtp -fno-strict-aliasing -D_C99 -D_HAS_C9X -std=c99 -fasm -Wall -Wno-write-strings"
  186. # The linker config must add the VxWorks common library for the selected
  187. # processor which is usually found in:
  188. # "$WIND_BASE/target/lib/usr/lib/PROCESSOR_FAMILY/PROCESSOR_TYPE/common",
  189. # where PROCESSOR_FAMILY and PROCESSOR_TYPE are those supported by the VxWorks
  190. # compiler (e.g. ppc/PPC32 or mips/MIPSI64, etc)
  191. # For now we only support the PowerPC CPU
  192. 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"
  193. @end
  194. gcc.options.speed = "-O3 -fno-strict-aliasing -fno-ident"
  195. gcc.options.size = "-Os -fno-ident"
  196. @if windows:
  197. gcc.options.debug = "-g3 -Og -gdwarf-3"
  198. @else:
  199. gcc.options.debug = "-g3 -Og"
  200. @end
  201. gcc.cpp.options.speed = "-O3 -fno-strict-aliasing -fno-ident"
  202. gcc.cpp.options.size = "-Os -fno-ident"
  203. gcc.cpp.options.debug = "-g3 -Og"
  204. #passl = "-pg"
  205. # Configuration for the LLVM GCC compiler:
  206. llvm_gcc.options.debug = "-g"
  207. llvm_gcc.options.always = "-w"
  208. llvm_gcc.options.speed = "-O2"
  209. llvm_gcc.options.size = "-Os"
  210. # Configuration for the LLVM CLang compiler:
  211. clang.options.debug = "-g"
  212. clang.cpp.options.debug = "-g"
  213. clang.options.always = "-w"
  214. clang.options.speed = "-O3"
  215. clang.options.size = "-Os"
  216. @if windows:
  217. clang_cl.cpp.options.always %= "${clang_cl.options.always} /EHsc"
  218. @if not release and not safety and not danger:
  219. clang_cl.options.linker = "/Z7"
  220. clang_cl.cpp.options.linker = "/Z7"
  221. @end
  222. clang.options.debug = "-g -gcodeview"
  223. clang.cpp.options.debug = "-g -gcodeview"
  224. @if not release and not safety and not danger:
  225. clang.options.linker = "-g"
  226. clang.cpp.options.linker = "-g"
  227. @end
  228. @end
  229. # Configuration for the Visual C/C++ compiler:
  230. # VCCEXE is a tool that invokes the Visual Studio Developer Command Prompt
  231. # before calling the compiler.
  232. # Please make sure either Visual Studio or C++ Build SKU is installed when using the vcc compiler backend.
  233. vcc.exe = "vccexe.exe"
  234. vcc.cpp.exe = "vccexe.exe"
  235. vcc.linkerexe = "vccexe.exe"
  236. vcc.cpp.linkerexe = "vccexe.exe"
  237. vcc.options.always = "/nologo"
  238. vcc.cpp.options.always = "/EHsc"
  239. vcc.options.linker = "/nologo /F33554432" # set the stack size to 32 MiB
  240. vcc.cpp.options.linker = "/nologo /F33554432"
  241. vcc.options.debug = "/Zi /FS /Od"
  242. vcc.cpp.options.debug = "/Zi /FS /Od"
  243. vcc.options.speed = "/O2"
  244. vcc.cpp.options.speed = "/O2"
  245. vcc.options.size = "/O1"
  246. vcc.cpp.options.size = "/O1"
  247. # Configuration for the Tiny C Compiler:
  248. tcc.options.always = "-w"
  249. # Configuration for the Genode toolchain
  250. @if genode:
  251. noCppExceptions # avoid std C++
  252. tlsEmulation:on # no TLS segment register magic
  253. @if i386 or amd64:
  254. gcc.exe = "genode-x86-gcc"
  255. gcc.cpp.exe = "genode-x86-g++"
  256. gcc.cpp.linkerexe = "genode-x86-ld"
  257. @elif arm:
  258. gcc.exe = "genode-arm-gcc"
  259. gcc.cpp.exe = "genode-arm-g++"
  260. gcc.cpp.linkerexe = "genode-arm-ld"
  261. @elif arm64:
  262. gcc.exe = "genode-aarch64-gcc"
  263. gcc.cpp.exe = "genode-aarch64-g++"
  264. gcc.cpp.linkerexe = "genode-aarch64-ld"
  265. @elif riscv64:
  266. gcc.exe = "genode-riscv-gcc"
  267. gcc.cpp.exe = "genode-riscv-g++"
  268. gcc.cpp.linkerexe = "genode-riscv-ld"
  269. @end
  270. @end
  271. @if arm or arm64:
  272. --define:nimEmulateOverflowChecks
  273. @end
  274. @if nimv019:
  275. --multimethods:on
  276. --oldAst:on
  277. --define:nimOldCaseObjects
  278. --define:nimOldShiftRight
  279. @end