mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-29 13:35:38 +00:00
8161de1a8f
We can't use `ulimit -s` to limit stack size on Windows. Even though Bash accepts `ulimit -s` and the numbers change it has no effect and is not passed to child processes. (See https://public-inbox.org/git/alpine.DEB.2.21.1.1709131448390.4132@virtualbox/) Instead, set it when building the test executable, following, a suggestion from @stefantalpalaru. https://github.com/status-im/nimbus-eth1/pull/598#discussion_r621107128 To ensure no conflict with `config.nims`, `-d:windowsNoSetStack` is used. This proved unnecessary in practice because the command-line option is passed to the linker after the config file option. But given we don't have an automated test to verify linker behaviour, it's best not to rely on the option order, neither how the linker treats it, or whether Nim will always send them in that order. Testing: This has been verified by using a smaller limit. At 200k, all `ENABLE_EVMC=0` OS targets passed as expected, and all `ENABLE_EVMC=1` OS targets failed with expected kinds of errors due to stack overflow, including Windows. (400k wasn't small enough; 32-bit x86 Windows passed on that). Signed-off-by: Jamie Lokier <jamie@shareable.org>
55 lines
1.9 KiB
Nim
55 lines
1.9 KiB
Nim
mode = ScriptMode.Verbose
|
|
|
|
packageName = "nimbus"
|
|
version = "0.1.0"
|
|
author = "Status Research & Development GmbH"
|
|
description = "An Ethereum 2.0 Sharding Client for Resource-Restricted Devices"
|
|
license = "Apache License 2.0"
|
|
skipDirs = @["tests", "examples"]
|
|
# we can't have the result of a custom task in the "bin" var - https://github.com/nim-lang/nimble/issues/542
|
|
# bin = @["build/nimbus"]
|
|
|
|
requires "nim >= 1.2.0",
|
|
"bncurve",
|
|
"chronicles",
|
|
"chronos",
|
|
"eth",
|
|
"json_rpc",
|
|
"libbacktrace",
|
|
"nimcrypto",
|
|
"stew",
|
|
"stint"
|
|
|
|
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
|
|
if not dirExists "build":
|
|
mkDir "build"
|
|
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
|
var extra_params = params
|
|
for i in 2..<paramCount():
|
|
extra_params &= " " & paramStr(i)
|
|
exec "nim " & lang & " --out:build/" & name & " " & extra_params & " " & srcDir & name & ".nim"
|
|
|
|
proc test(name: string, lang = "c") =
|
|
# Verify stack usage is kept low by setting 750k stack limit in tests.
|
|
const stackLimitKiB = 750
|
|
when not defined(windows):
|
|
const (buildOption, runPrefix) = ("", "ulimit -s " & $stackLimitKiB & " && ")
|
|
else:
|
|
# No `ulimit` in Windows. `ulimit -s` in Bash is accepted but has no effect.
|
|
# See https://public-inbox.org/git/alpine.DEB.2.21.1.1709131448390.4132@virtualbox/
|
|
# Also, the command passed to NimScript `exec` on Windows is not a shell script.
|
|
# Instead, we can set stack size at link time.
|
|
const (buildOption, runPrefix) =
|
|
(" -d:windowsNoSetStack --passL:-Wl,--stack," & $(stackLimitKiB * 1024), "")
|
|
|
|
buildBinary name, "tests/", "-d:chronicles_log_level=ERROR" & buildOption
|
|
exec runPrefix & "build/" & name
|
|
|
|
task test, "Run tests":
|
|
test "all_tests"
|
|
test "test_rpc"
|
|
test "test_rpc_whisper"
|
|
|
|
task nimbus, "Build Nimbus":
|
|
buildBinary "nimbus", "nimbus/", "-d:chronicles_log_level=TRACE"
|