From a35e9daeb100225dd9f81bd68be8526de44005f5 Mon Sep 17 00:00:00 2001 From: "Matthias J. Kannwischer" Date: Thu, 20 Nov 2025 09:30:20 +0800 Subject: [PATCH 1/2] Make: Support CFLAGS as both env var and make argument We usually pass arguments to make through environment variables: CFLAGS="-std=c11" make quickcheck It currently does not work to pass it as a make argument: make quickcheck CFLAGS="-std=c11" This commit fixes that and extends the C90 CI to test both variants. Resolves https://github.com/pq-code-package/mldsa-native/issues/722 Signed-off-by: Matthias J. Kannwischer --- .github/workflows/base.yml | 12 +++++++++--- test/mk/config.mk | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 19c19b7dc..6666e1f0f 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -153,11 +153,17 @@ jobs: runs-on: ${{ matrix.target.runner }} steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: make quickcheck + - name: make quickcheck (CFLAGS as environment variable) + run: | + OPT=0 CFLAGS="-std=c90" make quickcheck + make clean >/dev/null + OPT=1 CFLAGS="-std=c90" make quickcheck + - name: make quickcheck (CFLAGS as make argument) run: | - OPT=0 CFLAGS=-std=c90 make quickcheck make clean >/dev/null - OPT=1 CFLAGS=-std=c90 make quickcheck + OPT=0 make quickcheck CFLAGS="-std=c90" + make clean >/dev/null + OPT=1 make quickcheck CFLAGS="-std=c90" - uses: ./.github/actions/setup-apt - name: tests func run: | diff --git a/test/mk/config.mk b/test/mk/config.mk index 8d7b2b2c6..76263b728 100644 --- a/test/mk/config.mk +++ b/test/mk/config.mk @@ -31,7 +31,8 @@ CC_AR := $(CROSS_PREFIX)$(CC_AR) ################# # Common config # ################# -CFLAGS := \ + +override CFLAGS := \ -Wall \ -Wextra \ -Werror=unused-result \ From cfe151fdefbbc3279b2401ca4dc57ff6a1535345 Mon Sep 17 00:00:00 2001 From: "Matthias J. Kannwischer" Date: Thu, 20 Nov 2025 09:32:07 +0800 Subject: [PATCH 2/2] Minor Makefile cleanup to align with mlkem-native Signed-off-by: Matthias J. Kannwischer --- Makefile | 16 +++++++++------- test/mk/auto.mk | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 55dc7f739..9143379b2 100644 --- a/Makefile +++ b/Makefile @@ -32,12 +32,6 @@ endif W := $(EXEC_WRAPPER) -# Detect available SHA256 command -SHA256SUM := $(shell command -v shasum >/dev/null 2>&1 && echo "shasum -a 256" || (command -v sha256sum >/dev/null 2>&1 && echo "sha256sum" || echo "")) -ifeq ($(SHA256SUM),) -$(error Neither 'shasum' nor 'sha256sum' found. Please install one of these tools.) -endif - include test/mk/config.mk include test/mk/compiler.mk include test/mk/auto.mk @@ -52,6 +46,12 @@ build: func kat acvp test: run_kat run_func run_acvp $(Q)echo " Everything checks fine!" +# Detect available SHA256 command +SHA256SUM := $(shell command -v shasum >/dev/null 2>&1 && echo "shasum -a 256" || (command -v sha256sum >/dev/null 2>&1 && echo "sha256sum" || echo "")) +ifeq ($(SHA256SUM),) +$(error Neither 'shasum' nor 'sha256sum' found. Please install one of these tools.) +endif + run_kat_44: kat_44 set -o pipefail; $(W) $(MLDSA44_DIR)/bin/gen_KAT44 | $(SHA256SUM) | cut -d " " -f 1 | xargs ./META.sh ML-DSA-44 kat-sha256 run_kat_65: kat_65 @@ -218,8 +218,10 @@ clean: -$(RM) -rf *.gcno *.gcda *.lcov *.o *.so -$(RM) -rf $(BUILD_DIR) -make clean -C examples/bring_your_own_fips202 >/dev/null + -make clean -C examples/bring_your_own_fips202_static >/dev/null -make clean -C examples/basic >/dev/null + -make clean -C examples/basic_deterministic >/dev/null -make clean -C examples/monolithic_build >/dev/null - -make clean -C examples/monolithic_build_multilevel >/dev/null -make clean -C examples/monolithic_build_native >/dev/null + -make clean -C examples/monolithic_build_multilevel >/dev/null -make clean -C examples/monolithic_build_multilevel_native >/dev/null diff --git a/test/mk/auto.mk b/test/mk/auto.mk index d8bc80a02..6907fc459 100644 --- a/test/mk/auto.mk +++ b/test/mk/auto.mk @@ -1,7 +1,7 @@ # Copyright (c) The mlkem-native project authors # Copyright (c) The mldsa-native project authors # SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT - +# # Automatically detect system architecture and set preprocessor flags accordingly # This file detects host CPU capabilities and combines them with compiler support # to enable optimal compilation flags.