Skip to content

Commit 09971a3

Browse files
committed
Merge #1047: ci: Various improvements
b4ac1a1 ci: Run valgrind/memcheck tasks with 2 CPUs (Tim Ruffing) e70acab ci: Use Cirrus "greedy" flag to use idle CPU time when available (Tim Ruffing) d07e301 ci: Update brew on macOS (Tim Ruffing) 22382f0 ci: Test different ecmult window sizes (Tim Ruffing) 26a022a ci: Remove STATICPRECOMPUTATION (Tim Ruffing) 10461d8 precompute_ecmult: Always compute all tables up to default WINDOW_G (Tim Ruffing) Pull request description: ACKs for top commit: elichai: utACK b4ac1a1 jonasnick: ACK b4ac1a1 Tree-SHA512: b283d7b1c72cf87484de1fe98318298698fe9982dc33389eaca62e92318ab0074c183b9799add274f46358032491fee875e5ffb2a76a47f3b07520b850f4c85e
2 parents 0b83b20 + b4ac1a1 commit 09971a3

File tree

4 files changed

+61
-74
lines changed

4 files changed

+61
-74
lines changed

.cirrus.yml

+27-43
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ env:
44
# Specific warnings can be disabled with -Wno-error=foo.
55
# -pedantic-errors is not equivalent to -Werror=pedantic and thus not implied by -Werror according to the GCC manual.
66
WERROR_CFLAGS: -Werror -pedantic-errors
7-
MAKEFLAGS: -j2
7+
MAKEFLAGS: -j4
88
BUILD: check
99
### secp256k1 config
10-
STATICPRECOMPUTATION: yes
10+
ECMULTWINDOW: auto
1111
ECMULTGENPRECISION: auto
1212
ASM: no
1313
WIDEMUL: auto
@@ -50,14 +50,19 @@ merge_base_script_snippet: &MERGE_BASE
5050
- git config --global user.name "ci"
5151
- git merge FETCH_HEAD # Merge base to detect silent merge conflicts
5252

53-
task:
54-
name: "x86_64: Linux (Debian stable)"
53+
linux_container_snippet: &LINUX_CONTAINER
5554
container:
5655
dockerfile: ci/linux-debian.Dockerfile
5756
# Reduce number of CPUs to be able to do more builds in parallel.
5857
cpu: 1
58+
# Gives us more CPUs for free if they're available.
59+
greedy: true
5960
# More than enough for our scripts.
6061
memory: 1G
62+
63+
task:
64+
name: "x86_64: Linux (Debian stable)"
65+
<< : *LINUX_CONTAINER
6166
matrix: &ENV_MATRIX
6267
- env: {WIDEMUL: int64, RECOVERY: yes}
6368
- env: {WIDEMUL: int64, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
@@ -66,12 +71,11 @@ task:
6671
- env: {WIDEMUL: int128, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
6772
- env: {WIDEMUL: int128, ASM: x86_64}
6873
- env: { RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
69-
- env: { STATICPRECOMPUTATION: no}
7074
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
7175
- env: {CPPFLAGS: -DDETERMINISTIC}
7276
- env: {CFLAGS: -O0, CTIMETEST: no}
73-
- env: { ECMULTGENPRECISION: 2 }
74-
- env: { ECMULTGENPRECISION: 8 }
77+
- env: { ECMULTGENPRECISION: 2, ECMULTWINDOW: 2 }
78+
- env: { ECMULTGENPRECISION: 8, ECMULTWINDOW: 4 }
7579
matrix:
7680
- env:
7781
CC: gcc
@@ -84,10 +88,7 @@ task:
8488

8589
task:
8690
name: "i686: Linux (Debian stable)"
87-
container:
88-
dockerfile: ci/linux-debian.Dockerfile
89-
cpu: 1
90-
memory: 1G
91+
<< : *LINUX_CONTAINER
9192
env:
9293
HOST: i686-linux-gnu
9394
ECDH: yes
@@ -134,8 +135,9 @@ task:
134135
## - rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
135136
##
136137
brew_valgrind_pre_script:
138+
- brew update
137139
- brew config
138-
- brew tap --shallow LouisBrunner/valgrind
140+
- brew tap LouisBrunner/valgrind
139141
# Fetch valgrind source but don't build it yet.
140142
- brew fetch --HEAD LouisBrunner/valgrind/valgrind
141143
brew_valgrind_cache:
@@ -165,10 +167,7 @@ task:
165167

166168
task:
167169
name: "s390x (big-endian): Linux (Debian stable, QEMU)"
168-
container:
169-
dockerfile: ci/linux-debian.Dockerfile
170-
cpu: 1
171-
memory: 1G
170+
<< : *LINUX_CONTAINER
172171
env:
173172
WRAPPER_CMD: qemu-s390x
174173
SECP256K1_TEST_ITERS: 16
@@ -188,10 +187,7 @@ task:
188187

189188
task:
190189
name: "ARM32: Linux (Debian stable, QEMU)"
191-
container:
192-
dockerfile: ci/linux-debian.Dockerfile
193-
cpu: 1
194-
memory: 1G
190+
<< : *LINUX_CONTAINER
195191
env:
196192
WRAPPER_CMD: qemu-arm
197193
SECP256K1_TEST_ITERS: 16
@@ -212,10 +208,7 @@ task:
212208

213209
task:
214210
name: "ARM64: Linux (Debian stable, QEMU)"
215-
container:
216-
dockerfile: ci/linux-debian.Dockerfile
217-
cpu: 1
218-
memory: 1G
211+
<< : *LINUX_CONTAINER
219212
env:
220213
WRAPPER_CMD: qemu-aarch64
221214
SECP256K1_TEST_ITERS: 16
@@ -233,10 +226,7 @@ task:
233226

234227
task:
235228
name: "ppc64le: Linux (Debian stable, QEMU)"
236-
container:
237-
dockerfile: ci/linux-debian.Dockerfile
238-
cpu: 1
239-
memory: 1G
229+
<< : *LINUX_CONTAINER
240230
env:
241231
WRAPPER_CMD: qemu-ppc64le
242232
SECP256K1_TEST_ITERS: 16
@@ -254,10 +244,7 @@ task:
254244

255245
task:
256246
name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)"
257-
container:
258-
dockerfile: ci/linux-debian.Dockerfile
259-
cpu: 1
260-
memory: 1G
247+
<< : *LINUX_CONTAINER
261248
env:
262249
WRAPPER_CMD: wine64-stable
263250
SECP256K1_TEST_ITERS: 16
@@ -275,10 +262,7 @@ task:
275262

276263
# Sanitizers
277264
task:
278-
container:
279-
dockerfile: ci/linux-debian.Dockerfile
280-
cpu: 1
281-
memory: 2G
265+
<< : *LINUX_CONTAINER
282266
env:
283267
ECDH: yes
284268
RECOVERY: yes
@@ -287,11 +271,15 @@ task:
287271
CTIMETEST: no
288272
matrix:
289273
- name: "Valgrind (memcheck)"
274+
container:
275+
cpu: 2
290276
env:
291277
# The `--error-exitcode` is required to make the test fail if valgrind found errors, otherwise it'll return 0 (https://www.valgrind.org/docs/manual/manual-core.html)
292278
WRAPPER_CMD: "valgrind --error-exitcode=42"
293279
SECP256K1_TEST_ITERS: 2
294280
- name: "UBSan, ASan, LSan"
281+
container:
282+
memory: 2G
295283
env:
296284
CFLAGS: "-fsanitize=undefined,address -g"
297285
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1"
@@ -302,11 +290,10 @@ task:
302290
matrix:
303291
- env:
304292
ASM: auto
305-
STATICPRECOMPUTATION: yes
306293
- env:
307294
ASM: no
308-
STATICPRECOMPUTATION: no
309295
ECMULTGENPRECISION: 2
296+
ECMULTWINDOW: 2
310297
matrix:
311298
- env:
312299
CC: clang
@@ -320,15 +307,12 @@ task:
320307

321308
task:
322309
name: "C++ -fpermissive"
323-
container:
324-
dockerfile: ci/linux-debian.Dockerfile
325-
cpu: 1
326-
memory: 1G
310+
<< : *LINUX_CONTAINER
327311
env:
328312
# ./configure correctly errors out when given CC=g++.
329313
# We hack around this by passing CC=g++ only to make.
330314
CC: gcc
331-
MAKEFLAGS: -j2 CC=g++ CFLAGS=-fpermissive\ -g
315+
MAKEFLAGS: -j4 CC=g++ CFLAGS=-fpermissive\ -g
332316
WERROR_CFLAGS:
333317
EXPERIMENTAL: yes
334318
ECDH: yes

ci/cirrus.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ valgrind --version || true
1515
./configure \
1616
--enable-experimental="$EXPERIMENTAL" \
1717
--with-test-override-wide-multiply="$WIDEMUL" --with-asm="$ASM" \
18-
--enable-ecmult-static-precomputation="$STATICPRECOMPUTATION" --with-ecmult-gen-precision="$ECMULTGENPRECISION" \
18+
--with-ecmult-window="$ECMULTWINDOW" \
19+
--with-ecmult-gen-precision="$ECMULTGENPRECISION" \
1920
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
2021
--enable-module-schnorrsig="$SCHNORRSIG" \
2122
--with-valgrind="$WITH_VALGRIND" \

src/precompute_ecmult.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void print_table(FILE *fp, const char *name, int window_g, const secp256k
3232

3333
j = 1;
3434
for(i = 3; i <= window_g; ++i) {
35-
fprintf(fp, "#if ECMULT_TABLE_SIZE(WINDOW_G) > %ld\n", ECMULT_TABLE_SIZE(i-1));
35+
fprintf(fp, "#if WINDOW_G > %d\n", i-1);
3636
for(;j < ECMULT_TABLE_SIZE(i); ++j) {
3737
fprintf(fp, ",S(%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32
3838
",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32")\n",
@@ -57,6 +57,8 @@ static void print_two_tables(FILE *fp, int window_g) {
5757
}
5858

5959
int main(void) {
60+
/* Always compute all tables for window sizes up to 15. */
61+
int window_g = (ECMULT_WINDOW_SIZE < 15) ? 15 : ECMULT_WINDOW_SIZE;
6062
FILE* fp;
6163

6264
fp = fopen("src/precomputed_ecmult.c","w");
@@ -77,15 +79,15 @@ int main(void) {
7779
fprintf(fp, "#include \"ecmult.h\"\n");
7880
fprintf(fp, "#include \"precomputed_ecmult.h\"\n");
7981
fprintf(fp, "#define S(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SECP256K1_GE_STORAGE_CONST(0x##a##u,0x##b##u,0x##c##u,0x##d##u,0x##e##u,0x##f##u,0x##g##u,0x##h##u,0x##i##u,0x##j##u,0x##k##u,0x##l##u,0x##m##u,0x##n##u,0x##o##u,0x##p##u)\n");
80-
fprintf(fp, "#if ECMULT_TABLE_SIZE(ECMULT_WINDOW_SIZE) > %ld\n", ECMULT_TABLE_SIZE(ECMULT_WINDOW_SIZE));
82+
fprintf(fp, "#if ECMULT_WINDOW_SIZE > %d\n", window_g);
8183
fprintf(fp, " #error configuration mismatch, invalid ECMULT_WINDOW_SIZE. Try deleting precomputed_ecmult.c before the build.\n");
8284
fprintf(fp, "#endif\n");
8385
fprintf(fp, "#ifdef EXHAUSTIVE_TEST_ORDER\n");
8486
fprintf(fp, "# error Cannot compile precomputed_ecmult.c in exhaustive test mode\n");
8587
fprintf(fp, "#endif /* EXHAUSTIVE_TEST_ORDER */\n");
8688
fprintf(fp, "#define WINDOW_G ECMULT_WINDOW_SIZE\n");
8789

88-
print_two_tables(fp, ECMULT_WINDOW_SIZE);
90+
print_two_tables(fp, window_g);
8991

9092
fprintf(fp, "#undef S\n");
9193
fclose(fp);

0 commit comments

Comments
 (0)