From 8568ec35eaf8fa558f2ce9677f35d8bdabde71ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Thu, 13 Feb 2020 20:18:27 +0100 Subject: [PATCH] enable -march=native by default plus some drive-by fixes and cosmetic changes --- Makefile | 32 +++++++++++++++++++++++++++++--- config.nims | 10 ++++++++++ nimbus.nimble | 20 +++++++++++--------- vendor/nim-json-rpc | 2 +- vendor/nim-libbacktrace | 2 +- vendor/nimbus-build-system | 2 +- 6 files changed, 53 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index fc37691f4..0b4870d36 100644 --- a/Makefile +++ b/Makefile @@ -14,15 +14,41 @@ BUILD_SYSTEM_DIR := vendor/nimbus-build-system -include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk # debugging tools + testing tools -TOOLS := premix persist debug dumper hunter regress tracerTestGen persistBlockTestGen -TOOLS_DIRS := premix tests waku +TOOLS := \ + premix \ + persist \ + debug \ + dumper \ + hunter \ + regress \ + tracerTestGen \ + persistBlockTestGen +TOOLS_DIRS := \ + premix \ + tests \ + waku # comma-separated values for the "clean" target TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS)) + # "--import" can't be added to config.nims, for some reason # "--define:release" implies "--stacktrace:off" and it cannot be added to config.nims either NIM_PARAMS := $(NIM_PARAMS) -d:release --import:libbacktrace -.PHONY: all $(TOOLS) build-system-checks deps update nimbus test test-reproducibility clean libnimbus.so libnimbus.a wrappers wrappers-static libbacktrace +.PHONY: \ + all \ + $(TOOLS) \ + build-system-checks \ + deps \ + update \ + nimbus \ + test \ + test-reproducibility \ + clean \ + libnimbus.so \ + libnimbus.a \ + wrappers \ + wrappers-static \ + libbacktrace # default target, because it's the first one that doesn't start with '.' all: build-system-checks $(TOOLS) nimbus diff --git a/config.nims b/config.nims index 62617f21d..9ba7b13c4 100644 --- a/config.nims +++ b/config.nims @@ -14,6 +14,16 @@ if defined(windows): # 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") +# remember to disable -march=native for reproducible builds +if defined(disableMarchNative): + switch("passC", "-msse3") +else: + switch("passC", "-march=native") + if defined(windows): + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65782 + # ("-fno-asynchronous-unwind-tables" breaks Nim's exception raising, sometimes) + switch("passC", "-mno-avx512vl") + --threads:on --opt:speed --excessiveStackTrace:on diff --git a/nimbus.nimble b/nimbus.nimble index 2e090d9e2..9c10b6249 100644 --- a/nimbus.nimble +++ b/nimbus.nimble @@ -10,14 +10,15 @@ skipDirs = @["tests", "examples"] # bin = @["build/nimbus"] requires "nim >= 0.19", - "chronicles", - "nimcrypto", - "stint", - "json_rpc", - "chronos", - "bncurve", - "eth", - "stew" + "bncurve", + "chronicles", + "chronos", + "eth", + "json_rpc", + "libbacktrace", + "nimcrypto", + "stew", + "stint" proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = if not dirExists "build": @@ -26,7 +27,7 @@ proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = var extra_params = params for i in 2..