diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 60da3abba..1c1ad6622 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -122,3 +122,25 @@ jobs: OPENSSL_HOME: "C:\\Miniconda\\Library" run: | mvn -V -B -ntp clean test-compile -Pbenchmark + + build-cross: + strategy: + matrix: + include: + - platform: aarch64 + - platform: riscv64 + jna_override: "-Djna.version=5.12.0" # See https://github.com/java-native-access/jna/issues/1557 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + - uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2 + with: + platforms: ${{ matrix.platform }} + - run: | + # Build package + docker compose -f src/docker/docker-compose.yaml run crypto src/docker/build.sh + # Run on platform + docker compose -f src/docker/docker-compose.yaml run crypto-${{ matrix.platform }} \ + mvn -V -B -ntp surefire:test ${{ matrix.jna_override }} diff --git a/Makefile b/Makefile index 328956630..1a6ef9c76 100644 --- a/Makefile +++ b/Makefile @@ -125,6 +125,10 @@ linux-armhf: linux-aarch64: $(MAKE) native CROSS_PREFIX=aarch64-linux-gnu- OS_NAME=Linux OS_ARCH=aarch64 +# for cross-compilation on Ubuntu, install the g++-riscv64-linux-gnu +linux-riscv64: + $(MAKE) native CROSS_PREFIX=riscv64-linux-gnu- OS_NAME=Linux OS_ARCH=riscv64 + linux-ppc: # TODO: Untested; may need additional CROSS_PREFIX define $(MAKE) native OS_NAME=Linux OS_ARCH=ppc diff --git a/Makefile.common b/Makefile.common index 85c115e5c..449927487 100644 --- a/Makefile.common +++ b/Makefile.common @@ -55,7 +55,7 @@ endif # The following list must include all OS entries below (apart from Default) # Also there should be a target in the makefile for each of the combinations # For example, 'Linux-x86' is invoked by the target 'linux32' -known_os_archs := Linux-x86 Linux-x86_64 Linux-aarch64 Linux-arm Linux-armhf Linux-ppc Linux-ppc64 \ +known_os_archs := Linux-x86 Linux-x86_64 Linux-aarch64 Linux-riscv64 Linux-arm Linux-armhf Linux-ppc Linux-ppc64 \ Mac-x86 Mac-x86_64 Mac-arm64 Mac-aarch64 \ FreeBSD-x86_64 \ Windows-x86 Windows-x86_64 \ @@ -197,6 +197,16 @@ Linux-aarch64_LIBNAME := libcommons-crypto.so Linux-aarch64_LIBNAME_OSSL3 := libcommons-crypto-ossl3.so Linux-aarch64_COMMONS_CRYPTO_FLAGS := +Linux-riscv64_CC := $(CROSS_PREFIX)gcc +Linux-riscv64_CXX := $(CROSS_PREFIX)g++ +Linux-riscv64_STRIP := $(CROSS_PREFIX)strip +Linux-riscv64_CXXFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -Wall -Werror +Linux-riscv64_CFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -Wall -Werror +Linux-riscv64_LINKFLAGS := -shared -static-libgcc +Linux-riscv64_LIBNAME := libcommons-crypto.so +Linux-riscv64_LIBNAME_OSSL3 := libcommons-crypto-ossl3.so +Linux-riscv64_COMMONS_CRYPTO_FLAGS := + ifndef Mac_INC_OPENSSL Mac_INC_OPENSSL := /usr/local/opt/openssl/include endif diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 505387d3c..2a3a07fab 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -197,6 +197,7 @@ Testing: - Linux x86_64; OpenSSL 1.1.1; thanks to Alex Remily. - Windows 64 (mingw64); OpenSSL 1.1.1d; thanks to Alex Remily. - linux-aarch64; OpenSSL 1.0.2k-fips; thanks to Geoffrey Blake. +- linux-riscv64; OpenSSL 1.1.1f; thanks to Ludovic Henry. - debian-arm64; OpenSSL 1.1.1f; thanks to Geoffrey Blake. Historical list of changes: https://commons.apache.org/proper/commons-crypto/changes-report.html diff --git a/pom.xml b/pom.xml index 4a1dd0476..c9f90d5ee 100644 --- a/pom.xml +++ b/pom.xml @@ -205,6 +205,12 @@ The following provides more details on the included cryptographic software: linux-aarch64 + + linux-riscv64 + + linux-riscv64 + + jacoco diff --git a/src/docker/Dockerfile b/src/docker/Dockerfile index 480831c56..eb61e6c4a 100644 --- a/src/docker/Dockerfile +++ b/src/docker/Dockerfile @@ -30,6 +30,8 @@ RUN apt-get update && apt-get --assume-yes install software-properties-common \ && apt-get --assume-yes install libssl-dev \ && apt-get --assume-yes install gcc-aarch64-linux-gnu \ && apt-get --assume-yes install g++-aarch64-linux-gnu \ + && apt-get --assume-yes install gcc-riscv64-linux-gnu \ + && apt-get --assume-yes install g++-riscv64-linux-gnu \ && apt-get --assume-yes install mingw-w64 \ && apt-get --assume-yes install wget \ && apt-get --assume-yes install dos2unix \ diff --git a/src/docker/Dockerfile.aarch64 b/src/docker/Dockerfile.aarch64 new file mode 100644 index 000000000..63ee8eaa6 --- /dev/null +++ b/src/docker/Dockerfile.aarch64 @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file creates a Docker image for use in building linux-aarch64 on CI + +FROM ubuntu:20.04 + +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64 +ENV MAVEN_HOME=/opt/maven +ENV PATH=${MAVEN_HOME}/bin:${PATH} +# Install 64-bit dependencies and tooling. +RUN apt-get update -qq && apt-get -y -qq install \ + openjdk-17-jre-headless \ + libssl-dev \ + curl \ +# Bug workaround see https://github.com/docker-library/openjdk/issues/19. + && /var/lib/dpkg/info/ca-certificates-java.postinst configure + +# Do this separately to make upgrades easier +RUN curl -L https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz \ + | tar xzf - -C /opt && ln -s /opt/apache-maven-3.8.8 /opt/maven + +# Ensure we are in the correct directory (this will be overlaid by the virtual mount) +WORKDIR /home/crypto + +CMD /bin/bash diff --git a/src/docker/Dockerfile.riscv64 b/src/docker/Dockerfile.riscv64 new file mode 100644 index 000000000..844b1d1be --- /dev/null +++ b/src/docker/Dockerfile.riscv64 @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file creates a Docker image for use in building linux-riscv64 on CI + +FROM riscv64/ubuntu:20.04 + +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-riscv64 +ENV MAVEN_HOME=/opt/maven +ENV PATH=${MAVEN_HOME}/bin:${PATH} +# Install 64-bit dependencies and tooling. +RUN apt-get update -qq && apt-get -y -qq install \ + openjdk-17-jre-headless \ + libssl-dev \ + curl \ +# Bug workaround see https://github.com/docker-library/openjdk/issues/19. + && /var/lib/dpkg/info/ca-certificates-java.postinst configure + +# Do this separately to make upgrades easier +RUN curl -L https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz \ + | tar xzf - -C /opt && ln -s /opt/apache-maven-3.8.8 /opt/maven + +# Ensure we are in the correct directory (this will be overlaid by the virtual mount) +WORKDIR /home/crypto + +CMD /bin/bash diff --git a/src/docker/build.sh b/src/docker/build.sh index 0424f1eb5..fb240dbcd 100755 --- a/src/docker/build.sh +++ b/src/docker/build.sh @@ -17,7 +17,7 @@ # Script to build native files under Docker -set -e +set -ex cd /home/crypto # must agree with virtual mount in docker-compose.yaml @@ -25,10 +25,11 @@ cd /home/crypto # must agree with virtual mount in docker-compose.yaml cp /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl # Run the 64-bit builds. -mvn -V package -Drat.skip +mvn -V -B -ntp clean package -Drat.skip # use process-classes rather than package to speed up builds mvn -DskipTests -Drat.skip process-classes -P linux-aarch64 +mvn -DskipTests -Drat.skip process-classes -P linux-riscv64 mvn -DskipTests -Drat.skip process-classes -P win64 mvn -DskipTests -Drat.skip process-classes -P linux64 diff --git a/src/docker/docker-compose.yaml b/src/docker/docker-compose.yaml index 831e73ac5..36ac4d6c0 100644 --- a/src/docker/docker-compose.yaml +++ b/src/docker/docker-compose.yaml @@ -17,7 +17,31 @@ version: '3' services: crypto: image: commons-crypto - build: . + build: + context: . + dockerfile: Dockerfile + # mount the source and Maven repo + volumes: + - ../..:/home/crypto + - ~/.m2/repository:/root/.m2/repository + + crypto-aarch64: &crypto-aarch64 + image: commons-crypto:aarch64 + platform: linux/arm64/v8 + build: + context: . + dockerfile: Dockerfile.aarch64 + # mount the source and Maven repo + volumes: + - ../..:/home/crypto + - ~/.m2/repository:/root/.m2/repository + + crypto-riscv64: &crypto-riscv64 + image: commons-crypto:riscv64 + platform: linux/riscv64 + build: + context: . + dockerfile: Dockerfile.riscv64 # mount the source and Maven repo volumes: - ../..:/home/crypto