From d3eb1d057ec9683586adc60491f7c26e5890a064 Mon Sep 17 00:00:00 2001 From: "Thing-han, Lim" <15379156+potsrevennil@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:27:38 +0800 Subject: [PATCH] fix static compilation for benchmarking on a55 Signed-off-by: Thing-han, Lim <15379156+potsrevennil@users.noreply.github.com> --- Makefile | 24 ++++++++++++------------ mk/config.mk | 2 -- mk/rules.mk | 2 +- mk/schemes.mk | 6 +++--- scripts/tests | 5 ++++- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index eba54699a..1ec09925f 100644 --- a/Makefile +++ b/Makefile @@ -14,24 +14,24 @@ include mk/rules.mk MAKEFLAGS = --no-print-directory mlkem: \ - $(MLKEM512_DIR)/bin/test_kyber \ - $(MLKEM768_DIR)/bin/test_kyber \ - $(MLKEM1024_DIR)/bin/test_kyber \ + $(MLKEM512_DIR)/bin/test_kyber512 \ + $(MLKEM768_DIR)/bin/test_kyber768 \ + $(MLKEM1024_DIR)/bin/test_kyber1024 \ bench: - $(MAKE) $(MAKEFLAGS) BENCH=1 $(MLKEM512_DIR)/bin/bench_kyber - $(MAKE) $(MAKEFLAGS) BENCH=1 $(MLKEM768_DIR)/bin/bench_kyber - $(MAKE) $(MAKEFLAGS) BENCH=1 $(MLKEM1024_DIR)/bin/bench_kyber + $(MAKE) $(MAKEFLAGS) BENCH=1 $(MLKEM512_DIR)/bin/bench_kyber512 + $(MAKE) $(MAKEFLAGS) BENCH=1 $(MLKEM768_DIR)/bin/bench_kyber768 + $(MAKE) $(MAKEFLAGS) BENCH=1 $(MLKEM1024_DIR)/bin/bench_kyber1024 nistkat: - $(MAKE) $(MAKEFLAGS) RNG=NISTRNG $(MLKEM512_DIR)/bin/gen_NISTKAT - $(MAKE) $(MAKEFLAGS) RNG=NISTRNG $(MLKEM768_DIR)/bin/gen_NISTKAT - $(MAKE) $(MAKEFLAGS) RNG=NISTRNG $(MLKEM1024_DIR)/bin/gen_NISTKAT + $(MAKE) $(MAKEFLAGS) RNG=NISTRNG $(MLKEM512_DIR)/bin/gen_NISTKAT512 + $(MAKE) $(MAKEFLAGS) RNG=NISTRNG $(MLKEM768_DIR)/bin/gen_NISTKAT768 + $(MAKE) $(MAKEFLAGS) RNG=NISTRNG $(MLKEM1024_DIR)/bin/gen_NISTKAT1024 kat: \ - $(MLKEM512_DIR)/bin/gen_KAT \ - $(MLKEM768_DIR)/bin/gen_KAT \ - $(MLKEM1024_DIR)/bin/gen_KAT + $(MLKEM512_DIR)/bin/gen_KAT512 \ + $(MLKEM768_DIR)/bin/gen_KAT768 \ + $(MLKEM1024_DIR)/bin/gen_KAT1024 # emulate ARM64 binary on x86_64 machine emulate: diff --git a/mk/config.mk b/mk/config.mk index 996b4d177..4bfc5943c 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -37,8 +37,6 @@ CFLAGS += \ -I fips202 \ $(CPPFLAGS) -LDFLAGS += $(ARCH_FLAGS) - LINKDEPS += $(LIBDEPS) ################## diff --git a/mk/rules.mk b/mk/rules.mk index 59ec81718..0f009f692 100644 --- a/mk/rules.mk +++ b/mk/rules.mk @@ -2,7 +2,7 @@ $(BUILD_DIR)/%: $(LINKDEPS) $(CONFIG) $(Q)echo " LD $@" $(Q)[ -d $(@D) ] || mkdir -p $(@D) - $(LD) $(LDFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS) + $(LD) $(CFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS) $(LIB_DIR)/%.a: $(CONFIG) $(Q)echo " AR $@" diff --git a/mk/schemes.mk b/mk/schemes.mk index 2a44dd42d..24fc1f6c1 100644 --- a/mk/schemes.mk +++ b/mk/schemes.mk @@ -9,10 +9,10 @@ MLKEM768_DIR = $(BUILD_DIR)/mlkem768 MLKEM1024_DIR = $(BUILD_DIR)/mlkem1024 $(MLKEM512_DIR)/bin/%: CPPFLAGS += -DKYBER_K=2 -$(TESTS:%=$(MLKEM512_DIR)/bin/%):$(MLKEM512_DIR)/bin/%: $(MLKEM512_DIR)/test/%.c.o $(call MAKE_OBJS,$(MLKEM512_DIR),$(SOURCES)) +$(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/%):$(MLKEM768_DIR)/bin/%: $(MLKEM768_DIR)/test/%.c.o $(call MAKE_OBJS,$(MLKEM768_DIR),$(SOURCES)) +$(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/%):$(MLKEM1024_DIR)/bin/%: $(MLKEM1024_DIR)/test/%.c.o $(call MAKE_OBJS,$(MLKEM1024_DIR),$(SOURCES)) +$(TESTS:%=$(MLKEM1024_DIR)/bin/%1024):$(MLKEM1024_DIR)/bin/%1024: $(MLKEM1024_DIR)/test/%.c.o $(call MAKE_OBJS,$(MLKEM1024_DIR),$(SOURCES)) diff --git a/scripts/tests b/scripts/tests index 9225391ee..d63131013 100755 --- a/scripts/tests +++ b/scripts/tests @@ -57,7 +57,7 @@ class TEST_TYPES(Enum): return "gen_KAT" def bin_path(self, scheme): - return f"test/build/{scheme.name.lower()}/bin/{self.bin()}" + return f"test/build/{scheme.name.lower()}/bin/{self.bin()}{scheme.suffix()}" class SCHEME(Enum): @@ -68,6 +68,9 @@ class SCHEME(Enum): def __str__(self): return self.name + def suffix(self): + return self.name.removeprefix("MLKEM") + def base_compile( test,