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

CRYPTO-172: Add support for Linux-riscv64 #264

Merged
merged 23 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b2785f4
Add support for Linux-riscv64
luhenry Oct 30, 2023
2a68c3e
Revert maven version bump
luhenry Oct 31, 2023
e827a92
Add linux-riscv64 docker-based testing
luhenry Oct 31, 2023
2fc4e2e
It's been tested on linux-riscv64
luhenry Oct 31, 2023
736f5f6
Add testing on aarch64 and riscv64 on GitHub Actions
luhenry Oct 31, 2023
58ea881
Merge branch 'master' of github.com:apache/commons-crypto into port-r…
luhenry Oct 31, 2023
294977f
Reduce verbosity
luhenry Oct 31, 2023
c2bdc6f
Reduce verbosity even further
luhenry Oct 31, 2023
930a836
Reduce verbosity some more (and speed up build as well)
luhenry Oct 31, 2023
332fcac
Downgrade JNA version to 5.12
luhenry Oct 31, 2023
28c4884
Fix bad package name
luhenry Oct 31, 2023
616e12b
review
luhenry Nov 1, 2023
d0be99f
review
luhenry Nov 1, 2023
7c146c5
Remove JNA version downgrade
luhenry Nov 2, 2023
f087df9
Merge branch 'master' of github.com:apache/commons-crypto into port-r…
luhenry Nov 2, 2023
54bc9a8
Downgrade on linux-riscv64 on CI
luhenry Nov 2, 2023
27b1197
JNA version override only needed when _running_ the test on linux-ris…
luhenry Nov 2, 2023
57b2c97
Merge branch 'master' of github.com:apache/commons-crypto into port-r…
luhenry Nov 2, 2023
9de357b
review
luhenry Nov 2, 2023
7db0236
Fix merge conflict resolution mistake
luhenry Nov 2, 2023
19644b6
Fix indentation
sebbASF Nov 3, 2023
5e6ad7f
Try again to insert a tab
sebbASF Nov 3, 2023
4c69119
Trim down aarch64 and riscv64 docker images to speed up CI
luhenry Nov 3, 2023
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
20 changes: 20 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
sebbASF marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The following provides more details on the included cryptographic software:
<japicmp.skip>false</japicmp.skip>

<commons.release.isDistModule>true</commons.release.isDistModule>
<jna.version>5.13.0</jna.version>
<jna.version>5.12.0</jna.version>
sebbASF marked this conversation as resolved.
Show resolved Hide resolved

<!-- The property "target.name" is used to specify the ant target, The "all" target will use
OsInfo.java to detect the OS info and arch to generate the native binary for detected platform.
Expand Down Expand Up @@ -206,6 +206,12 @@ The following provides more details on the included cryptographic software:
<target.name>linux-aarch64</target.name>
</properties>
</profile>
<profile>
<id>linux-riscv64</id>
<properties>
<target.name>linux-riscv64</target.name>
</properties>
</profile>
sebbASF marked this conversation as resolved.
Show resolved Hide resolved
<profile>
<id>jacoco</id>
<activation>
Expand Down
34 changes: 18 additions & 16 deletions src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,32 @@ 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 mingw-w64 \
&& apt-get --assume-yes install wget \
&& apt-get --assume-yes install dos2unix \
&& apt-get -y -qq install openjdk-8-jdk \
build-essential \
libssl-dev \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
gcc-riscv64-linux-gnu \
g++-riscv64-linux-gnu \
mingw-w64 \
curl \
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 \
gcc-arm-linux-gnueabi \
g++-arm-linux-gnueabi \
gcc-arm-linux-gnueabihf \
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

sebbASF marked this conversation as resolved.
Show resolved Hide resolved
# Ensure we are in the correct directory (this will be overlaid by the virtual mount)
WORKDIR /home/crypto
Expand Down
41 changes: 41 additions & 0 deletions src/docker/Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -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.
sebbASF marked this conversation as resolved.
Show resolved Hide resolved

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 -y -qq install software-properties-common \
&& add-apt-repository ppa:openjdk-r/ppa && apt-get update \
&& apt-get -y -qq install openjdk-21-jdk \
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
41 changes: 41 additions & 0 deletions src/docker/Dockerfile.riscv64
Original file line number Diff line number Diff line change
@@ -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.
sebbASF marked this conversation as resolved.
Show resolved Hide resolved

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 -y -qq install software-properties-common \
&& add-apt-repository ppa:openjdk-r/ppa && apt-get update \
&& apt-get -y -qq install openjdk-21-jdk \
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
3 changes: 2 additions & 1 deletion src/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
35 changes: 34 additions & 1 deletion src/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,41 @@ 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-aarch64-test:
<<: *crypto-aarch64
command: bash -xc "mvn -V -B -ntp surefire:test"
luhenry marked this conversation as resolved.
Show resolved Hide resolved

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
- ~/.m2/repository:/root/.m2/repository

crypto-riscv64-test:
luhenry marked this conversation as resolved.
Show resolved Hide resolved
<<: *crypto-riscv64
command: bash -xc "mvn -V -B -ntp surefire:test"

1 change: 1 addition & 0 deletions src/site/xdoc/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ limitations under the License.
<li>debian-amd64; OpenSSL 1.1.1g</li>
<li>debian-arm64; OpenSSL 1.1.1f</li>
<li>linux-aarch64; OpenSSL 1.0.2k-fips</li>
<li>linux-riscv64; OpenSSL 1.1.1f</li>
sebbASF marked this conversation as resolved.
Show resolved Hide resolved
<li>Linux x86_64; OpenSSL 1.1.1</li>
<li>Windows 64 (mingw64); OpenSSL 1.1.1d</li>
</ul>
Expand Down
Loading