-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Build System for Easier Extensibility and Future Optimizatio…
…ns (#100) * place all artifacts under test/build dir Signed-off-by: Thing-han, Lim <[email protected]> * refactor the build system Signed-off-by: Thing-han, Lim <[email protected]> * refactor build system objs macro Signed-off-by: Thing-han, Lim <[email protected]> * make don't print directory Signed-off-by: Thing-han, Lim <[email protected]> * integrate the new build system to python script Signed-off-by: Thing-han, Lim <[email protected]> * format nix file Signed-off-by: Thing-han, Lim <[email protected]> * fix arch flags not correctly set Signed-off-by: Thing-han, Lim <[email protected]> * ci fix -static to be cflags Signed-off-by: Thing-han, Lim <[email protected]> * fix static compilation for benchmarking on a55 Signed-off-by: Thing-han, Lim <[email protected]> --------- Signed-off-by: Thing-han, Lim <[email protected]>
- Loading branch information
1 parent
01b9dee
commit 1b45463
Showing
12 changed files
with
200 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,4 @@ | |
.direnv | ||
.vscode | ||
.idea | ||
test/bin/ | ||
test/obj/ | ||
test/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
LDLIBS += -L$(LIB_DIR) | ||
|
||
LIBDEPS += $(LIB_DIR)/libfips202.a | ||
LDLIBS += -lfips202 | ||
CPPFLAGS += -Ifips202 | ||
|
||
ifeq ($(RNG),NISTRNG) | ||
LIBDEPS += $(LIB_DIR)/libnistrng.a | ||
LDLIBS += -lnistrng | ||
CPPFLAGS += -Itest/nistrng | ||
else | ||
LIBDEPS += $(LIB_DIR)/librng.a | ||
LDLIBS += -lrng | ||
CPPFLAGS += -Irandombytes | ||
endif | ||
|
||
$(LIB_DIR)/librng.a: $(call OBJS,$(wildcard randombytes/*.c)) | ||
|
||
$(LIB_DIR)/libnistrng.a: CFLAGS += -Wno-unused-result -O3 -fomit-frame-pointer | ||
$(LIB_DIR)/libnistrng.a: $(call OBJS,$(wildcard test/nistrng/*.c)) | ||
|
||
$(LIB_DIR)/libfips202.a: $(call OBJS,$(wildcard fips202/*.c)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
ifdef BENCH | ||
|
||
LIBDEPS += $(LIB_DIR)/libhal.a | ||
LDLIBS += -lhal | ||
CPPFLAGS += -Itest/hal | ||
$(LIB_DIR)/libhal.a: $(call OBJS,$(wildcard test/hal/*.c)) | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
$(BUILD_DIR)/%: $(LINKDEPS) $(CONFIG) | ||
$(Q)echo " LD $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(LD) $(CFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS) | ||
|
||
$(LIB_DIR)/%.a: $(CONFIG) | ||
$(Q)echo " AR $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(Q)rm -f $@ | ||
$(Q)$(AR) rcs $@ $(filter %.o,$^) | ||
|
||
$(BUILD_DIR)/%.c.o: %.c $(CONFIG) | ||
$(Q)echo " CC $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(Q)$(CC) -c -o $@ $(CFLAGS) $< | ||
|
||
$(BUILD_DIR)/mlkem512/%.c.o: %.c $(CONFIG) | ||
$(Q)echo " CC $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(Q)$(CC) -c -o $@ $(CFLAGS) $< | ||
|
||
$(BUILD_DIR)/mlkem512/%.S.o: %.S $(CONFIG) | ||
$(Q)echo " AS $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(Q)$(CC) -c -o $@ $(CFLAGS) $< | ||
|
||
$(BUILD_DIR)/mlkem768/%.c.o: %.c $(CONFIG) | ||
$(Q)echo " CC $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(Q)$(CC) -c -o $@ $(CFLAGS) $< | ||
|
||
$(BUILD_DIR)/mlkem768/%.S.o: %.S $(CONFIG) | ||
$(Q)echo " AS $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(Q)$(CC) -c -o $@ $(CFLAGS) $< | ||
|
||
$(BUILD_DIR)/mlkem1024/%.c.o: %.c $(CONFIG) | ||
$(Q)echo " CC $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(Q)$(CC) -c -o $@ $(CFLAGS) $< | ||
|
||
$(BUILD_DIR)/mlkem1024/%.S.o: %.S $(CONFIG) | ||
$(Q)echo " AS $@" | ||
$(Q)[ -d $(@D) ] || mkdir -p $(@D) | ||
$(Q)$(CC) -c -o $@ $(CFLAGS) $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
SOURCES = $(wildcard mlkem/*.c) | ||
|
||
CPPFLAGS += -Imlkem | ||
TESTS = test_kyber bench_kyber gen_NISTKAT gen_KAT | ||
|
||
MLKEM512_DIR = $(BUILD_DIR)/mlkem512 | ||
MLKEM768_DIR = $(BUILD_DIR)/mlkem768 | ||
MLKEM1024_DIR = $(BUILD_DIR)/mlkem1024 | ||
|
||
$(MLKEM512_DIR)/bin/%: CPPFLAGS += -DKYBER_K=2 | ||
$(TESTS:%=$(MLKEM512_DIR)/bin/%512):$(MLKEM512_DIR)/bin/%512: $(MLKEM512_DIR)/test/%.c.o $(call MAKE_OBJS,$(MLKEM512_DIR),$(SOURCES)) | ||
|
||
$(MLKEM768_DIR)/bin/%: CPPFLAGS += -DKYBER_K=3 | ||
$(TESTS:%=$(MLKEM768_DIR)/bin/%768):$(MLKEM768_DIR)/bin/%768: $(MLKEM768_DIR)/test/%.c.o $(call MAKE_OBJS,$(MLKEM768_DIR),$(SOURCES)) | ||
|
||
$(MLKEM1024_DIR)/bin/%: CPPFLAGS += -DKYBER_K=4 | ||
$(TESTS:%=$(MLKEM1024_DIR)/bin/%1024):$(MLKEM1024_DIR)/bin/%1024: $(MLKEM1024_DIR)/test/%.c.o $(call MAKE_OBJS,$(MLKEM1024_DIR),$(SOURCES)) |
Oops, something went wrong.