Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap armv7m libjade; #93

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/amd64-linux-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
uses: actions/checkout@v3

- name: compile amd64
run: JASMIN=$(which_jasminc) make -j$JOBS -C src/ CI=1 default
run: JASMIN=$(which_jasminc) make -j$JOBS -C src/ CI=1 compile-amd64

- name: dist amd64
run: JASMIN=$(which_jasminc) ./scripts/ci/releaser/jdist-src-v1 amd64
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/armv7m-linux-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: armv7m-linux-main

on:
workflow_dispatch:
push:
branches:
- main
pull_request:

jobs:

test:
runs-on: [self-hosted, linux, X64, amd64-main]
steps:
- name: checkout
uses: actions/checkout@v3

- name: compile and run
run: JASMIN=$(which_jasminc) make -f Makefile.armv7m -j$JOBS -C test/ CI=1 default
- name: print logs
run: JASMIN=$(which_jasminc) make -f Makefile.armv7m -C test/ CI=1 reporter
- name: return error if there are any errors
run: make -f Makefile.armv7m -C test/ CI=1 err

- name: libjade-armv7m-logs-test.tar.gz - contains non-empty logs and errors
if: always()
uses: actions/upload-artifact@v3
with:
name: libjade-armv7m-logs-test.tar.gz
path: test/libjade-armv7m-logs-test.tar.gz


14 changes: 12 additions & 2 deletions bench/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# implementations being excluded from benchmarks:
EXCLUDE ?= crypto_xof/shake256/amd64/spec/

# --------------------------------------------------------------------
ARCH ?= amd64

# --------------------------------------------------------------------
AS ?= as
CC ?= clang
Expand Down Expand Up @@ -51,6 +54,8 @@ BIN ?= bin
LOGS := libjade-logs-bench.tar.gz

SRC := ../src
export SRC

COMMON := common

EXT := ../ext
Expand All @@ -59,8 +64,13 @@ RANDINC ?= $(EXT)/randombytes/
SSBD_DIR := $(EXT)/ssbd-tools

FILTER ?= $(SRC)/crypto_%
JAZZ ?= $(filter $(FILTER), $(filter-out $(addprefix $(SRC)/,$(EXCLUDE)), $(sort $(dir $(shell find $(SRC) -name '*.jazz')))))
BENCHDIR := $(subst $(SRC),$(BIN), $(JAZZ))
export FILTER

JAZZ_ARCH ?= $(filter $(FILTER), $(filter-out $(addprefix $(SRC)/,$(EXCLUDE)), $(sort $(dir $(shell find $(SRC) -path "*/$(ARCH)/*" -name '*.jazz')))))

BENCHDIR := $(subst $(SRC),$(BIN), $(JAZZ_ARCH))

# --------------------------------------------------------------------

EXEC := $(addsuffix bench, $(BENCHDIR))
OUT := $(addsuffix .out, $(EXEC))
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/config/jasmin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9e87718c35083acc3349bee84e2b3a12ce385032
2c25aa576a0852bcf6ebe2d6a58adbe65bb497bb
87 changes: 64 additions & 23 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# -*- Makefile -*-
# --------------------------------------------------------------------
# some commands frequently run during development sessions:
#
# - clean 'everything' and compile all assembly files (change -j12 accordingly):
# libjade/src$ make CI=1 distclean && make -j12 CI=1 compile && make CI=1 reporter
#
# - build libjade-amd64.a/h (note that there are no tests that use libjade-*.a
# directly -- only .s files -- feel free to open a PR/reach out);
# libjade/src$ make CI=1 distclean && make -j12 libjade-amd64.a libjade-amd64.h
#
# - build libjade-armv7m.a libjade-armv7m.h
# libjade/src$ make CI=1 distclean && make -j12 CI=1 ARCH=armv7m CC=arm-linux-gnueabi-gcc CFLAGS='-Wall -O3' AS=arm-linux-gnueabi-as AR=arm-linux-gnueabi-ar RANLIB=arm-linux-gnueabi-ranlib libjade-armv7m.a libjade-armv7m.h && make CI=1 reporter
#
# In particular for the last command, it is helpful to setup some sort of
# facilitator that sets the variables according to the system's configuration || *


# --------------------------------------------------------------------
AS ?= as
CC ?= clang
CFLAGS ?= -O3 -Wall -Wextra -Wpedantic -Wvla -Werror -std=c99 \
-Wundef -Wshadow -Wcast-align -Wpointer-arith -Wmissing-prototypes \
-fstrict-aliasing -fno-common -pipe
AR ?= ar
RANLIB ?= ranlib

JASMIN ?= jasminc

# --------------------------------------------------------------------
Expand All @@ -14,19 +32,32 @@ export CI
CICL ?= "1"

# --------------------------------------------------------------------
LOGS := libjade-logs-src.tar.gz
SRC ?= .
LOGS := $(SRC)/libjade-logs-src.tar.gz

EXCLUDE ?=
SRC := .

EXCLUDE ?=
FILTER ?= $(SRC)/crypto_%
JAZZ ?= $(filter $(FILTER), $(filter-out $(addprefix ./,$(EXCLUDE)), $(sort $(dir $(shell find $(SRC) -name '*.jazz')))))

# JAZZ contains *all* directories where there is a '.jazz' file: it is expected
# that there is a Makefile in the same directory whose default rule produces .s
# file(s).

JAZZ ?= $(filter $(FILTER), $(filter-out $(addprefix ./,$(EXCLUDE)), $(sort $(dir $(shell find $(SRC) -name '*.jazz')))))
SAFETY ?= $(addsuffix safety, $(JAZZ))

SOURCES ?= $(filter-out ./, $(sort $(dir $(shell find $(SRC) -name 'Makefile'))))
ASM := $(shell find $(SRC) -name '*.s')
API := $(addsuffix include/api.h, $(dir $(ASM)))
OBJ := $(ASM:%.s=%.o)

# OBJECTS contains all '.o' files we would like to build. This list is built
# from the existing .s files (default rule compiles everything to assembly;
# then, on a second/third call to this Makefile, we create individual libraries
# -- at the time of this writing, amd64 and armv7m.

ARCH ?= amd64

JAZZ_ARCH ?= $(filter $(FILTER), $(filter-out $(addprefix ./,$(EXCLUDE)), $(sort $(dir $(shell find $(SRC) -path "*/$(ARCH)/*" -name '*.jazz')))))
ASSEMBLY := $(shell find $(SRC) -path "*/$(ARCH)/*" -name '*.s')
OBJECTS := $(ASSEMBLY:%.s=%.o)
HEADERS := $(addsuffix include/api.h, $(dir $(ASSEMBLY)))

# --------------------------------------------------------------------
ifeq ($(CI),1)
Expand All @@ -39,26 +70,36 @@ backward_compatibility:
endif

# --------------------------------------------------------------------
.PHONY: libjade.a libjade.h $(JAZZ) clean distclean $(LOGS)
.INTERMEDIATE: $(OBJ)
.PHONY: libjade-$(ARCH).a libjade-$(ARCH).h $(JAZZ) clean distclean $(LOGS)
.INTERMEDIATE: $(OBJECTS)

default: libjade.a libjade.h
default: compile

all: $(JAZZ)

libjade.a: $(JAZZ)
$(MAKE) __libjade

__libjade: $(OBJ)
ar -rc libjade.a $(OBJ)
ranlib libjade.a
echo "" | cat - $(API) > libjade.h
compile: $(JAZZ)

$(JAZZ):
$(MAKE) -C $@ || true

# --------------------------------------------------------------------

# two call building pattern:
# - compile as many .s as possible (from .jazz);
# - then archive

libjade-$(ARCH).a: compile-$(ARCH)
$(MAKE) __libjade-$(ARCH).a

__libjade-$(ARCH).a: $(OBJECTS)
$(AR) -rc libjade-$(ARCH).a $(OBJECTS)
$(RANLIB) libjade-$(ARCH).a

libjade-$(ARCH).h: $(HEADERS)
echo "" | cat - $(HEADERS) > $@

compile-$(ARCH): $(JAZZ_ARCH)

# --------------------------------------------------------------------

SAFETY_TIMEOUT ?= 1440m
export SAFETY_TIMEOUT

Expand Down Expand Up @@ -105,8 +146,8 @@ endif

# --------------------------------------------------------------------
clean:
rm -f libjade.a libjade.h $(LOGS) check.tar.gz
rm -f libjade-*.a libjade-*.h $(LOGS) check.tar.gz

distclean: clean
for i in $(SOURCES); do $(MAKE) -C $$i clean; done
for i in $(JAZZ); do $(MAKE) -C $$i clean; done

Loading
Loading