From b2785f4888e7d9ef39d0fdce37b29febbf8634a4 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 30 Oct 2023 10:19:55 +0000 Subject: [PATCH 01/20] Add support for Linux-riscv64 Java supports RISC-V since version 19. Given Apache Common Crypto is a commonly used library in the Java ecosystem, it's important for it to support RISC-V as well. This patch adds the linux-riscv64 target similarly to linux-aarch64 --- Makefile | 4 ++++ Makefile.common | 12 +++++++++++- pom.xml | 6 ++++++ src/docker/Dockerfile | 6 ++++-- src/docker/build.sh | 1 + src/site/xdoc/index.xml | 1 + 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a079bae7a..28dc4fa5f 100644 --- a/Makefile +++ b/Makefile @@ -120,6 +120,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 + clean-native-linux32: $(MAKE) clean-native OS_NAME=Linux OS_ARCH=x86 diff --git a/Makefile.common b/Makefile.common index 900b3c5f5..b11308a6b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -53,7 +53,7 @@ endif # os=Default is meant to be generic Unix/Linux # The following list must include all OS entries beloe (apart from Default) -known_os_archs := Linux-x86 Linux-x86_64 Linux-aarch64 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 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc64 +known_os_archs := Linux-x86 Linux-x86_64 Linux-aarch64 Linux-arm Linux-armhf Linux-ppc Linux-ppc64 Linux-riscv64 Mac-x86 Mac-x86_64 Mac-arm64 Mac-aarch64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc64 os_arch := $(OS_NAME)-$(OS_ARCH) ifeq (,$(findstring $(strip $(os_arch)),$(known_os_archs))) @@ -190,6 +190,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/pom.xml b/pom.xml index 7b2c5dd67..d5d735978 100644 --- a/pom.xml +++ b/pom.xml @@ -206,6 +206,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 eb5c9ad54..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 \ @@ -45,8 +47,8 @@ RUN dpkg --add-architecture i386 && apt-get update \ && apt-get --assume-yes install g++-arm-linux-gnueabihf # Do this separately to make upgrades easier -RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz \ -&& tar xf apache-maven-*.tar.gz -C /opt && ln -s /opt/apache-maven-3.8.7 /opt/maven +RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz \ +&& tar xf apache-maven-*.tar.gz -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 diff --git a/src/docker/build.sh b/src/docker/build.sh index 0424f1eb5..0795e69ed 100755 --- a/src/docker/build.sh +++ b/src/docker/build.sh @@ -29,6 +29,7 @@ mvn -V 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/site/xdoc/index.xml b/src/site/xdoc/index.xml index c3a034b3f..bb613cfbf 100644 --- a/src/site/xdoc/index.xml +++ b/src/site/xdoc/index.xml @@ -84,6 +84,7 @@ limitations under the License.
  • debian-amd64; OpenSSL 1.1.1g
  • debian-arm64; OpenSSL 1.1.1f
  • linux-aarch64; OpenSSL 1.0.2k-fips
  • +
  • linux-riscv64; OpenSSL 1.1.1f
  • Linux x86_64; OpenSSL 1.1.1
  • Windows 64 (mingw64); OpenSSL 1.1.1d
  • From 2a68c3e663a8159a5ae47613b58d4c973da0a53f Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 07:53:26 +0000 Subject: [PATCH 02/20] Revert maven version bump --- src/docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docker/Dockerfile b/src/docker/Dockerfile index eb61e6c4a..9449c403a 100644 --- a/src/docker/Dockerfile +++ b/src/docker/Dockerfile @@ -47,8 +47,8 @@ RUN dpkg --add-architecture i386 && apt-get update \ && apt-get --assume-yes install g++-arm-linux-gnueabihf # Do this separately to make upgrades easier -RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz \ -&& tar xf apache-maven-*.tar.gz -C /opt && ln -s /opt/apache-maven-3.8.8 /opt/maven +RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz \ +&& tar xf apache-maven-*.tar.gz -C /opt && ln -s /opt/apache-maven-3.8.7 /opt/maven # Ensure we are in the correct directory (this will be overlaid by the virtual mount) WORKDIR /home/crypto From e827a9220b663807e4b3d1652d4cba2cadaef054 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 12:59:44 +0000 Subject: [PATCH 03/20] Add linux-riscv64 docker-based testing Run with docker compose -f src/docker/docker-compose.yaml run crypto-riscv64-test --- src/docker/Dockerfile.riscv64 | 41 ++++++++++++++++++++++++++++++++++ src/docker/docker-compose.yaml | 19 +++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/docker/Dockerfile.riscv64 diff --git a/src/docker/Dockerfile.riscv64 b/src/docker/Dockerfile.riscv64 new file mode 100644 index 000000000..12bfb3b5e --- /dev/null +++ b/src/docker/Dockerfile.riscv64 @@ -0,0 +1,41 @@ +# 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 various native binaries +# for Linux 64-bit and 32-bit, and Windows 64-bit and 32-bit. +# See the README for further details. + +FROM riscv64/ubuntu:20.04 + +ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-riscv64 +ENV MAVEN_HOME=/opt/maven +ENV PATH=${MAVEN_HOME}/bin:${PATH} +# Install 64-bit dependencies and tooling. +RUN apt-get update && apt-get --assume-yes install software-properties-common \ + && add-apt-repository ppa:openjdk-r/ppa && apt-get update \ + && apt-get --assume-yes install openjdk-21-jdk \ + && apt-get --assume-yes install libssl-dev \ + && apt-get --assume-yes install 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/docker-compose.yaml b/src/docker/docker-compose.yaml index 831e73ac5..c538396df 100644 --- a/src/docker/docker-compose.yaml +++ b/src/docker/docker-compose.yaml @@ -17,8 +17,25 @@ 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-riscv64: &crypto-riscv64 + image: commons-crypto:riscv64 + build: + context: . + dockerfile: Dockerfile.riscv64 + # mount the source and Maven repo + volumes: + - ../..:/home/crypto + - ~/.m2/repository:/root/.m2/repository + + crypto-riscv64-test: + <<: *crypto-riscv64 + command: mvn -V surefire:test + From 2fc4e2e65a804df0f24c8125b9848e0fb7563b4c Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 13:04:29 +0000 Subject: [PATCH 04/20] It's been tested on linux-riscv64 ``` $> docker compose -f src/docker/docker-compose.yaml run crypto-riscv64-test WARN[0000] Found orphan containers ([docker-cross-compile-riscv64-build-run-397c7aebdada docker-cross-compile-riscv64-runtime-setup-1 docker-cross-compile-riscv64-build-run-93a982a05cdc docker-cross-compile-riscv64-build-run-7dc6a41f1d5b docker-cross-compile-riscv64-build-run-644e853cbf55 docker-cross-compile-riscv64-build-run-3b09454dc280]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Running 1/1 ! crypto-riscv64-test Warning 2.0s [+] Building 303.7s (9/9) FINISHED docker-container:festive_mccarthy => [crypto-riscv64-test internal] load build definition from Dockerfile.riscv64 0.0s => => transferring dockerfile: 1.97kB 0.0s => [crypto-riscv64-test internal] load metadata for docker.io/riscv64/ubuntu:20.04 0.7s => [crypto-riscv64-test internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => CACHED [crypto-riscv64-test 1/4] FROM docker.io/riscv64/ubuntu:20.04@sha256:c0e96f609e5f128bdb6d24d21d3bf 0.0s => => resolve docker.io/riscv64/ubuntu:20.04@sha256:c0e96f609e5f128bdb6d24d21d3bf0a9af6f17234976fa574dad7146 0.0s => [crypto-riscv64-test 2/4] RUN apt-get update && apt-get --assume-yes install software-properties-common 274.2s => [crypto-riscv64-test 3/4] RUN curl -L https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven- 1.0s => [crypto-riscv64-test 4/4] WORKDIR /home/crypto 0.0s => [crypto-riscv64-test] exporting to docker image format 27.7s => => exporting layers 17.4s => => exporting manifest sha256:9068927ccfbc46788ec15578541ebc06302b538d4ed75e308b694e1132dd55fd 0.0s => => exporting config sha256:27adda314855e324670f04d2cc656b48c19879ccf16b9e4f32f32cd273bb3319 0.0s => => sending tarball 10.2s => [crypto-riscv64-test crypto-riscv64-test] importing to docker 9.1s Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39) Maven home: /opt/maven Java version: 21-ea, vendor: Private Build, runtime: /usr/lib/jvm/java-21-openjdk-riscv64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.2.0-35-generic", arch: "riscv64", family: "unix" [INFO] Scanning for projects... [INFO] [INFO] -----------------< org.apache.commons:commons-crypto >------------------ [INFO] Building Apache Commons Crypto 1.2.1-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-surefire-plugin:3.1.2:test (default-cli) @ commons-crypto --- [INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running org.apache.commons.crypto.CryptoTest OpenJDK 64-Bit Server VM warning: You have loaded library /tmp/commons-crypto-1e590661-aa26-4da1-b5c2-8d721ca08d18-libcommons-crypto.so which might have disabled stack guard. The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'. [INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.095 s -- in org.apache.commons.crypto.CryptoTest [INFO] Running org.apache.commons.crypto.OsInfoTest Linux/riscv64 Linux riscv64 [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.663 s -- in org.apache.commons.crypto.OsInfoTest [INFO] Running org.apache.commons.crypto.utils.UtilsTest [INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.159 s -- in org.apache.commons.crypto.utils.UtilsTest [INFO] Running org.apache.commons.crypto.utils.EnumTest [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.033 s -- in org.apache.commons.crypto.utils.EnumTest [INFO] Running org.apache.commons.crypto.jna.CtrCryptoJnaStreamTest [INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.60 s -- in org.apache.commons.crypto.jna.CtrCryptoJnaStreamTest [INFO] Running org.apache.commons.crypto.jna.CtrNoPaddingCipherJnaStreamTest [INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.532 s -- in org.apache.commons.crypto.jna.CtrNoPaddingCipherJnaStreamTest [INFO] Running org.apache.commons.crypto.jna.OpenSslJnaTest Apache Commons Crypto OpenSslJna: enabled = true, version = 0x1010106F OpenSSLVersion(0): OpenSSL 1.1.1f 31 Mar 2020 OpenSSLVersion(1): compiler: gcc -fPIC -pthread -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -fdebug-prefix-map=/build/openssl-zF9Nk8/openssl-1.1.1f=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2 OpenSSLVersion(2): built on: Tue Oct 10 09:03:48 2023 UTC OpenSSLVersion(3): platform: debian-riscv64 OpenSSLVersion(4): OPENSSLDIR: "/usr/lib/ssl" OpenSSLVersion(5): ENGINESDIR: "/usr/lib/riscv64-linux-gnu/engines-1.1" [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.394 s -- in org.apache.commons.crypto.jna.OpenSslJnaTest [INFO] Running org.apache.commons.crypto.jna.OpenSslJnaCipherTest [INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.447 s -- in org.apache.commons.crypto.jna.OpenSslJnaCipherTest [INFO] Running org.apache.commons.crypto.jna.CbcNoPaddingCipherJnaStreamTest [INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.448 s -- in org.apache.commons.crypto.jna.CbcNoPaddingCipherJnaStreamTest [INFO] Running org.apache.commons.crypto.jna.PositionedCryptoInputStreamJnaTest [INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.210 s -- in org.apache.commons.crypto.jna.PositionedCryptoInputStreamJnaTest [INFO] Running org.apache.commons.crypto.jna.OpenSslNativeJnaTest [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.300 s -- in org.apache.commons.crypto.jna.OpenSslNativeJnaTest [INFO] Running org.apache.commons.crypto.jna.OpenSslJnaCryptoRandomTest [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 16.24 s -- in org.apache.commons.crypto.jna.OpenSslJnaCryptoRandomTest [INFO] Running org.apache.commons.crypto.jna.CbcPkcs5PaddingCipherJnaStreamTest [INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.609 s -- in org.apache.commons.crypto.jna.CbcPkcs5PaddingCipherJnaStreamTest [INFO] Running org.apache.commons.crypto.cipher.CryptoCipherTest [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.328 s -- in org.apache.commons.crypto.cipher.CryptoCipherTest [INFO] Running org.apache.commons.crypto.cipher.OpenSslCipherTest [INFO] Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.684 s -- in org.apache.commons.crypto.cipher.OpenSslCipherTest [INFO] Running org.apache.commons.crypto.cipher.CryptoCipherFactoryTest [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.266 s -- in org.apache.commons.crypto.cipher.CryptoCipherFactoryTest [INFO] Running org.apache.commons.crypto.cipher.OpenSslCommonModeTest [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 s -- in org.apache.commons.crypto.cipher.OpenSslCommonModeTest [INFO] Running org.apache.commons.crypto.cipher.GcmCipherTest [INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.431 s -- in org.apache.commons.crypto.cipher.GcmCipherTest [INFO] Running org.apache.commons.crypto.cipher.JceCipherTest [INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.126 s -- in org.apache.commons.crypto.cipher.JceCipherTest [INFO] Running org.apache.commons.crypto.stream.CbcPkcs5PaddingCipherStreamTest [INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.579 s -- in org.apache.commons.crypto.stream.CbcPkcs5PaddingCipherStreamTest [INFO] Running org.apache.commons.crypto.stream.output.StreamOutputTest [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.037 s -- in org.apache.commons.crypto.stream.output.StreamOutputTest [INFO] Running org.apache.commons.crypto.stream.CbcNoPaddingCipherStreamTest [INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.528 s -- in org.apache.commons.crypto.stream.CbcNoPaddingCipherStreamTest [INFO] Running org.apache.commons.crypto.stream.input.ChannelInputTest [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 s -- in org.apache.commons.crypto.stream.input.ChannelInputTest [INFO] Running org.apache.commons.crypto.stream.PositionedCryptoInputStreamTest [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.747 s -- in org.apache.commons.crypto.stream.PositionedCryptoInputStreamTest [INFO] Running org.apache.commons.crypto.stream.CtrNoPaddingCipherStreamTest [INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.471 s -- in org.apache.commons.crypto.stream.CtrNoPaddingCipherStreamTest [INFO] Running org.apache.commons.crypto.stream.CtrCryptoStreamTest [INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.703 s -- in org.apache.commons.crypto.stream.CtrCryptoStreamTest [INFO] Running org.apache.commons.crypto.random.OpenSslCryptoRandomTest [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 9.651 s -- in org.apache.commons.crypto.random.OpenSslCryptoRandomTest [INFO] Running org.apache.commons.crypto.random.CryptoRandomFactoryTest [INFO] Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.530 s -- in org.apache.commons.crypto.random.CryptoRandomFactoryTest [INFO] Running org.apache.commons.crypto.random.JavaCryptoRandomTest [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 19.79 s -- in org.apache.commons.crypto.random.JavaCryptoRandomTest [INFO] Running org.apache.commons.crypto.random.OsCryptoRandomTest [INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.594 s -- in org.apache.commons.crypto.random.OsCryptoRandomTest [INFO] Running org.apache.commons.crypto.NativeCodeLoaderTest [WARNING] Tests run: 5, Failures: 0, Errors: 0, Skipped: 3, Time elapsed: 1.206 s -- in org.apache.commons.crypto.NativeCodeLoaderTest [INFO] [INFO] Results: [INFO] [WARNING] Tests run: 141, Failures: 0, Errors: 0, Skipped: 3 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:18 min [INFO] Finished at: 2023-10-31T13:04:26Z [INFO] ------------------------------------------------------------------------ ``` --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 62313bdf4..559e007c0 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 From 736f5f6391598238d85561f9b6cd927a94168d16 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 13:44:20 +0000 Subject: [PATCH 05/20] Add testing on aarch64 and riscv64 on GitHub Actions --- .github/workflows/maven.yml | 20 +++++++++++++++++ src/docker/Dockerfile.aarch64 | 41 ++++++++++++++++++++++++++++++++++ src/docker/docker-compose.yaml | 18 ++++++++++++++- 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/docker/Dockerfile.aarch64 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 8cb795080..10c5b7425 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -114,3 +114,23 @@ jobs: OPENSSL_HOME: "C:\\Miniconda\\Library" run: | mvn --show-version --batch-mode --no-transfer-progress clean test-compile -Pbenchmark + + build-cross: + strategy: + matrix: + include: + - platform: aarch64 + - platform: riscv64 + 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 }}-test \ No newline at end of file diff --git a/src/docker/Dockerfile.aarch64 b/src/docker/Dockerfile.aarch64 new file mode 100644 index 000000000..24a39c95b --- /dev/null +++ b/src/docker/Dockerfile.aarch64 @@ -0,0 +1,41 @@ +# 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 various native binaries +# for Linux 64-bit and 32-bit, and Windows 64-bit and 32-bit. +# See the README for further details. + +FROM ubuntu:20.04 + +ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-arm64 +ENV MAVEN_HOME=/opt/maven +ENV PATH=${MAVEN_HOME}/bin:${PATH} +# Install 64-bit dependencies and tooling. +RUN apt-get update && apt-get --assume-yes install software-properties-common \ + && add-apt-repository ppa:openjdk-r/ppa && apt-get update \ + && apt-get --assume-yes install openjdk-21-jdk \ + && apt-get --assume-yes install libssl-dev \ + && apt-get --assume-yes install 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/docker-compose.yaml b/src/docker/docker-compose.yaml index c538396df..95f36cd12 100644 --- a/src/docker/docker-compose.yaml +++ b/src/docker/docker-compose.yaml @@ -25,8 +25,24 @@ services: - ../..:/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-aarch64-test: + <<: *crypto-aarch64 + command: bash -xc "mvn -V surefire:test" + crypto-riscv64: &crypto-riscv64 image: commons-crypto:riscv64 + platform: linux/riscv64 build: context: . dockerfile: Dockerfile.riscv64 @@ -37,5 +53,5 @@ services: crypto-riscv64-test: <<: *crypto-riscv64 - command: mvn -V surefire:test + command: bash -xc "mvn -V surefire:test" From 294977fc88f9d3b7c6f7fc6f3a985ccb56bdfdd9 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 13:59:28 +0000 Subject: [PATCH 06/20] Reduce verbosity --- src/docker/Dockerfile | 6 +++--- src/docker/build.sh | 2 +- src/docker/docker-compose.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/docker/Dockerfile b/src/docker/Dockerfile index eb61e6c4a..f4089a90b 100644 --- a/src/docker/Dockerfile +++ b/src/docker/Dockerfile @@ -33,7 +33,7 @@ RUN apt-get update && apt-get --assume-yes install software-properties-common \ && 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 curl \ && apt-get --assume-yes install dos2unix \ # Bug workaround see https://github.com/docker-library/openjdk/issues/19. && /var/lib/dpkg/info/ca-certificates-java.postinst configure @@ -47,8 +47,8 @@ RUN dpkg --add-architecture i386 && apt-get update \ && apt-get --assume-yes install g++-arm-linux-gnueabihf # Do this separately to make upgrades easier -RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz \ -&& tar xf apache-maven-*.tar.gz -C /opt && ln -s /opt/apache-maven-3.8.8 /opt/maven +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 diff --git a/src/docker/build.sh b/src/docker/build.sh index 0795e69ed..7dbc22af8 100755 --- a/src/docker/build.sh +++ b/src/docker/build.sh @@ -25,7 +25,7 @@ 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 diff --git a/src/docker/docker-compose.yaml b/src/docker/docker-compose.yaml index 95f36cd12..da0320074 100644 --- a/src/docker/docker-compose.yaml +++ b/src/docker/docker-compose.yaml @@ -38,7 +38,7 @@ services: crypto-aarch64-test: <<: *crypto-aarch64 - command: bash -xc "mvn -V surefire:test" + command: bash -xc "mvn -V -B -ntp surefire:test" crypto-riscv64: &crypto-riscv64 image: commons-crypto:riscv64 @@ -53,5 +53,5 @@ services: crypto-riscv64-test: <<: *crypto-riscv64 - command: bash -xc "mvn -V surefire:test" + command: bash -xc "mvn -V -B -ntp surefire:test" From c2bdc6f6ddb4caad68fbc49886bf5f07dccb0f66 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 14:00:52 +0000 Subject: [PATCH 07/20] Reduce verbosity even further --- src/docker/Dockerfile | 32 ++++++++++++++++---------------- src/docker/Dockerfile.aarch64 | 8 ++++---- src/docker/Dockerfile.riscv64 | 8 ++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/docker/Dockerfile b/src/docker/Dockerfile index f4089a90b..5e1d89ecf 100644 --- a/src/docker/Dockerfile +++ b/src/docker/Dockerfile @@ -23,28 +23,28 @@ ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 ENV MAVEN_HOME=/opt/maven ENV PATH=${MAVEN_HOME}/bin:${PATH} # Install 64-bit dependencies and tooling. -RUN apt-get update && apt-get --assume-yes install software-properties-common \ +RUN apt-get update && apt-get -y -qq install software-properties-common \ && add-apt-repository ppa:openjdk-r/ppa && apt-get update \ - && apt-get --assume-yes install openjdk-8-jdk \ - && apt-get --assume-yes install build-essential \ - && 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 curl \ - && apt-get --assume-yes install dos2unix \ + && apt-get -y -qq install openjdk-8-jdk \ + && apt-get -y -qq install build-essential \ + && apt-get -y -qq install libssl-dev \ + && apt-get -y -qq install gcc-aarch64-linux-gnu \ + && apt-get -y -qq install g++-aarch64-linux-gnu \ + && apt-get -y -qq install gcc-riscv64-linux-gnu \ + && apt-get -y -qq install g++-riscv64-linux-gnu \ + && apt-get -y -qq install mingw-w64 \ + && apt-get -y -qq install curl -L \ + && apt-get -y -qq install dos2unix \ # Bug workaround see https://github.com/docker-library/openjdk/issues/19. && /var/lib/dpkg/info/ca-certificates-java.postinst configure # Install 32-bit dependencies and tooling. RUN dpkg --add-architecture i386 && apt-get update \ - && apt-get --assume-yes install libssl-dev:i386 \ - && apt-get --assume-yes install gcc-arm-linux-gnueabi \ - && apt-get --assume-yes install g++-arm-linux-gnueabi \ - && apt-get --assume-yes install gcc-arm-linux-gnueabihf \ - && apt-get --assume-yes install g++-arm-linux-gnueabihf + && apt-get -y -qq install libssl-dev:i386 \ + && apt-get -y -qq install gcc-arm-linux-gnueabi \ + && apt-get -y -qq install g++-arm-linux-gnueabi \ + && apt-get -y -qq install gcc-arm-linux-gnueabihf \ + && apt-get -y -qq install g++-arm-linux-gnueabihf # 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 \ diff --git a/src/docker/Dockerfile.aarch64 b/src/docker/Dockerfile.aarch64 index 24a39c95b..abbd46ea3 100644 --- a/src/docker/Dockerfile.aarch64 +++ b/src/docker/Dockerfile.aarch64 @@ -23,11 +23,11 @@ ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-arm64 ENV MAVEN_HOME=/opt/maven ENV PATH=${MAVEN_HOME}/bin:${PATH} # Install 64-bit dependencies and tooling. -RUN apt-get update && apt-get --assume-yes install software-properties-common \ +RUN apt-get update && apt-get -y -qq install software-properties-common \ && add-apt-repository ppa:openjdk-r/ppa && apt-get update \ - && apt-get --assume-yes install openjdk-21-jdk \ - && apt-get --assume-yes install libssl-dev \ - && apt-get --assume-yes install curl \ + && apt-get -y -qq install openjdk-21-jdk \ + && apt-get -y -qq install libssl-dev \ + && apt-get -y -qq install curl \ # Bug workaround see https://github.com/docker-library/openjdk/issues/19. && /var/lib/dpkg/info/ca-certificates-java.postinst configure diff --git a/src/docker/Dockerfile.riscv64 b/src/docker/Dockerfile.riscv64 index 12bfb3b5e..44739aaf2 100644 --- a/src/docker/Dockerfile.riscv64 +++ b/src/docker/Dockerfile.riscv64 @@ -23,11 +23,11 @@ ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-riscv64 ENV MAVEN_HOME=/opt/maven ENV PATH=${MAVEN_HOME}/bin:${PATH} # Install 64-bit dependencies and tooling. -RUN apt-get update && apt-get --assume-yes install software-properties-common \ +RUN apt-get update && apt-get -y -qq install software-properties-common \ && add-apt-repository ppa:openjdk-r/ppa && apt-get update \ - && apt-get --assume-yes install openjdk-21-jdk \ - && apt-get --assume-yes install libssl-dev \ - && apt-get --assume-yes install curl \ + && apt-get -y -qq install openjdk-21-jdk \ + && apt-get -y -qq install libssl-dev \ + && apt-get -y -qq install curl \ # Bug workaround see https://github.com/docker-library/openjdk/issues/19. && /var/lib/dpkg/info/ca-certificates-java.postinst configure From 930a83697b8e87db110df6c03dd68a8bbcf451a7 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 14:03:33 +0000 Subject: [PATCH 08/20] Reduce verbosity some more (and speed up build as well) --- src/docker/Dockerfile | 26 +++++++++++++------------- src/docker/Dockerfile.aarch64 | 4 ++-- src/docker/Dockerfile.riscv64 | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/docker/Dockerfile b/src/docker/Dockerfile index 5e1d89ecf..e2bec6db8 100644 --- a/src/docker/Dockerfile +++ b/src/docker/Dockerfile @@ -26,25 +26,25 @@ ENV PATH=${MAVEN_HOME}/bin:${PATH} RUN apt-get update && apt-get -y -qq install software-properties-common \ && add-apt-repository ppa:openjdk-r/ppa && apt-get update \ && apt-get -y -qq install openjdk-8-jdk \ - && apt-get -y -qq install build-essential \ - && apt-get -y -qq install libssl-dev \ - && apt-get -y -qq install gcc-aarch64-linux-gnu \ - && apt-get -y -qq install g++-aarch64-linux-gnu \ - && apt-get -y -qq install gcc-riscv64-linux-gnu \ - && apt-get -y -qq install g++-riscv64-linux-gnu \ - && apt-get -y -qq install mingw-w64 \ - && apt-get -y -qq install curl -L \ - && apt-get -y -qq install dos2unix \ + build-essential \ + libssl-dev \ + gcc-aarch64-linux-gnu \ + g++-aarch64-linux-gnu \ + gcc-riscv64-linux-gnu \ + g++-riscv64-linux-gnu \ + mingw-w64 \ + curl -L \ + dos2unix \ # Bug workaround see https://github.com/docker-library/openjdk/issues/19. && /var/lib/dpkg/info/ca-certificates-java.postinst configure # Install 32-bit dependencies and tooling. RUN dpkg --add-architecture i386 && apt-get update \ && apt-get -y -qq install libssl-dev:i386 \ - && apt-get -y -qq install gcc-arm-linux-gnueabi \ - && apt-get -y -qq install g++-arm-linux-gnueabi \ - && apt-get -y -qq install gcc-arm-linux-gnueabihf \ - && apt-get -y -qq install g++-arm-linux-gnueabihf + gcc-arm-linux-gnueabi \ + g++-arm-linux-gnueabi \ + gcc-arm-linux-gnueabihf \ + g++-arm-linux-gnueabihf # 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 \ diff --git a/src/docker/Dockerfile.aarch64 b/src/docker/Dockerfile.aarch64 index abbd46ea3..195128044 100644 --- a/src/docker/Dockerfile.aarch64 +++ b/src/docker/Dockerfile.aarch64 @@ -26,8 +26,8 @@ ENV PATH=${MAVEN_HOME}/bin:${PATH} RUN apt-get update && apt-get -y -qq install software-properties-common \ && add-apt-repository ppa:openjdk-r/ppa && apt-get update \ && apt-get -y -qq install openjdk-21-jdk \ - && apt-get -y -qq install libssl-dev \ - && apt-get -y -qq install curl \ + libssl-dev \ + curl \ # Bug workaround see https://github.com/docker-library/openjdk/issues/19. && /var/lib/dpkg/info/ca-certificates-java.postinst configure diff --git a/src/docker/Dockerfile.riscv64 b/src/docker/Dockerfile.riscv64 index 44739aaf2..a8ae7c027 100644 --- a/src/docker/Dockerfile.riscv64 +++ b/src/docker/Dockerfile.riscv64 @@ -26,8 +26,8 @@ ENV PATH=${MAVEN_HOME}/bin:${PATH} RUN apt-get update && apt-get -y -qq install software-properties-common \ && add-apt-repository ppa:openjdk-r/ppa && apt-get update \ && apt-get -y -qq install openjdk-21-jdk \ - && apt-get -y -qq install libssl-dev \ - && apt-get -y -qq install curl \ + libssl-dev \ + curl \ # Bug workaround see https://github.com/docker-library/openjdk/issues/19. && /var/lib/dpkg/info/ca-certificates-java.postinst configure From 332fcac642672c726bb9506f8a8a69a2df33e079 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 14:06:32 +0000 Subject: [PATCH 09/20] Downgrade JNA version to 5.12 JNA 5.13 on linux-riscv64 introduces dependency on GLIBC 2.34. It's been reported at https://github.com/java-native-access/jna/issues/1557. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d5d735978..35e806326 100644 --- a/pom.xml +++ b/pom.xml @@ -133,7 +133,7 @@ The following provides more details on the included cryptographic software: false true - 5.13.0 + 5.12.0