-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for s390x architecture. (#1431)
### Description of changes: Add support for s390x architecture. This is pretty trivial change (a few defines), since the big-endian support was previously added for PowerPC architectures. ### Call-outs: There is a false-positive error when compiling using `s390x-linux-gnu-gcc-11` with `-O3` (i.e. `Release` profile): ``` crypto/pem/pem_lib.c:705:11: error: ‘strncmp’ of strings of length 1 and 9 and bound of 9 evaluates to nonzero [-Werror=string-compare] 705 | if (strncmp(buf, "-----END ", 9) == 0) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ``` but there are no issues when using `-O2` or when building with `s390x-linux-gnu-gcc-12`. ### Testing: All tests from `run_cross_tests.sh`, i.e. ``` crypto/crypto_test --gtest_also_run_disabled_tests crypto/urandom_test crypto/mem_test crypto/mem_set_test crypto/dynamic_loading_test ssl/ssl_test ssl/integration_test ``` passed, with the exception of `BIOTest.InvokeConnectCallback`, which fails for me on all platforms. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license. cc @andrewhop @justsmth --------- Signed-off-by: Piotr Sikora <piotr@aviatrix.com> Co-authored-by: Justin Smith <justsmth@amazon.com> Co-authored-by: Justin W Smith <103147162+justsmth@users.noreply.github.com>
- Loading branch information
1 parent
6bc2e52
commit e16ea3d
Showing
11 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
set -ex | ||
|
||
# Note: | ||
# After host reboot, qemu registration may need to be performed. | ||
# `docker run --rm --privileged multiarch/qemu-user-static --reset -p yes` | ||
|
||
# On Linux, you can see which architectures that qemu is registered for by looking | ||
# under `/proc/sys/fs/binfmt_misc`. | ||
|
||
# If needed, you can clear these entries using the following command: | ||
# `sudo find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \;` | ||
|
||
# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate | ||
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) | ||
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest | ||
|
||
SCRIPT_DIR=$(dirname "$(readlink -f "${0}")") | ||
|
||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
|
||
ARCH_NAME=s390x | ||
|
||
X_TOOLS_FILE=${ARCH_NAME}-x-tools | ||
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then | ||
wget "https://aws-libcrypto.s3.us-west-2.amazonaws.com/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz" | ||
mv ${X_TOOLS_FILE}.tar.xz ./ubuntu-x-tools/ | ||
fi | ||
|
||
BUILDER_NAME=${ARCH_NAME}-builder | ||
if ! docker buildx inspect ${BUILDER_NAME}; then | ||
docker buildx create --name ${BUILDER_NAME} --use | ||
fi | ||
|
||
docker buildx build -t ubuntu-${ARCH_NAME}:test "${SCRIPT_DIR}"/ubuntu-test --load | ||
docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load | ||
|
||
docker buildx rm ${BUILDER_NAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
FROM --platform=$BUILDPLATFORM s390x/ubuntu | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# Note: valgind was not available on this platform | ||
RUN apt-get update && apt-get install -y \ | ||
git gcc g++ cmake golang gdb gdbserver \ | ||
libclang-dev clang \ | ||
build-essential \ | ||
ssh \ | ||
rsync \ | ||
tar \ | ||
python3 \ | ||
&& apt-get clean | ||
|
||
EXPOSE 7777 | ||
|
||
ENV GOCACHE=/tmp | ||
|
||
CMD ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
FROM ubuntu:22.04 | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
git cmake golang gdb gdbserver valgrind \ | ||
libclang1 \ | ||
build-essential \ | ||
ssh \ | ||
rsync \ | ||
tar \ | ||
python3 \ | ||
xz-utils \ | ||
ninja-build | ||
|
||
RUN apt-get install -y \ | ||
qemu-system-s390x \ | ||
qemu-user \ | ||
qemu-user-binfmt | ||
|
||
RUN apt-get clean | ||
|
||
COPY s390x-x-tools.tar.xz / | ||
RUN tar Jxvf s390x-x-tools.tar.xz -C / && rm /s390x-x-tools.tar.xz | ||
COPY s390x.cmake / | ||
|
||
EXPOSE 1234 | ||
|
||
ENV GOCACHE=/tmp \ | ||
CMAKE_TOOLCHAIN_FILE=/s390x.cmake \ | ||
CMAKE_SYSTEM_NAME=Linux \ | ||
CMAKE_SYSTEM_PROCESSOR=s390x \ | ||
PATH="${PATH}:/s390x-ibm-linux-gnu/bin/" \ | ||
CMAKE_C_COMPILER=/s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-gcc \ | ||
CMAKE_CXX_COMPILER=/s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-g++ \ | ||
CMAKE_SYSROOT=/s390x-ibm-linux-gnu/s390x-ibm-linux-gnu/sysroot \ | ||
CMAKE_GENERATOR=Ninja | ||
|
||
CMD ["/bin/bash"] |
12 changes: 12 additions & 0 deletions
12
tests/docker_images/linux-s390x/ubuntu-x-tools/s390x.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Specify the target system | ||
set(CMAKE_SYSTEM_NAME Linux) | ||
set(CMAKE_SYSTEM_PROCESSOR s390x) | ||
|
||
# Specify the cross-compiler | ||
set(CMAKE_C_COMPILER /s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-gcc) | ||
set(CMAKE_CXX_COMPILER /s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-g++) | ||
|
||
# Specify the sysroot for the target system | ||
set(CMAKE_SYSROOT /s390x-ibm-linux-gnu/s390x-ibm-linux-gnu/sysroot) | ||
set(CMAKE_GENERATOR Ninja) | ||
set(ENABLE_EXPERIMENTAL_BIG_ENDIAN_SUPPORT true) |