@@ -19,53 +19,43 @@ ARCHTYPE_RESULT=$(shell uname -m)
1919SRC ?= $(S2N_BIGNUM_DIR )
2020SRC_ARM ?= $(SRC ) /arm
2121
22+ ARCHFLAGS=-march =armv8.4-a+sha3
23+
24+ # If actually on an AArch64 machine, just use the assembler (as). Otherwise
25+ # use a cross-assembling version so that the code can still be assembled
26+ # and the proofs checked against the object files (though you won't be able
27+ # to run code without additional emulation infrastructure).
28+
29+ ifeq ($(filter $(ARCHTYPE_RESULT ) ,aarch64 arm64) ,)
30+ CROSS_PREFIX =aarch64-unknown-linux-gnu-
31+ # Check if cross-toolchain exists
32+ ifeq ($(shell command -v $(ASSEMBLE ) >/dev/null 2>&1 && echo yes || echo no) ,no)
33+ $(error Cross-toolchain not found. Please run in the 'hol_light' nix shell via : nix develop .# hol_light)
34+ endif
35+ endif
36+
37+ ASSEMBLE =$(CROSS_PREFIX ) as $(ARCHFLAGS )
38+ OBJDUMP =$(CROSS_PREFIX ) objdump -d
39+ COMPILE =$(CROSS_PREFIX )$(CC )
40+
2241# Add explicit language input parameter to cpp, otherwise the use of #n for
2342# numeric literals in ARM code is a problem when used inside #define macros
2443# since normally that means stringization.
2544#
2645# Some clang-based preprocessors seem to behave differently, and get confused
2746# by single-quote characters in comments, so we eliminate // comments first.
2847
29- ARCHFLAGS=-march =armv8.4-a+sha3
3048ifeq ($(OSTYPE_RESULT ) ,Darwin)
31- PREPROCESS =sed -e 's/\/\/.*//' | $(CC ) -E -xassembler-with-cpp -
49+ PREPROCESS =sed -e 's/\/\/.*//' | $(COMPILE ) -E -xassembler-with-cpp -
3250else
33- PREPROCESS =$(CC ) $(ARCHFLAGS ) -E -xassembler-with-cpp -
51+ PREPROCESS =$(COMPILE ) $(ARCHFLAGS ) -E -xassembler-with-cpp -
3452endif
3553
3654# Generally GNU-type assemblers are happy with multiple instructions on
3755# a line, but we split them up anyway just in case.
3856
3957SPLIT =tr ';' '\n'
4058
41- # If actually on an ARM8 machine, just use the assembler (as). Otherwise
42- # use a cross-assembling version so that the code can still be assembled
43- # and the proofs checked against the object files (though you won't be able
44- # to run code without additional emulation infrastructure). For the clang
45- # version on OS X we just add the "-arch arm64" option. For the Linux/gcc
46- # toolchain we assume the presence of the special cross-assembler. This
47- # can be installed via something like:
48- #
49- # sudo apt-get install binutils-aarch64-linux-gnu
50-
51- ifeq ($(ARCHTYPE_RESULT ) ,aarch64)
52- ASSEMBLE =as $(ARCHFLAGS )
53- OBJDUMP =objdump -d
54- else
55- ifeq ($(ARCHTYPE_RESULT ) ,arm64)
56- ASSEMBLE =as $(ARCHFLAGS )
57- OBJDUMP =objdump -d
58- else
59- ifeq ($(OSTYPE_RESULT ) ,Darwin)
60- ASSEMBLE =as -arch arm64
61- OBJDUMP =otool -tvV
62- else
63- ASSEMBLE =aarch64-linux-gnu-as $(ARCHFLAGS )
64- OBJDUMP =aarch64-linux-gnu-objdump -d
65- endif
66- endif
67- endif
68-
6959OBJ = mlkem/mlkem_ntt.o \
7060 mlkem/mlkem_intt.o \
7161 mlkem/mlkem_poly_tomont.o \
0 commit comments