nim.cfg 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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 bsd:
  158. # at least NetBSD has problems with thread local storage:
  159. tlsEmulation:on
  160. @end
  161. @if macosx or freebsd or openbsd:
  162. cc = clang
  163. gcc.options.always %= "-w ${gcc.maxerrorsimpl}"
  164. gcc.cpp.options.always %= "-w ${gcc.maxerrorsimpl} -fpermissive"
  165. @elif windows:
  166. gcc.options.always %= "-w ${gcc.maxerrorsimpl} -mno-ms-bitfields"
  167. gcc.cpp.options.always %= "-w ${gcc.maxerrorsimpl} -fpermissive -mno-ms-bitfields"
  168. @else:
  169. gcc.options.always %= "-w ${gcc.maxerrorsimpl}"
  170. gcc.cpp.options.always %= "-w ${gcc.maxerrorsimpl} -fpermissive"
  171. @end
  172. # Configuration for Objective-C compiler:
  173. #
  174. # Options for GNUStep. GNUStep configuration varies wildly, so you'll probably
  175. # have to add additional compiler and linker flags on a per-project basis.
  176. gcc.objc.options.linker = "-lobjc -lgnustep-base"
  177. llvm_gcc.objc.options.linker = "-lobjc -lgnustep-base"
  178. clang.objc.options.linker = "-lobjc -lgnustep-base"
  179. # Options for Mac OS X. Mac OS X uses its own Objective-C stack that is
  180. # totally different from GNUStep.
  181. @if macosx:
  182. gcc.objc.options.linker = "-framework Foundation"
  183. llvm_gcc.objc.options.linker = "-framework Foundation"
  184. clang.objc.options.linker = "-framework Foundation"
  185. @end
  186. # Options for FreeBSD, OpenBSD, NetBSD linker to add locations for searching
  187. # shared libraries.
  188. @if freebsd or openbsd or netbsd:
  189. gcc.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  190. gcc.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  191. llvm_gcc.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  192. llvm_gcc.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  193. clang.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  194. clang.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
  195. cincludes: "/usr/local/include"
  196. clibdir: "/usr/local/lib"
  197. @end
  198. @if freebsd or openbsd:
  199. cincludes: "/usr/local/include"
  200. clibdir: "/usr/local/lib"
  201. @elif netbsd:
  202. cincludes: "/usr/pkg/include"
  203. clibdir: "/usr/pkg/lib"
  204. @end
  205. # Configuration for the VxWorks
  206. # This has been tested with VxWorks 6.9 only
  207. @if vxworks:
  208. # For now we only support compiling RTPs applications (i.e. no DKMs)
  209. gcc.options.always = "-mrtp -fno-strict-aliasing -D_C99 -D_HAS_C9X -std=c99 -fasm -Wall -Wno-write-strings"
  210. # The linker config must add the VxWorks common library for the selected
  211. # processor which is usually found in:
  212. # "$WIND_BASE/target/lib/usr/lib/PROCESSOR_FAMILY/PROCESSOR_TYPE/common",
  213. # where PROCESSOR_FAMILY and PROCESSOR_TYPE are those supported by the VxWorks
  214. # compiler (e.g. ppc/PPC32 or mips/MIPSI64, etc)
  215. # For now we only support the PowerPC CPU
  216. 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"
  217. @end
  218. # -fno-math-errno is default in OSX, iOS, BSD, Musl, Libm, LLVM, Clang, ICC.
  219. # See https://itnext.io/why-standard-c-math-functions-are-slow-d10d02554e33
  220. # and https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Optimize-Options.html#Optimize-Options
  221. gcc.options.speed = "-O3 -fno-strict-aliasing -fno-ident -fno-math-errno"
  222. gcc.options.size = "-Os -fno-ident"
  223. @if windows:
  224. gcc.options.debug = "-g3 -Og -gdwarf-3"
  225. @else:
  226. gcc.options.debug = "-g3 -Og"
  227. @end
  228. gcc.cpp.options.speed = "-O3 -fno-strict-aliasing -fno-ident -fno-math-errno"
  229. gcc.cpp.options.size = "-Os -fno-ident"
  230. gcc.cpp.options.debug = "-g3 -Og"
  231. #passl = "-pg"
  232. # Configuration for the LLVM GCC compiler:
  233. llvm_gcc.options.debug = "-g"
  234. llvm_gcc.options.always = "-w"
  235. llvm_gcc.options.speed = "-O2"
  236. llvm_gcc.options.size = "-Os"
  237. # Configuration for the LLVM CLang compiler:
  238. clang.options.debug = "-g"
  239. clang.cpp.options.debug = "-g"
  240. clang.options.always = "-w -ferror-limit=3"
  241. clang.options.speed = "-O3"
  242. clang.options.size = "-Os"
  243. @if windows:
  244. clang_cl.cpp.options.always %= "${clang_cl.options.always} /EHsc"
  245. @if not release and not safety and not danger:
  246. clang_cl.options.linker = "/Z7"
  247. clang_cl.cpp.options.linker = "/Z7"
  248. @end
  249. clang.options.debug = "-g -gcodeview"
  250. clang.cpp.options.debug = "-g -gcodeview"
  251. @if not release and not safety and not danger:
  252. clang.options.linker = "-g"
  253. clang.cpp.options.linker = "-g"
  254. @end
  255. @end
  256. # Configuration for the Visual C/C++ compiler:
  257. # VCCEXE is a tool that invokes the Visual Studio Developer Command Prompt
  258. # before calling the compiler.
  259. # Please make sure either Visual Studio or C++ Build SKU is installed when using the vcc compiler backend.
  260. vcc.exe = "vccexe.exe"
  261. vcc.cpp.exe = "vccexe.exe"
  262. vcc.linkerexe = "vccexe.exe"
  263. vcc.cpp.linkerexe = "vccexe.exe"
  264. vcc.options.always = "/nologo"
  265. vcc.cpp.options.always = "/nologo /EHsc"
  266. vcc.options.debug = "/Zi /FS /Od"
  267. vcc.cpp.options.debug = "/Zi /FS /Od"
  268. vcc.options.speed = "/O2"
  269. vcc.cpp.options.speed = "/O2"
  270. vcc.options.size = "/O1"
  271. vcc.cpp.options.size = "/O1"
  272. # Configuration for the Tiny C Compiler:
  273. tcc.options.always = "-w"
  274. @if arm or arm64:
  275. --define:nimEmulateOverflowChecks
  276. @end
  277. @if lto or lto_incremental:
  278. @if lto_incremental:
  279. vcc.options.always%= "${vcc.options.always} /GL /Gw /Gy"
  280. vcc.cpp.options.always%= "${vcc.cpp.options.always} /GL /Gw /Gy"
  281. vcc.options.linker %= "${vcc.options.linker} /link /LTCG:incremental"
  282. vcc.cpp.options.linker %= "${vcc.cpp.options.linker} /link /LTCG:incremental"
  283. @else:
  284. vcc.options.always%= "${vcc.options.always} /GL"
  285. vcc.cpp.options.always%= "${vcc.cpp.options.always} /GL"
  286. vcc.options.linker %= "${vcc.options.linker} /link /LTCG"
  287. vcc.cpp.options.linker %= "${vcc.cpp.options.linker} /link /LTCG"
  288. @end
  289. clang_cl.options.always%= "${clang_cl.options.always} -flto"
  290. clang_cl.cpp.options.always%= "${clang.cpp.options.always} -flto"
  291. clang.options.always%= "${clang.options.always} -flto"
  292. clang.cpp.options.always%= "${clang.cpp.options.always} -flto"
  293. icl.options.always %= "${icl.options.always} /Qipo"
  294. icl.cpp.options.always %= "${icl.cpp.options.always} /Qipo"
  295. gcc.options.always %= "${gcc.options.always} -flto"
  296. gcc.cpp.options.always %= "${gcc.cpp.options.always} -flto"
  297. clang.options.linker %= "${clang.options.linker} -fuse-ld=lld -flto"
  298. clang.cpp.options.linker %= "${clang.cpp.options.linker} -fuse-ld=lld -flto"
  299. gcc.options.linker %= "${gcc.options.linker} -flto"
  300. gcc.cpp.options.linker %= "${gcc.cpp.options.linker} -flto"
  301. @end
  302. @if strip:
  303. gcc.options.linker %= "${gcc.options.linker} -s"
  304. gcc.cpp.options.linker %= "${gcc.cpp.options.linker} -s"
  305. clang.options.linker %= "${clang.options.linker} -s"
  306. clang.cpp.options.linker %= "${clang.cpp.options.linker} -s"
  307. @end