Improve default settings and documentation
This commit is contained in:
parent
9281022f1d
commit
36af387bea
|
@ -23,9 +23,9 @@ fn main() {
|
||||||
.flag_if_supported("-Wno-unused-parameter") // patching out printf causes this warning
|
.flag_if_supported("-Wno-unused-parameter") // patching out printf causes this warning
|
||||||
.define("SECP256K1_API", Some(""))
|
.define("SECP256K1_API", Some(""))
|
||||||
.define("ENABLE_MODULE_ECDH", Some("1"))
|
.define("ENABLE_MODULE_ECDH", Some("1"))
|
||||||
.define("ENABLE_MODULE_SCHNORRSIG", Some("1"))
|
.define("ENABLE_MODULE_SCHNORRSIG", Some("0"))
|
||||||
.define("ENABLE_MODULE_EXTRAKEYS", Some("1"))
|
.define("ENABLE_MODULE_EXTRAKEYS", Some("0"))
|
||||||
.define("ENABLE_MODULE_ELLSWIFT", Some("1"))
|
.define("ENABLE_MODULE_ELLSWIFT", Some("0"))
|
||||||
// upstream sometimes introduces calls to printf, which we cannot compile
|
// upstream sometimes introduces calls to printf, which we cannot compile
|
||||||
// with WASM due to its lack of libc. printf is never necessary and we can
|
// with WASM due to its lack of libc. printf is never necessary and we can
|
||||||
// just #define it away.
|
// just #define it away.
|
||||||
|
@ -42,22 +42,18 @@ fn main() {
|
||||||
|
|
||||||
// going from the default 4 to 8 is a huge performance increase
|
// going from the default 4 to 8 is a huge performance increase
|
||||||
// when combined with other optimizations
|
// when combined with other optimizations
|
||||||
base_config.define("ECMULT_GEN_PREC_BITS", Some("8"));
|
// base_config.define("ECMULT_GEN_PREC_BITS", Some("8"));
|
||||||
|
|
||||||
// TODO highly experimental
|
// TODO highly experimental
|
||||||
// non-standard optimization
|
// non-standard optimization
|
||||||
// slow compilation
|
// slow compilation
|
||||||
// base_config.define("ECMULT_GEN_PREC_BITS", Some("16"));
|
base_config.define("ECMULT_GEN_PREC_BITS", Some("16"));
|
||||||
|
|
||||||
// minor factor, the 15 default is already optimized
|
// ECMULT_WINDOW_SIZE has only a minor performance impact
|
||||||
|
// the default value of 15 is already optimized and would be acceptable
|
||||||
|
// values 14, 16, 17 don't result in a meaningful speedup
|
||||||
base_config.define("ECMULT_WINDOW_SIZE", Some("15")); // This is the default in the configure file (`auto`)
|
base_config.define("ECMULT_WINDOW_SIZE", Some("15")); // This is the default in the configure file (`auto`)
|
||||||
|
// base_config.define("ECMULT_WINDOW_SIZE", Some("19"));
|
||||||
// TODO do some fine tuning for a slightly higher than default ECMULT_WINDOW_SIZE
|
|
||||||
// base_config.define("ECMULT_WINDOW_SIZE", Some("17"));
|
|
||||||
// base_config.define("ECMULT_WINDOW_SIZE", Some("18"));
|
|
||||||
|
|
||||||
// too large
|
|
||||||
// base_config.define("ECMULT_WINDOW_SIZE", Some("22"));
|
|
||||||
}
|
}
|
||||||
base_config.define("USE_EXTERNAL_DEFAULT_CALLBACKS", Some("1"));
|
base_config.define("USE_EXTERNAL_DEFAULT_CALLBACKS", Some("1"));
|
||||||
#[cfg(feature = "recovery")]
|
#[cfg(feature = "recovery")]
|
||||||
|
@ -75,20 +71,27 @@ fn main() {
|
||||||
.file("depend/secp256k1/src/precomputed_ecmult.c")
|
.file("depend/secp256k1/src/precomputed_ecmult.c")
|
||||||
.file("depend/secp256k1/src/secp256k1.c");
|
.file("depend/secp256k1/src/secp256k1.c");
|
||||||
|
|
||||||
|
|
||||||
// default CC is gcc on the tested system
|
// default CC is gcc on the tested system
|
||||||
// GCC 12.2 slightly faster than clang-18 for the unmodified code?
|
// observation: GCC 12.2 slightly faster than clang-18 for the unmodified code
|
||||||
|
// observation: clang-14 is slightly faster than gcc 12.2 for the modified code
|
||||||
|
|
||||||
// for the modified code, clang is slightly faster?
|
// on the tested system, the compilers don't default to use some -fstack-protector level
|
||||||
|
// therefore the use of -fno-stack-protector isn't necessary
|
||||||
|
|
||||||
// // force clang
|
// force use of clang
|
||||||
base_config.compiler("clang");
|
base_config.compiler("clang");
|
||||||
|
|
||||||
// // gcc is faster without native CPU settings on a Ryzen Zen 3 desktop CPU
|
// gcc 12.2 is faster without this setting on Ryzen Zen 3/4 CPUs
|
||||||
base_config.flag("-march=native");
|
base_config.flag("-march=native");
|
||||||
|
|
||||||
// doesn't work as-is
|
// doesn't work yet
|
||||||
|
// relevant:
|
||||||
|
// RUSTFLAGS="-Clink-args=-fuse-ld=lld"
|
||||||
|
// installing the lld tool package
|
||||||
|
// for lto=thin, there are problems with "Opaque pointers are only supported in -opaque-pointers mode"
|
||||||
|
// for lto=fat, there are some problems with "error: undefined symbol"
|
||||||
// base_config.flag("-flto=thin");
|
// base_config.flag("-flto=thin");
|
||||||
|
// base_config.flag("-flto=fat");
|
||||||
|
|
||||||
// shouldn't do much
|
// shouldn't do much
|
||||||
base_config.define("NDEBUG", Some(""));
|
base_config.define("NDEBUG", Some(""));
|
||||||
|
@ -106,6 +109,7 @@ fn main() {
|
||||||
// -O3 seems to be better than -O2 for clang
|
// -O3 seems to be better than -O2 for clang
|
||||||
// -O3 is already the default for --release builds
|
// -O3 is already the default for --release builds
|
||||||
// set anyway so that rust non-release builds don't fall back to -O1 here
|
// set anyway so that rust non-release builds don't fall back to -O1 here
|
||||||
|
// base_config.flag("-O3");
|
||||||
base_config.flag("-O3");
|
base_config.flag("-O3");
|
||||||
|
|
||||||
// base_config.flag("-O1");
|
// base_config.flag("-O1");
|
||||||
|
@ -115,12 +119,11 @@ fn main() {
|
||||||
// the default seems to set -gdwarf-4
|
// the default seems to set -gdwarf-4
|
||||||
// slightly worse on gcc?
|
// slightly worse on gcc?
|
||||||
// slightly better on clang-18 ?
|
// slightly better on clang-18 ?
|
||||||
// base_config.flag("-g0");
|
base_config.flag("-g0");
|
||||||
|
|
||||||
// potential minor improvement
|
// potential minor improvement
|
||||||
// to counteract the -fno-omit-frame-pointer
|
// to counteract the -fno-omit-frame-pointer
|
||||||
// base_config.flag("-fomit-frame-pointer");
|
base_config.flag("-fomit-frame-pointer");
|
||||||
|
|
||||||
|
|
||||||
if base_config.try_compile("libsecp256k1.a").is_err() {
|
if base_config.try_compile("libsecp256k1.a").is_err() {
|
||||||
// Some embedded platforms may not have, eg, string.h available, so if the build fails
|
// Some embedded platforms may not have, eg, string.h available, so if the build fails
|
||||||
|
@ -129,6 +132,4 @@ fn main() {
|
||||||
// base_config.include("wasm/wasm-sysroot");
|
// base_config.include("wasm/wasm-sysroot");
|
||||||
// base_config.compile("libsecp256k1.a");
|
// base_config.compile("libsecp256k1.a");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue