build: show stderr by default

Also added: `-d:cwarnings` and `-d:limitStackUsage`
This commit is contained in:
Ștefan Talpalaru 2021-11-04 15:35:36 +01:00 committed by zah
parent 122055b65e
commit b09cd71348
4 changed files with 38 additions and 10 deletions

View File

@ -13,6 +13,10 @@ switch("nimcache", nimCachePath)
# `-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!
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")
if defined(macosx): # Clang
switch("passC", "-flto=thin")
switch("passL", "-flto=thin -Wl,-object_path_lto," & nimCachePath & "/lto")
@ -26,6 +30,23 @@ if defined(release) and not defined(disableLTO):
# used for static libraries.
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 "./nimcache/" 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")

View File

@ -139,7 +139,19 @@ make NIMFLAGS="-d:disableMarchNative" nimbus_beacon_node
make NIMFLAGS="-d:disableLTO" nimbus_beacon_node
```
- build a static binary
- show C compiler warnings:
```bash
make NIMFLAGS="-d:cwarnings" nimbus_beacon_node
```
- limit stack usage to 1 MiB per C function (static analysis - see the [GCC docs](https://gcc.gnu.org/onlinedocs/gnat_ugn/Static-Stack-Usage-Analysis.html); if LTO is enabled, it works without `-d:cwarnings`):
```bash
make NIMFLAGS="-d:limitStackUsage" nimbus_beacon_node
```
- build a static binary:
```bash
make NIMFLAGS="--passL:-static" nimbus_beacon_node
@ -151,18 +163,12 @@ make NIMFLAGS="--passL:-static" nimbus_beacon_node
make publish-book
```
- create a binary distribution
- create a binary distribution:
```bash
make dist
```
- test the binaries
```bash
make dist-test
```
## Multi-client interop scripts
[This repository](https://github.com/eth2-clients/multinet) contains a set of scripts used by the client implementation teams to test interop between the clients (in certain simplified scenarios). It mostly helps us find and debug issues.

View File

@ -23,7 +23,8 @@ PROJECT_NAME="$(basename ${SOURCE%.nim})"
# LTO on macOS, in "config.nims"
nim c --compileOnly -o:build/${BINARY} "$@" -d:nimCachePathOverride=nimcache/release/${BINARY} "${SOURCE}"
build/generate_makefile "nimcache/release/${BINARY}/${PROJECT_NAME}.json" "nimcache/release/${BINARY}/${BINARY}.makefile"
[[ "$V" == "0" ]] && exec &>/dev/null
# Don't swallow stderr, in case it's important.
[[ "$V" == "0" ]] && exec >/dev/null
"${MAKE}" -f "nimcache/release/${BINARY}/${BINARY}.makefile" --no-print-directory build
if uname | grep -qi darwin || [[ -n "${FORCE_DSYMUTIL}" ]]; then

@ -1 +1 @@
Subproject commit 9d6b4b6e98515af8248127f51889c24308006096
Subproject commit 5fbffb22859a85aa0dc3e9238cc03d92ab197682