Skip to content

Commit

Permalink
add native-linux platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
mkannwischer committed Jul 26, 2024
1 parent 7de7232 commit 5426a52
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 193 deletions.
74 changes: 74 additions & 0 deletions envs/common/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
LD=$(CC)

COMMON_INC=../common/inc/
ENV_INC=./inc/
TEST_COMMON=../../tests/common/
SRC_DIR=./src
BUILD_DIR=./build/$(TARGET)


CFLAGS += -fpic -Wall -Wextra -Werror -Wshadow -Wno-unused-parameter
CFLAGS += $(CFLAGS_EXTRA)

CFLAGS+= -Ofast \
-I$(COMMON_INC) \
-I$(ENV_INC) \
-I$(SRC_DIR) \
-I$(TESTDIR) \
-I$(TEST_COMMON) \


LDFLAGS = -static

CYCLES?=NO # PMU / PERF

ifeq ($(CYCLES),PMU)
CFLAGS += -DPMU_CYCLES
endif

ifeq ($(CYCLES),PERF)
CFLAGS += -DPERF_CYCLES
endif

ifeq ($(CYCLES),NO)
CFLAGS += -DNO_CYCLES
endif

all: $(TARGET)

HAL_SOURCES = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*/*.c)
OBJECTS_HAL = $(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(HAL_SOURCES)))
TEST_COMMON_SOURCES = $(wildcard $(TEST_COMMON)/*.c)
OBJECTS_TEST_COMMON = $(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(TEST_COMMON_SOURCES)))
OBJECTS_SOURCES=$(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(SOURCES)))
OBJECTS_C = $(OBJECTS_SOURCES) $(OBJECTS_HAL) $(OBJECTS_TEST_COMMON)
OBJECTS_ASM = $(patsubst %.s, $(BUILD_DIR)/%.s.o, $(abspath $(ASMS)))

OBJECTS = $(OBJECTS_C) $(OBJECTS_ASM)

# Compilation
$(OBJECTS_C): $(BUILD_DIR)/%.o: %
mkdir -p $(@D)
$(CC) $(CFLAGS) -c -o $@ $<

$(OBJECTS_ASM): $(BUILD_DIR)/%.o: %
mkdir -p $(@D)
$(CC) -x assembler-with-cpp $(CFLAGS) -c -o $@ $<

# Linking
$(TARGET): $(OBJECTS)
mkdir -p $(@D)
$(LD) $(LDFLAGS) $(OBJECTS) -o $(TARGET)

.PHONY: build
build: $(TARGET)

# Running
.PHONY: run
run: $(TARGET)
$(EMU) ./$(TARGET)

.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
rm -f *.elf
81 changes: 4 additions & 77 deletions envs/common/cross.mk
Original file line number Diff line number Diff line change
@@ -1,77 +1,4 @@
QEMU=qemu-aarch64
CC=aarch64-linux-gnu-gcc
LD=$(CC)


COMMON_INC=../common/inc/
ENV_INC=./inc/
TEST_COMMON=../../tests/common/
SRC_DIR=./src
BUILD_DIR=./build/$(TARGET)


CFLAGS += -fpic -Wall -Wextra -Werror -Wshadow -Wno-unused-parameter
CFLAGS += $(CFLAGS_EXTRA)

CFLAGS+= -Ofast \
-I$(COMMON_INC) \
-I$(ENV_INC) \
-I$(SRC_DIR) \
-I$(TESTDIR) \
-I$(TEST_COMMON) \


LDFLAGS = -static

CYCLES?=NO # PMU / PERF

ifeq ($(CYCLES),PMU)
CFLAGS += -DPMU_CYCLES
endif

ifeq ($(CYCLES),PERF)
CFLAGS += -DPERF_CYCLES
endif

ifeq ($(CYCLES),NO)
CFLAGS += -DNO_CYCLES
endif

all: $(TARGET)

HAL_SOURCES = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*/*.c)
OBJECTS_HAL = $(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(HAL_SOURCES)))
TEST_COMMON_SOURCES = $(wildcard $(TEST_COMMON)/*.c)
OBJECTS_TEST_COMMON = $(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(TEST_COMMON_SOURCES)))
OBJECTS_SOURCES=$(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(SOURCES)))
OBJECTS_C = $(OBJECTS_SOURCES) $(OBJECTS_HAL) $(OBJECTS_TEST_COMMON)
OBJECTS_ASM = $(patsubst %.s, $(BUILD_DIR)/%.s.o, $(abspath $(ASMS)))

OBJECTS = $(OBJECTS_C) $(OBJECTS_ASM)

# Compilation
$(OBJECTS_C): $(BUILD_DIR)/%.o: %
mkdir -p $(@D)
$(CC) $(CFLAGS) -c -o $@ $<

$(OBJECTS_ASM): $(BUILD_DIR)/%.o: %
mkdir -p $(@D)
$(CC) -x assembler-with-cpp $(CFLAGS) -c -o $@ $<

# Linking
$(TARGET): $(OBJECTS)
mkdir -p $(@D)
$(LD) $(LDFLAGS) $(OBJECTS) -o $(TARGET)

.PHONY: build
build: $(TARGET)

# Running
.PHONY: run
run: $(TARGET)
$(QEMU) ./$(TARGET)

.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
rm -f *.elf
# emulation (qemu or empty for native)
EMU = qemu-aarch64
CC = aarch64-linux-gnu-gcc
include ../common/common.mk
4 changes: 4 additions & 0 deletions envs/common/native-linux.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# emulation (qemu or empty for native)
EMU =
CC = gcc
include ../common/common.mk
3 changes: 0 additions & 3 deletions envs/cross-v9a/Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions envs/native-linux-v84a/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CFLAGS += -march=armv8.4-a+crypto+sha3+sve2

include ../common/native-linux.mk
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions envs/native-linux-v8a/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CFLAGS += -march=armv8-a

include ../common/native-linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
#define ASM_LOAD(dst,symbol) \
adrp dst, symbol ; add dst, dst, :lo12:symbol;

#endif /* QEMU_V8A_HAL_ENV_H */
#endif
File renamed without changes.
2 changes: 0 additions & 2 deletions envs/native_linux/.gitignore

This file was deleted.

102 changes: 0 additions & 102 deletions envs/native_linux/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion envs/native_linux/inc/test_inc

This file was deleted.

1 change: 0 additions & 1 deletion envs/native_linux/src/test_common

This file was deleted.

3 changes: 2 additions & 1 deletion tests/helloworld/helloworld.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ TESTS += helloworld
# Platforms this test should run on (matching the directory name in envs/)
HELLOWORLD_PLATFORMS += cross-v8a
HELLOWORLD_PLATFORMS += cross-v84a
HELLOWORLD_PLATFORMS += cross-v9a
HELLOWORLD_PLATFORMS += native-linux-v8a
HELLOWORLD_PLATFORMS += native-linux-v84a

# C sources required for this test
HELLOWORLD_SOURCES += main.c
Expand Down
3 changes: 2 additions & 1 deletion tests/keccak-neon/keccak-neon.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ TESTS += keccak-neon
# Platforms this test should run on (matching the directory name in envs/)
KECCAK_NEON_PLATFORMS += cross-v8a
KECCAK_NEON_PLATFORMS += cross-v84a
KECCAK_NEON_PLATFORMS += cross-v9a
KECCAK_NEON_PLATFORMS += natice-linux-v8a
KECCAK_NEON_PLATFORMS += natice-linux-v84a

# C sources required for this test
KECCAK_NEON_SOURCES += main.c
Expand Down
3 changes: 3 additions & 0 deletions tests/ntt-dilithium/ntt-dilithium.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ TESTS += ntt-dilithium
# Platforms this test should run on (matching the directory name in envs/)
NTT_DILITHIUM_PLATFORMS += cross-v8a
NTT_DILITHIUM_PLATFORMS += cross-v84a
NTT_DILITHIUM_PLATFORMS += native-linux-v8a
NTT_DILITHIUM_PLATFORMS += native-linux-v84a


# C sources required for this test
NTT_DILITHIUM_SOURCES += main.c
Expand Down
2 changes: 2 additions & 0 deletions tests/ntt-kyber/ntt-kyber.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ TESTS += ntt-kyber
# Platforms this test should run on (matching the directory name in envs/)
NTT_KYBER_PLATFORMS += cross-v8a
NTT_KYBER_PLATFORMS += cross-v84a
NTT_KYBER_PLATFORMS += native-linux-v8a
NTT_KYBER_PLATFORMS += native-linux-v84a

# C sources required for this test
NTT_KYBER_SOURCES += main.c
Expand Down
3 changes: 2 additions & 1 deletion tests/ntt-neon/ntt-neon.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ TESTS += ntt-neon
# Platforms this test should run on (matching the directory name in envs/)
NTT_NEON_PLATFORMS += cross-v8a
NTT_NEON_PLATFORMS += cross-v84a
NTT_NEON_PLATFORMS += cross-v9a
NTT_NEON_PLATFORMS += native-linux-v8a
NTT_NEON_PLATFORMS += native-linux-v84a

# C sources required for this test
NTT_NEON_SOURCES += main.c
Expand Down
3 changes: 2 additions & 1 deletion tests/ntt-sve2/ntt-sve2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ TESTS += ntt-sve2
# All further variables must be prefixed with the capitalized test name

# Platforms this test should run on (matching the directory name in envs/)
NTT_SVE2_PLATFORMS += cross-v9a
NTT_SVE2_PLATFORMS += cross-v84a
NTT_SVE2_PLATFORMS += native-linux-v84a

# C sources required for this test
NTT_SVE2_SOURCES += main.c
Expand Down
3 changes: 2 additions & 1 deletion tests/profiling/profiling.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ TESTS += profiling
# Platforms this test should run on (matching the directory name in envs/)
PROFILING_PLATFORMS += cross-v8a
PROFILING_PLATFORMS += cross-v84a
PROFILING_PLATFORMS += cross-v9a
PROFILING_PLATFORMS += native-linux-v8a
PROFILING_PLATFORMS += native-linux-v84a

# C sources required for this test
PROFILING_SOURCES += main.c
Expand Down
3 changes: 2 additions & 1 deletion tests/x25519/x25519.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ TESTS += x25519
# Platforms this test should run on (matching the directory name in envs/)
X25519_PLATFORMS += cross-v8a
X25519_PLATFORMS += cross-v84a
X25519_PLATFORMS += cross-v9a
X25519_PLATFORMS += native-linux-v8a
X25519_PLATFORMS += native-linux-v84a

# C sources required for this test
X25519_SOURCES += main.c
Expand Down

0 comments on commit 5426a52

Please sign in to comment.