Skip to content

Commit 1fa65a7

Browse files
authored
Allow compiler overrides & only use some flags for clang (#633)
1 parent d3185a2 commit 1fa65a7

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

.github/workflows/c-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
# Doesn't work on Windows.
5454
- name: Clang Sanitizers
5555
if: matrix.os != 'windows-latest'
56-
run: make sanitize
56+
run: CC=clang make sanitize
5757

5858
# Run static analyzer.
5959
# Doesn't work on Windows.

src/Makefile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ifeq ($(PLATFORM),Darwin)
2020
endif
2121

2222
# The base compiler flags. More can be added on command line.
23-
CFLAGS += -I. -I../inc -O2 -Werror -Wno-gnu-folding-constant
23+
CFLAGS += -I. -I../inc -O2
2424
# Enable a bunch of optional warnings.
2525
CFLAGS += \
2626
-pedantic \
@@ -43,6 +43,7 @@ CFLAGS += \
4343
-Winit-self \
4444
-Winline \
4545
-Winvalid-pch \
46+
-Wmissing-braces \
4647
-Wmissing-declarations \
4748
-Wmissing-field-initializers \
4849
-Wmissing-format-attribute \
@@ -75,13 +76,15 @@ CFLAGS += \
7576

7677
# Cross-platform compilation settings.
7778
ifeq ($(PLATFORM),Windows)
78-
CC = gcc
79+
CC ?= gcc
7980
CFLAGS += -D_CRT_SECURE_NO_WARNINGS
80-
CFLAGS += -Wno-missing-braces -Wno-format
81+
CFLAGS += -Wno-format
8182
else
82-
CC = clang
83+
CC ?= clang
8384
CFLAGS += -fPIC
84-
CFLAGS += -Wmissing-braces -Wformat=2
85+
ifeq ($(CC),clang)
86+
CFLAGS += -Werror -Wno-gnu-folding-constant -Wformat=2
87+
endif
8588
endif
8689

8790
# Settings for blst.
@@ -219,7 +222,10 @@ sanitize_%: blst $(SOURCE_FILES) $(HEADER_FILES)
219222
./$@; rm $@
220223

221224
.PHONY: sanitize
222-
ifeq ($(PLATFORM),Darwin)
225+
ifneq ($(CC),clang)
226+
sanitize:
227+
$(error sanitize requires CC=clang)
228+
else ifeq ($(PLATFORM),Darwin)
223229
sanitize: \
224230
sanitize_address \
225231
sanitize_undefined

src/common/ec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ typedef blst_p2 g2_t; /**< Internal G2 group element type. */
3232

3333
/** Deserialized form of the G1 identity/infinity point. */
3434
static const g1_t G1_IDENTITY = {
35-
{0L, 0L, 0L, 0L, 0L, 0L}, {0L, 0L, 0L, 0L, 0L, 0L}, {0L, 0L, 0L, 0L, 0L, 0L}
35+
{{0L, 0L, 0L, 0L, 0L, 0L}}, {{0L, 0L, 0L, 0L, 0L, 0L}}, {{0L, 0L, 0L, 0L, 0L, 0L}}
3636
};
3737

3838
////////////////////////////////////////////////////////////////////////////////////////////////////

src/common/fr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ typedef blst_fr fr_t; /**< Internal Fr field element type. */
4141
////////////////////////////////////////////////////////////////////////////////////////////////////
4242

4343
/** The zero field element. */
44-
static const fr_t FR_ZERO = {0L, 0L, 0L, 0L};
44+
static const fr_t FR_ZERO = {{0L, 0L, 0L, 0L}};
4545

4646
/** This is 1 in blst's `blst_fr` limb representation. Crazy but true. */
4747
static const fr_t FR_ONE = {
48-
0x00000001fffffffeL, 0x5884b7fa00034802L, 0x998c4fefecbc4ff5L, 0x1824b159acc5056fL
48+
{0x00000001fffffffeL, 0x5884b7fa00034802L, 0x998c4fefecbc4ff5L, 0x1824b159acc5056fL}
4949
};
5050

5151
/** This used to represent a missing element. It's an invalid value. */
5252
static const fr_t FR_NULL = {
53-
0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
53+
{0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL}
5454
};
5555

5656
////////////////////////////////////////////////////////////////////////////////////////////////////

src/eip7594/fft.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* printf("%#018llxL,\n", a.l[i]);
3636
*/
3737
static const fr_t RECOVERY_SHIFT_FACTOR = {
38-
0x0000000efffffff1L, 0x17e363d300189c0fL, 0xff9c57876f8457b0L, 0x351332208fc5a8c4L
38+
{0x0000000efffffff1L, 0x17e363d300189c0fL, 0xff9c57876f8457b0L, 0x351332208fc5a8c4L}
3939
};
4040

4141
/**
@@ -48,7 +48,7 @@ static const fr_t RECOVERY_SHIFT_FACTOR = {
4848
* printf("%#018llxL,\n", a.l[i]);
4949
*/
5050
static const fr_t INV_RECOVERY_SHIFT_FACTOR = {
51-
0xdb6db6dadb6db6dcL, 0xe6b5824adb6cc6daL, 0xf8b356e005810db9L, 0x66d0f1e660ec4796L
51+
{0xdb6db6dadb6db6dcL, 0xe6b5824adb6cc6daL, 0xf8b356e005810db9L, 0x66d0f1e660ec4796L}
5252
};
5353

5454
////////////////////////////////////////////////////////////////////////////////////////////////////

src/setup/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
* factor changes, this constant is no longer correct.
8080
*/
8181
static const fr_t ROOT_OF_UNITY = {
82-
0xa33d279ff0ccffc9L, 0x41fac79f59e91972L, 0x065d227fead1139bL, 0x71db41abda03e055L
82+
{0xa33d279ff0ccffc9L, 0x41fac79f59e91972L, 0x065d227fead1139bL, 0x71db41abda03e055L}
8383
};
8484

8585
////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)