Skip to content

Commit

Permalink
fix static compilation for benchmarking on a55
Browse files Browse the repository at this point in the history
Signed-off-by: Thing-han, Lim <[email protected]>
  • Loading branch information
potsrevennil authored and ryjones committed Sep 6, 2024
1 parent 883d899 commit d3eb1d0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ CFLAGS += \
-I fips202 \
$(CPPFLAGS)

LDFLAGS += $(ARCH_FLAGS)

LINKDEPS += $(LIBDEPS)

##################
Expand Down
2 changes: 1 addition & 1 deletion mk/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@"
Expand Down
6 changes: 3 additions & 3 deletions mk/schemes.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))
5 changes: 4 additions & 1 deletion scripts/tests
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
Expand Down

0 comments on commit d3eb1d0

Please sign in to comment.