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

Support clang-16 #12

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 15 additions & 0 deletions .github/workflows/rust-with-clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Rust

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Update submodules
run: git submodule update --init
- name: Run sphincs+ rust tests
run: ./tests/sphincsplus_rust/run_rust.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be "run_rust_with_clang.sh"

87 changes: 87 additions & 0 deletions Makefile.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
CC := clang-16
LD := ld.lld-16
OBJCOPY := llvm-objcopy-16
AR := llvm-ar-16
RANLIB := llvm-ranlib-16

PARAMS = sphincs-shake-128f
THASH = simple

CFLAGS := --target=riscv64 -march=rv64imc_zba_zbb_zbc_zbs \
-g -O3 -fPIC \
-Wall -Werror -Wno-nonnull -Wno-unused-function \
-Wno-error=unused-but-set-variable \
-Wno-error=unused-command-line-argument \
-Wno-error=bitwise-instead-of-logical \
-fno-builtin-printf -fno-builtin-memcmp \
-nostdinc -nostdlib -fvisibility=hidden \
-fdata-sections -ffunction-sections \
-DCKB_VM -DCKB_DECLARATION_ONLY

LDFLAGS := -static -Wl,--gc-sections

CFLAGS := $(CFLAGS) -I c -I deps/ckb-c-stdlib/libc -I deps/ckb-c-stdlib -I deps/ckb-c-stdlib/molecule
CFLAGS := $(CFLAGS) -I deps/sphincsplus/ref -DPARAMS=$(PARAMS)

SPHINCS_PLUS_DIR = deps/sphincsplus/ref/

SOURCES = \
$(SPHINCS_PLUS_DIR)address.c \
$(SPHINCS_PLUS_DIR)merkle.c \
$(SPHINCS_PLUS_DIR)wots.c \
$(SPHINCS_PLUS_DIR)wotsx1.c \
$(SPHINCS_PLUS_DIR)utils.c \
$(SPHINCS_PLUS_DIR)utilsx1.c \
$(SPHINCS_PLUS_DIR)fors.c \
$(SPHINCS_PLUS_DIR)sign.c \
c/ckb-sphincsplus.c

HEADERS = \
$(SPHINCS_PLUS_DIR)params.h \
$(SPHINCS_PLUS_DIR)address.h \
$(SPHINCS_PLUS_DIR)merkle.h \
$(SPHINCS_PLUS_DIR)wots.h \
$(SPHINCS_PLUS_DIR)wotsx1.h \
$(SPHINCS_PLUS_DIR)utils.h \
$(SPHINCS_PLUS_DIR)utilsx1.h \
$(SPHINCS_PLUS_DIR)fors.h \
$(SPHINCS_PLUS_DIR)api.h \
$(SPHINCS_PLUS_DIR)hash.h \
$(SPHINCS_PLUS_DIR)thash.h \
$(SPHINCS_PLUS_DIR)randombytes.h \
c/ckb-sphincsplus.h

ifneq (,$(findstring shake,$(PARAMS)))
SOURCES += \
$(SPHINCS_PLUS_DIR)fips202.c \
$(SPHINCS_PLUS_DIR)hash_shake.c \
$(SPHINCS_PLUS_DIR)thash_shake_$(THASH).c
HEADERS += $(SPHINCS_PLUS_DIR)fips202.h
endif
ifneq (,$(findstring haraka,$(PARAMS)))
SOURCES += \
$(SPHINCS_PLUS_DIR)haraka.c \
$(SPHINCS_PLUS_DIR)hash_haraka.c \
$(SPHINCS_PLUS_DIR)thash_haraka_$(THASH).c
HEADERS += $(SPHINCS_PLUS_DIR)haraka.h
endif
ifneq (,$(findstring sha2,$(PARAMS)))
SOURCES += \
$(SPHINCS_PLUS_DIR)sha2.c \
$(SPHINCS_PLUS_DIR)hash_sha2.c \
$(SPHINCS_PLUS_DIR)thash_sha2_$(THASH).c
HEADERS += $(SPHINCS_PLUS_DIR)sha2.h
endif

# CFLAGS := $(CFLAGS) -DCKB_C_STDLIB_PRINTF

all: build/sphincsplus_lock

build/sphincsplus_lock: c/ckb-sphincsplus-lock.c $(SOURCES) $(HEADERS)
mkdir -p build
$(CC) $(CFLAGS) -o $@ $(SOURCES) $<
cp $@ [email protected]
$(OBJCOPY) --strip-debug --strip-all $@

clean:
rm -rf build/sphincsplus_lock
Loading