nim.cfg 12 KB

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