@@ -19,53 +19,46 @@ 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 ($(ARCHTYPE_RESULT ) -$(OSTYPE_RESULT ) ,x86_64-Darwin)
30+ ASSEMBLE =as -arch arm64
31+ OBJDUMP =otool -tvV
32+ else
33+ ifeq ($(filter $(ARCHTYPE_RESULT ) ,aarch64 arm64) ,)
34+ CROSS_PREFIX =aarch64-unknown-linux-gnu-
35+ # Check if cross-toolchain exists
36+ ifeq ($(shell command -v $(ASSEMBLE ) >/dev/null 2>&1 && echo yes || echo no) ,no)
37+ $(error Cross-toolchain not found. Please run in the 'hol_light' nix shell via : nix develop .# hol_light)
38+ endif
39+ endif
40+ ASSEMBLE =$(CROSS_PREFIX ) as $(ARCHFLAGS )
41+ OBJDUMP =$(CROSS_PREFIX ) objdump -d
42+ endif
43+
2244# Add explicit language input parameter to cpp, otherwise the use of #n for
2345# numeric literals in ARM code is a problem when used inside #define macros
2446# since normally that means stringization.
2547#
2648# Some clang-based preprocessors seem to behave differently, and get confused
2749# by single-quote characters in comments, so we eliminate // comments first.
2850
29- ARCHFLAGS=-march =armv8.4-a+sha3
3051ifeq ($(OSTYPE_RESULT ) ,Darwin)
3152PREPROCESS =sed -e 's/\/\/.*//' | $(CC ) -E -xassembler-with-cpp -
3253else
33- PREPROCESS =$(CC ) $( ARCHFLAGS ) -E -xassembler-with-cpp -
54+ PREPROCESS =$(CC ) -E -xassembler-with-cpp -
3455endif
3556
3657# Generally GNU-type assemblers are happy with multiple instructions on
3758# a line, but we split them up anyway just in case.
3859
3960SPLIT =tr ';' '\n'
4061
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-
6962OBJ = mlkem/mlkem_ntt.o \
7063 mlkem/mlkem_intt.o \
7164 mlkem/mlkem_poly_tomont.o \
0 commit comments