nimbus-eth2/config.nims

211 lines
8.3 KiB
Plaintext
Raw Permalink Normal View History

2021-05-19 06:38:13 +00:00
import strutils
const nimCachePathOverride {.strdefine.} = ""
when nimCachePathOverride == "":
when defined(release):
let nimCachePath = "nimcache/release/" & projectName()
else:
let nimCachePath = "nimcache/debug/" & projectName()
else:
let nimCachePath = nimCachePathOverride
switch("nimcache", nimCachePath)
use LTO in release builds (#1661) * use LTO in release builds This significantly (40%) speeds up block replay and hashing - for example replaying first 1000 blocks, without/with LTO: ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 25468.481, 0.000, 25468.481, 25468.481, 1, Initialize DB 0.297, 0.516, 0.053, 13.645, 721, Load block from database 26.458, 0.000, 26.458, 26.458, 1, Load state from database 20.737, 8.288, 11.096, 199.325, 690, Apply block 333.069, 62.798, 45.225, 429.452, 31, Apply epoch block 0.000, 0.000, 0.000, 0.000, 0, Database block store ``` ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release --passc:-flto --passl:-flto --stacktrace:off ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 23903.006, 0.000, 23903.006, 23903.006, 1, Initialize DB 0.253, 0.122, 0.047, 0.731, 721, Load block from database 24.455, 0.000, 24.455, 24.455, 1, Load state from database 18.734, 7.062, 10.346, 167.397, 690, Apply block 194.869, 33.175, 29.311, 226.981, 31, Apply epoch block ``` Epoch processing is heavy on both arithmetics and hash caching, both of which get a significant boost here. This makes sense: nim creates lots of small functions spread out over many C files. A much worse solution is to try to annotate code with `inline` - it copies functions to multiple C files but still doesn't do intermodule optimizations significantly limiting the compilers' ability to reason about the code, causing bloat and misrepresenting the usefulness of a function to the call frequency analysis that drives actual (C-compiler) inlining and many other optimizations. In particular, many nim functions are part of `system` or the `C` backend - stack tracing, memory allocation etc - nim's inlining system is pretty incomplete in that it does not deal with these and many other cases. * windows workaround * skip LTO on windows for now
2020-09-24 16:40:28 +00:00
# `-flto` gives a significant improvement in processing speed, specially hash tree and state transition (basically any CPU-bound code implemented in nim)
# With LTO enabled, optimization flags should be passed to both compiler and linker!
2020-09-25 16:15:02 +00:00
if defined(release) and not defined(disableLTO):
# "-w" is not passed to the compiler during linking, so we need to disable
# some warnings by hand.
switch("passL", "-Wno-stringop-overflow -Wno-stringop-overread")
use LTO in release builds (#1661) * use LTO in release builds This significantly (40%) speeds up block replay and hashing - for example replaying first 1000 blocks, without/with LTO: ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 25468.481, 0.000, 25468.481, 25468.481, 1, Initialize DB 0.297, 0.516, 0.053, 13.645, 721, Load block from database 26.458, 0.000, 26.458, 26.458, 1, Load state from database 20.737, 8.288, 11.096, 199.325, 690, Apply block 333.069, 62.798, 45.225, 429.452, 31, Apply epoch block 0.000, 0.000, 0.000, 0.000, 0, Database block store ``` ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release --passc:-flto --passl:-flto --stacktrace:off ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 23903.006, 0.000, 23903.006, 23903.006, 1, Initialize DB 0.253, 0.122, 0.047, 0.731, 721, Load block from database 24.455, 0.000, 24.455, 24.455, 1, Load state from database 18.734, 7.062, 10.346, 167.397, 690, Apply block 194.869, 33.175, 29.311, 226.981, 31, Apply epoch block ``` Epoch processing is heavy on both arithmetics and hash caching, both of which get a significant boost here. This makes sense: nim creates lots of small functions spread out over many C files. A much worse solution is to try to annotate code with `inline` - it copies functions to multiple C files but still doesn't do intermodule optimizations significantly limiting the compilers' ability to reason about the code, causing bloat and misrepresenting the usefulness of a function to the call frequency analysis that drives actual (C-compiler) inlining and many other optimizations. In particular, many nim functions are part of `system` or the `C` backend - stack tracing, memory allocation etc - nim's inlining system is pretty incomplete in that it does not deal with these and many other cases. * windows workaround * skip LTO on windows for now
2020-09-24 16:40:28 +00:00
if defined(macosx): # Clang
switch("passC", "-flto=thin")
switch("passL", "-flto=thin -Wl,-object_path_lto," & nimCachePath & "/lto")
use LTO in release builds (#1661) * use LTO in release builds This significantly (40%) speeds up block replay and hashing - for example replaying first 1000 blocks, without/with LTO: ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 25468.481, 0.000, 25468.481, 25468.481, 1, Initialize DB 0.297, 0.516, 0.053, 13.645, 721, Load block from database 26.458, 0.000, 26.458, 26.458, 1, Load state from database 20.737, 8.288, 11.096, 199.325, 690, Apply block 333.069, 62.798, 45.225, 429.452, 31, Apply epoch block 0.000, 0.000, 0.000, 0.000, 0, Database block store ``` ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release --passc:-flto --passl:-flto --stacktrace:off ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 23903.006, 0.000, 23903.006, 23903.006, 1, Initialize DB 0.253, 0.122, 0.047, 0.731, 721, Load block from database 24.455, 0.000, 24.455, 24.455, 1, Load state from database 18.734, 7.062, 10.346, 167.397, 690, Apply block 194.869, 33.175, 29.311, 226.981, 31, Apply epoch block ``` Epoch processing is heavy on both arithmetics and hash caching, both of which get a significant boost here. This makes sense: nim creates lots of small functions spread out over many C files. A much worse solution is to try to annotate code with `inline` - it copies functions to multiple C files but still doesn't do intermodule optimizations significantly limiting the compilers' ability to reason about the code, causing bloat and misrepresenting the usefulness of a function to the call frequency analysis that drives actual (C-compiler) inlining and many other optimizations. In particular, many nim functions are part of `system` or the `C` backend - stack tracing, memory allocation etc - nim's inlining system is pretty incomplete in that it does not deal with these and many other cases. * windows workaround * skip LTO on windows for now
2020-09-24 16:40:28 +00:00
elif defined(linux):
2020-11-27 01:29:06 +00:00
switch("passC", "-flto=jobserver")
switch("passL", "-flto=jobserver")
switch("passC", "-finline-limit=100000")
switch("passL", "-finline-limit=100000")
use LTO in release builds (#1661) * use LTO in release builds This significantly (40%) speeds up block replay and hashing - for example replaying first 1000 blocks, without/with LTO: ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 25468.481, 0.000, 25468.481, 25468.481, 1, Initialize DB 0.297, 0.516, 0.053, 13.645, 721, Load block from database 26.458, 0.000, 26.458, 26.458, 1, Load state from database 20.737, 8.288, 11.096, 199.325, 690, Apply block 333.069, 62.798, 45.225, 429.452, 31, Apply epoch block 0.000, 0.000, 0.000, 0.000, 0, Database block store ``` ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release --passc:-flto --passl:-flto --stacktrace:off ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 23903.006, 0.000, 23903.006, 23903.006, 1, Initialize DB 0.253, 0.122, 0.047, 0.731, 721, Load block from database 24.455, 0.000, 24.455, 24.455, 1, Load state from database 18.734, 7.062, 10.346, 167.397, 690, Apply block 194.869, 33.175, 29.311, 226.981, 31, Apply epoch block ``` Epoch processing is heavy on both arithmetics and hash caching, both of which get a significant boost here. This makes sense: nim creates lots of small functions spread out over many C files. A much worse solution is to try to annotate code with `inline` - it copies functions to multiple C files but still doesn't do intermodule optimizations significantly limiting the compilers' ability to reason about the code, causing bloat and misrepresenting the usefulness of a function to the call frequency analysis that drives actual (C-compiler) inlining and many other optimizations. In particular, many nim functions are part of `system` or the `C` backend - stack tracing, memory allocation etc - nim's inlining system is pretty incomplete in that it does not deal with these and many other cases. * windows workaround * skip LTO on windows for now
2020-09-24 16:40:28 +00:00
else:
# On windows, LTO needs more love and attention so "gcc-ar" and "gcc-ranlib" are
# used for static libraries.
use LTO in release builds (#1661) * use LTO in release builds This significantly (40%) speeds up block replay and hashing - for example replaying first 1000 blocks, without/with LTO: ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 25468.481, 0.000, 25468.481, 25468.481, 1, Initialize DB 0.297, 0.516, 0.053, 13.645, 721, Load block from database 26.458, 0.000, 26.458, 26.458, 1, Load state from database 20.737, 8.288, 11.096, 199.325, 690, Apply block 333.069, 62.798, 45.225, 429.452, 31, Apply epoch block 0.000, 0.000, 0.000, 0.000, 0, Database block store ``` ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release --passc:-flto --passl:-flto --stacktrace:off ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 23903.006, 0.000, 23903.006, 23903.006, 1, Initialize DB 0.253, 0.122, 0.047, 0.731, 721, Load block from database 24.455, 0.000, 24.455, 24.455, 1, Load state from database 18.734, 7.062, 10.346, 167.397, 690, Apply block 194.869, 33.175, 29.311, 226.981, 31, Apply epoch block ``` Epoch processing is heavy on both arithmetics and hash caching, both of which get a significant boost here. This makes sense: nim creates lots of small functions spread out over many C files. A much worse solution is to try to annotate code with `inline` - it copies functions to multiple C files but still doesn't do intermodule optimizations significantly limiting the compilers' ability to reason about the code, causing bloat and misrepresenting the usefulness of a function to the call frequency analysis that drives actual (C-compiler) inlining and many other optimizations. In particular, many nim functions are part of `system` or the `C` backend - stack tracing, memory allocation etc - nim's inlining system is pretty incomplete in that it does not deal with these and many other cases. * windows workaround * skip LTO on windows for now
2020-09-24 16:40:28 +00:00
discard
# show C compiler warnings
if defined(cwarnings):
let common_gcc_options = "-Wno-discarded-qualifiers -Wno-incompatible-pointer-types"
if defined(windows):
put("gcc.options.always", "-mno-ms-bitfields " & common_gcc_options)
put("clang.options.always", "-mno-ms-bitfields " & common_gcc_options)
else:
put("gcc.options.always", common_gcc_options)
put("clang.options.always", common_gcc_options)
if defined(limitStackUsage):
# This limits stack usage of each individual function to 1MB - the option is
# available on some GCC versions but not all - run with `-d:limitStackUsage`
# and look for .su files in "./build/", "./nimcache/" or $TMPDIR that list the
# stack size of each function.
switch("passC", "-fstack-usage -Werror=stack-usage=1048576")
switch("passL", "-fstack-usage -Werror=stack-usage=1048576")
if defined(windows):
# disable timestamps in Windows PE headers - https://wiki.debian.org/ReproducibleBuilds/TimestampsInPEBinaries
switch("passL", "-Wl,--no-insert-timestamp")
2019-04-11 21:30:26 +00:00
# increase stack size
switch("passL", "-Wl,--stack,8388608")
2019-04-24 23:49:41 +00:00
# https://github.com/nim-lang/Nim/issues/4057
--tlsEmulation:off
if defined(i386):
# set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag so we can use PAE, if enabled, and access more than 2 GiB of RAM
switch("passL", "-Wl,--large-address-aware")
# The dynamic Chronicles output currently prevents us from using colors on Windows
# because these require direct manipulations of the stdout File object.
switch("define", "chronicles_colors=off")
# Avoid some rare stack corruption while using exceptions with a SEH-enabled
# toolchain: https://github.com/status-im/nimbus-eth2/issues/3121
switch("define", "nimRawSetjmp")
2020-02-05 17:20:05 +00:00
# This helps especially for 32-bit x86, which sans SSE2 and newer instructions
# requires quite roundabout code generation for cryptography, and other 64-bit
# and larger arithmetic use cases, along with register starvation issues. When
# engineering a more portable binary release, this should be tweaked but still
# use at least -msse2 or -msse3.
#
# https://github.com/status-im/nimbus-eth2/blob/stable/docs/cpu_features.md#ssse3-supplemental-sse3
# suggests that SHA256 hashing with SSSE3 is 20% faster than without SSSE3, so
# given its near-ubiquity in the x86 installed base, it renders a distribution
# build more viable on an overall broader range of hardware.
#
if defined(disableMarchNative):
if defined(i386) or defined(amd64):
if defined(macosx):
# https://support.apple.com/kb/SP777
# "macOS Mojave - Technical Specifications": EOL as of 2021-10
# https://support.apple.com/kb/SP803
# "macOS Catalina - Technical Specifications" lists current oldest
# supported models: MacBook Air (Mid 2012 or newer), MacBook Pro
# (Mid 2012 or newer), Mac mini (Late 2012 or newer), and iMac (Late 2012
# or newer). These all have Ivy Bridge CPUs or newer.
#
# This ensures AVX, AES, PCLMUL, FSGSBASE, RDRND, and F16C instruction
# set support.
switch("passC", "-march=ivybridge")
switch("passL", "-march=ivybridge")
else:
switch("passC", "-mssse3")
switch("passL", "-mssse3")
elif defined(macosx) and defined(arm64):
# Apple's Clang can't handle "-march=native" on M1: https://github.com/status-im/nimbus-eth2/issues/2758
switch("passC", "-mcpu=apple-a14")
switch("passL", "-mcpu=apple-a14")
else:
switch("passC", "-march=native")
use LTO in release builds (#1661) * use LTO in release builds This significantly (40%) speeds up block replay and hashing - for example replaying first 1000 blocks, without/with LTO: ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 25468.481, 0.000, 25468.481, 25468.481, 1, Initialize DB 0.297, 0.516, 0.053, 13.645, 721, Load block from database 26.458, 0.000, 26.458, 26.458, 1, Load state from database 20.737, 8.288, 11.096, 199.325, 690, Apply block 333.069, 62.798, 45.225, 429.452, 31, Apply epoch block 0.000, 0.000, 0.000, 0.000, 0, Database block store ``` ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release --passc:-flto --passl:-flto --stacktrace:off ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 23903.006, 0.000, 23903.006, 23903.006, 1, Initialize DB 0.253, 0.122, 0.047, 0.731, 721, Load block from database 24.455, 0.000, 24.455, 24.455, 1, Load state from database 18.734, 7.062, 10.346, 167.397, 690, Apply block 194.869, 33.175, 29.311, 226.981, 31, Apply epoch block ``` Epoch processing is heavy on both arithmetics and hash caching, both of which get a significant boost here. This makes sense: nim creates lots of small functions spread out over many C files. A much worse solution is to try to annotate code with `inline` - it copies functions to multiple C files but still doesn't do intermodule optimizations significantly limiting the compilers' ability to reason about the code, causing bloat and misrepresenting the usefulness of a function to the call frequency analysis that drives actual (C-compiler) inlining and many other optimizations. In particular, many nim functions are part of `system` or the `C` backend - stack tracing, memory allocation etc - nim's inlining system is pretty incomplete in that it does not deal with these and many other cases. * windows workaround * skip LTO on windows for now
2020-09-24 16:40:28 +00:00
switch("passL", "-march=native")
if defined(windows):
2020-02-11 23:36:54 +00:00
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65782
# ("-fno-asynchronous-unwind-tables" breaks Nim's exception raising, sometimes)
switch("passC", "-mno-avx512f")
use LTO in release builds (#1661) * use LTO in release builds This significantly (40%) speeds up block replay and hashing - for example replaying first 1000 blocks, without/with LTO: ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 25468.481, 0.000, 25468.481, 25468.481, 1, Initialize DB 0.297, 0.516, 0.053, 13.645, 721, Load block from database 26.458, 0.000, 26.458, 26.458, 1, Load state from database 20.737, 8.288, 11.096, 199.325, 690, Apply block 333.069, 62.798, 45.225, 429.452, 31, Apply epoch block 0.000, 0.000, 0.000, 0.000, 0, Database block store ``` ``` [arnetheduck@tempus ncli]$ ../env.sh nim c -d:release --passc:-flto --passl:-flto --stacktrace:off ncli_db [arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000 Loaded 215006 blocks, head slot 307400 All time are ms Average, StdDev, Min, Max, Samples, Test Validation is turned off meaning that no BLS operations are performed 23903.006, 0.000, 23903.006, 23903.006, 1, Initialize DB 0.253, 0.122, 0.047, 0.731, 721, Load block from database 24.455, 0.000, 24.455, 24.455, 1, Load state from database 18.734, 7.062, 10.346, 167.397, 690, Apply block 194.869, 33.175, 29.311, 226.981, 31, Apply epoch block ``` Epoch processing is heavy on both arithmetics and hash caching, both of which get a significant boost here. This makes sense: nim creates lots of small functions spread out over many C files. A much worse solution is to try to annotate code with `inline` - it copies functions to multiple C files but still doesn't do intermodule optimizations significantly limiting the compilers' ability to reason about the code, causing bloat and misrepresenting the usefulness of a function to the call frequency analysis that drives actual (C-compiler) inlining and many other optimizations. In particular, many nim functions are part of `system` or the `C` backend - stack tracing, memory allocation etc - nim's inlining system is pretty incomplete in that it does not deal with these and many other cases. * windows workaround * skip LTO on windows for now
2020-09-24 16:40:28 +00:00
switch("passL", "-mno-avx512f")
2020-02-05 17:20:05 +00:00
# omitting frame pointers in nim breaks the GC
# https://github.com/nim-lang/Nim/issues/10625
switch("passC", "-fno-omit-frame-pointer")
switch("passL", "-fno-omit-frame-pointer")
--threads:on
--opt:speed
--excessiveStackTrace:on
# enable metric collection
--define:metrics
Logging and startup improvements (#3038) * Logging and startup improvements Color support for released binaries! * startup scripts no longer log to file by default - this only affects source builds - released binaries don't support file logging * add --log-stdout option to control logging to stdout (colors, json) * detect tty:s vs redirected logs and log accordingly * add option to disable log colors at runtime * simplify several "common" logs, showing the most important information earlier and more clearly * remove line numbers / file information / tid - these take up space and are of little use to end users * still enabled in debug builds and tools * remove `testnet_servers_image` compile-time option * server images, released binaries and compile-from-source now offer the same behaviour and features * fixes https://github.com/status-im/nimbus-eth2/issues/2326 * fixes https://github.com/status-im/nimbus-eth2/issues/1794 * remove instanteneous block speed from sync message, keeping only average before: ``` INF 2021-10-28 16:45:59.000+02:00 Slot start topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:884 lastSlot=2384027 wallSlot=2384028 delay=461us84ns peers=0 head=75a10ee5:3348 headEpoch=104 finalized=cd6804ba:3264 finalizedEpoch=102 sync="wwwwwwwwww:0:0.0000:0.0000:00h00m (3348)" INF 2021-10-28 16:45:59.046+02:00 Slot end topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:821 slot=2384028 nextSlot=2384029 head=75a10ee5:3348 headEpoch=104 finalizedHead=cd6804ba:3264 finalizedEpoch=102 nextAttestationSlot=-1 nextProposalSlot=-1 nextActionWait=n/a ``` after: ``` INF 2021-10-28 22:43:23.033+02:00 Slot start topics="beacnde" slot=2385815 epoch=74556 sync="DDPDDPUDDD:10:5.2258:01h19m (2361088)" peers=37 head=eacd2dae:2361096 finalized=73782:a4751487 delay=33ms687us715ns INF 2021-10-28 22:43:23.291+02:00 Slot end topics="beacnde" slot=2385815 nextActionWait=n/a nextAttestationSlot=-1 nextProposalSlot=-1 head=eacd2dae:2361096 ``` * fix comment * documentation updates * mention `--log-file` may be deprecated in the future * update various docs
2021-11-02 17:06:36 +00:00
--define:chronicles_line_numbers # These are disabled for release binaries
2020-03-28 22:04:43 +00:00
# for heap-usage-by-instance-type metrics and object base-type strings
--define:nimTypeNames
2019-11-12 23:22:21 +00:00
2020-06-11 16:41:43 +00:00
const currentDir = currentSourcePath()[0 .. ^(len("config.nims") + 1)]
switch("define", "nim_compiler_path=" & currentDir & "env.sh nim")
switch("define", "withoutPCRE")
2020-06-11 16:41:43 +00:00
switch("import", "testutils/moduletests")
when not defined(disable_libbacktrace):
--define:nimStackTraceOverride
switch("import", "libbacktrace")
else:
--stacktrace:on
--linetrace:on
2021-05-19 06:38:13 +00:00
var canEnableDebuggingSymbols = true
if defined(macosx):
# The default open files limit is too low on macOS (512), breaking the
# "--debugger:native" build. It can be increased with `ulimit -n 1024`.
let openFilesLimitTarget = 1024
var openFilesLimit = 0
try:
openFilesLimit = staticExec("ulimit -n").strip(chars = Whitespace + Newlines).parseInt()
if openFilesLimit < openFilesLimitTarget:
echo "Open files limit too low to enable debugging symbols and lightweight stack traces."
echo "Increase it with \"ulimit -n " & $openFilesLimitTarget & "\""
canEnableDebuggingSymbols = false
except:
echo "ulimit error"
# We ignore this resource limit on Windows, where a default `ulimit -n` of 256
# in Git Bash is apparently ignored by the OS, and on Linux where the default of
# 1024 is good enough for us.
if canEnableDebuggingSymbols:
2019-11-12 17:05:05 +00:00
# add debugging symbols and original files and line numbers
--debugger:native
--define:nimOldCaseObjects # https://github.com/status-im/nim-confutils/issues/9
# `switch("warning[CaseTransition]", "off")` fails with "Error: invalid command line option: '--warning[CaseTransition]'"
switch("warning", "CaseTransition:off")
2020-06-03 12:49:32 +00:00
# The compiler doth protest too much, methinks, about all these cases where it can't
# do its (N)RVO pass: https://github.com/nim-lang/RFCs/issues/230
switch("warning", "ObservableStores:off")
# Too many false positives for "Warning: method has lock level <unknown>, but another method has 0 [LockLevel]"
switch("warning", "LockLevel:off")
# Useful for Chronos metrics.
#--define:chronosFutureTracking
# ############################################################
#
# No LTO for crypto
#
# ############################################################
# This applies per-file compiler flags to C files
# which do not support {.localPassC: "-fno-lto".}
# Unfortunately this is filename based instead of path-based
# Assumes GCC
# BLST
put("server.always", "-fno-lto")
put("assembly.always", "-fno-lto")
# Secp256k1
put("secp256k1.always", "-fno-lto")
# BearSSL - only RNGs
put("aesctr_drbg.always", "-fno-lto")
put("hmac_drbg.always", "-fno-lto")
put("sysrng.always", "-fno-lto")
# Miracl - only ECP to derive public key from private key
put("ecp_BLS12381.always", "-fno-lto")
# ############################################################
#
# Spurious warnings
#
# ############################################################
# sqlite3.c: In function sqlite3SelectNew:
# vendor/nim-sqlite3-abi/sqlite3.c:124500: warning: function may return address of local variable [-Wreturn-local-addr]
put("sqlite3.always", "-fno-lto") # -Wno-return-local-addr