From 670facf733c48be7d289a1327a715279134e3822 Mon Sep 17 00:00:00 2001 From: Franziskus Kiefer Date: Wed, 14 Sep 2022 16:13:37 +0200 Subject: [PATCH] opam fixes for 0.5.0 (#189) * make opam build work with bsd sed * disable arm32 for opam hacl-star-raw for now * fix s390x opam build * fixes for ubuntu 18.04 - drop some more modern cmake features - build opam package with old cmake style * opam: add explicit dune dependency in hacl-star-raw.opam Co-authored-by: Victor Dumitrescu --- .github/workflows/ocaml.yml | 14 ++++++++++++-- CMakeLists.txt | 5 +++-- ocaml/Makefile | 13 ++++++++++--- ocaml/hacl-star-raw.opam | 3 ++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ocaml.yml b/.github/workflows/ocaml.yml index a70d2e87..af57694d 100644 --- a/.github/workflows/ocaml.yml +++ b/.github/workflows/ocaml.yml @@ -66,7 +66,13 @@ jobs: # ./mach test -l ocaml -v packaging: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: + - macos-latest + - ubuntu-latest + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -78,8 +84,12 @@ jobs: path: ~/.opam key: ${{ runner.os }}-ocaml-setup - - name: System Setup + - name: Setup Ubuntu + if: matrix.os == 'ubuntu-latest' run: sudo apt-get install ninja-build opam libgmp-dev + - name: Setup macOS + if: matrix.os == 'macos-latest' + run: brew install ninja opam gmp - name: OCaml Setup if: steps.cache-ocaml-setup.outputs.cache-hit != 'true' run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index cff08b73..2b6de5e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,6 @@ endif() project(hacl VERSION 0.1.0 DESCRIPTION "The High Assurance Crypto Library" - HOMEPAGE_URL "https://www.cryspen.com/hacl" LANGUAGES C CXX ) @@ -355,7 +354,9 @@ endif() set(CMAKE_INSTALL_LIBDIR lib) include(GNUInstallDirs) set(CMAKE_INSTALL_MESSAGE LAZY) -install(TARGETS hacl_static hacl) +install(TARGETS hacl_static hacl + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) # # Copy hacl headers install(FILES ${PUBLIC_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hacl) diff --git a/ocaml/Makefile b/ocaml/Makefile index a4d18dee..9fac333d 100644 --- a/ocaml/Makefile +++ b/ocaml/Makefile @@ -44,8 +44,11 @@ C_DYN_LIB?=lib$(DYNAMIC_C_LIB_NAME).$(SO) # Compiling the C library. This needs to be executed before and independently # of build-bindings because it will also write Makefile.config, which is needed # by build-bindings. +# +# Note that cmake 3.10 does not support -B to output build files to a different +# directory. Hence the other way of calling it here. build-c: - cmake -B build -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + cd build && cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../ make -C build cp build/$(C_LIB) . cp build/$(C_DYN_LIB) . @@ -104,6 +107,10 @@ lib_gen/Lib_RandomBuffer_System_gen.exe: lib/Lib_RandomBuffer_System_bindings.cm %.exe: +uname_m=$(shell uname -m) +OCAML_CFLAGS.s390x=-m64 -mzarch -mvx -mzvector -march=native -O3 +CFLAGS+=$(OCAML_CFLAGS.$(uname_m)) + lib_gen/%_gen.exe: $(OCAMLOPT) $(filter-out %.a,$^) $(C_LIB) -o $@ @@ -147,8 +154,8 @@ clean: # Install hacl-star-raw locally. install: dllocamlevercrypt.$(OCAML_SO) # We need to remove all comments from config.h because ccpo can't handle them - sed 's/\(\/\/.*\)\|\(\/\*.*\*\/\)//g' build/config.h > build/config-new.h - mv build/config-new.h build/config.h + sed 's/\(\/\/.*\)//g' build/config.h > build/config-new.h + sed 's/\(\/\*.*\*\/\)//g' build/config-new.h > build/config.h ocamlfind remove hacl-star-raw || true ocamlfind install hacl-star-raw META ocamlfind install -add hacl-star-raw $(CTYPES_ML) diff --git a/ocaml/hacl-star-raw.opam b/ocaml/hacl-star-raw.opam index ee0b7d7c..929b9709 100644 --- a/ocaml/hacl-star-raw.opam +++ b/ocaml/hacl-star-raw.opam @@ -15,13 +15,14 @@ homepage: "https://hacl-star.github.io/" bug-reports: "https://github.com/project-everest/hacl-star/issues" depends: [ "ocaml" { >= "4.08.0" } + "dune" {>= "1.2"} "ocamlfind" {build} "ctypes" { >= "0.18.0" } "conf-which" {build} "conf-cmake" {build} ] available: [ - arch != "ppc64" & arch != "ppc32" & + arch != "ppc64" & arch != "ppc32" & arch != "arm32" & (os = "freebsd" | os-family != "bsd") ] x-ci-accept-failures: [