Skip to content

Commit a1e999f

Browse files
committed
chore: Compile libsodium reference implementation with compcert.
This ensures that we're able to generate a guaranteed semantically correct binary with all of toxcore and libsodium. We don't currently compile libvpx and opus with compcert. Probably not worth the effort.
1 parent fbe3c19 commit a1e999f

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

other/docker/compcert/Makefile

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
1-
SOURCES := $(wildcard auto_tests/auto_test_support.c \
2-
auto_tests/send_message_test.c \
3-
testing/misc_tools.c \
4-
toxav/*.c \
5-
toxcore/*.c \
6-
toxcore/*/*.c \
7-
toxencryptsave/*.c \
8-
third_party/cmp/*.c)
1+
CC := ccomp
2+
CFLAGS := -Wall \
3+
-Wno-c11-extensions \
4+
-Wno-unknown-pragmas \
5+
-Wno-unused-variable \
6+
-fstruct-passing -fno-unprototyped -g \
7+
-Ilibsodium/src/libsodium/include \
8+
$(shell pkg-config --cflags opus vpx)
9+
LDFLAGS := -lpthread $(shell pkg-config --libs opus vpx)
910

10-
OBJECTS := $(SOURCES:.c=.o)
11+
libsodium_SOURCES := $(shell find libsodium/src/libsodium -name "*.c")
12+
libsodium_OBJECTS := $(libsodium_SOURCES:.c=.o)
1113

12-
CC := ccomp
13-
CFLAGS := -Wall -Werror \
14-
-Wno-c11-extensions \
15-
-Wno-unknown-pragmas \
16-
-Wno-unused-variable \
17-
-fstruct-passing -fno-unprototyped -g \
18-
-D__COMPCERT__ \
19-
-DDISABLE_VLA \
20-
-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
21-
-Dinline= \
22-
$(shell pkg-config --cflags libsodium opus vpx)
23-
LDFLAGS := -lpthread $(shell pkg-config --libs libsodium opus vpx)
14+
$(libsodium_OBJECTS): CFLAGS += \
15+
-DDEV_MODE \
16+
-DCONFIGURED \
17+
-D_DEFAULT_SOURCE \
18+
-Ilibsodium/builds/msvc \
19+
-Ilibsodium/src/libsodium/include/sodium
20+
21+
toxcore_SOURCES := $(wildcard \
22+
auto_tests/auto_test_support.c \
23+
auto_tests/send_message_test.c \
24+
testing/misc_tools.c \
25+
toxav/*.c \
26+
toxcore/*.c \
27+
toxcore/*/*.c \
28+
toxencryptsave/*.c \
29+
third_party/cmp/*.c)
30+
toxcore_OBJECTS := $(toxcore_SOURCES:.c=.o)
31+
$(toxcore_OBJECTS): CFLAGS += \
32+
-Werror \
33+
-D__COMPCERT__ \
34+
-DDISABLE_VLA \
35+
-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
36+
-Dinline= \
2437

25-
send_message_test: $(OBJECTS)
38+
send_message_test: $(libsodium_OBJECTS) $(toxcore_OBJECTS)
2639
$(CC) -o $@ $+ $(LDFLAGS)

other/docker/compcert/compcert.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ COPY --from=sources /src/ /work/
1313

1414
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1515

16+
RUN git clone --depth=1 https://github.com/jedisct1/libsodium /work/libsodium
1617
COPY other/docker/compcert/Makefile /work/
1718
RUN make "-j$(nproc)"
1819
RUN ./send_message_test | grep 'tox clients connected'

0 commit comments

Comments
 (0)