1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

Utilities/Release: Add base images to build sunos-{i386,sparc} binaries

This commit is contained in:
Brad King
2025-02-13 14:03:47 -05:00
parent a4e5719d31
commit 59ed18e54d
13 changed files with 297 additions and 0 deletions

View File

@@ -79,6 +79,12 @@ Each ``<os>/<arch>/`` directory contains the following:
.. _`kitware/cmake Docker Hub Repository`: https://hub.docker.com/r/kitware/cmake
SunOS
-----
The ``sunos/`` directory contains infrastructure to cross-compile
CMake binaries to SunOS from Linux hosts.
macOS
-----

View File

@@ -0,0 +1,53 @@
# syntax=docker/dockerfile:1
ARG BASE_IMAGE=debian:12
FROM ${BASE_IMAGE} AS apt-cache
# Populate APT cache w/ the fresh metadata and prefetch packages.
# Use an empty `docker-clean` file to "hide" the image-provided
# file to disallow removing packages after `apt-get` operations.
RUN --mount=type=tmpfs,target=/var/log \
--mount=type=bind,source=docker-clean,target=/etc/apt/apt.conf.d/docker-clean \
--mount=type=bind,source=base.lst,target=/root/base.lst \
--mount=type=bind,source=openssl.lst,target=/root/openssl.lst \
apt-get update \
&& apt-get --download-only -y install $(grep -h '^[^#]\+$' /root/*.lst)
FROM ${BASE_IMAGE} AS base
ARG ARCH=sparc
RUN --mount=type=bind,source=base.lst,target=/root/base.lst \
--mount=type=bind,source=docker-clean,target=/etc/apt/apt.conf.d/docker-clean \
--mount=type=cache,from=apt-cache,source=/var/lib/apt/lists,target=/var/lib/apt/lists \
--mount=type=cache,from=apt-cache,source=/var/cache/apt,target=/var/cache/apt,sharing=private \
--mount=type=tmpfs,target=/var/log \
--mount=type=tmpfs,target=/tmp \
apt-get install -y $(grep '^[^#]\+$' /root/base.lst)
RUN --mount=type=bind,source=base.bash,target=/root/base.bash \
--mount=type=tmpfs,target=/tmp \
/root/base.bash $ARCH
FROM base AS sysroot
ARG SYSROOT_URL
ARG SYSROOT_SHA256SUM
RUN --mount=type=bind,source=sysroot.bash,target=/root/sysroot.bash \
--mount=type=tmpfs,target=/tmp \
/root/sysroot.bash $ARCH
FROM sysroot AS openssl
RUN --mount=type=bind,source=openssl.lst,target=/root/openssl.lst \
--mount=type=bind,source=docker-clean,target=/etc/apt/apt.conf.d/docker-clean \
--mount=type=cache,from=apt-cache,source=/var/lib/apt/lists,target=/var/lib/apt/lists \
--mount=type=cache,from=apt-cache,source=/var/cache/apt,target=/var/cache/apt,sharing=private \
--mount=type=tmpfs,target=/var/log \
--mount=type=tmpfs,target=/tmp \
apt-get install -y $(grep '^[^#]\+$' /root/openssl.lst)
RUN --mount=type=bind,source=openssl.bash,target=/root/openssl.bash \
--mount=type=bind,source=openssl.patch,target=/root/openssl.patch \
--mount=type=bind,from=sysroot,source=/opt/cross/sysroot,target=/opt/cross/sysroot \
--mount=type=tmpfs,target=/tmp \
/root/openssl.bash $ARCH
FROM base
LABEL maintainer="Brad King <brad.king@kitware.com>"
RUN --mount=type=bind,from=openssl,source=/root,target=/root \
tar xzf /root/openssl.tar.gz -C /

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -e
arch="$1"
readonly arch
case "$arch" in
i386)
tarball="gcc-9.5.0-linux-x86_64-cross-sunos-i386.tar.xz"
sha256sum="3cd3c989483051e741dd9f39170842d22e5c43cd25628d2b0c57890a3f235883"
;;
sparc)
tarball="gcc-9.5.0-linux-x86_64-cross-sunos-sparc.tar.xz"
sha256sum="853454ef4e787895786fdb21e56a3ba9c121ffe6116467a75f2c3eb09f3c88b4"
;;
*)
echo >&2 "Unknown architecture: $arch"
exit 1
;;
esac
readonly tarball
readonly sha256sum
cd /tmp
curl -OL "https://gitlab.kitware.com/api/v4/projects/6955/packages/generic/gcc-solaris/v9.5.0-20250212.0/$tarball"
echo "$sha256sum $tarball" > gcc.sha256sum
sha256sum --check gcc.sha256sum
tar xJf "$tarball" -C /

View File

@@ -0,0 +1,3 @@
curl
git
xz-utils

View File

@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -e
arch="$1"
readonly arch
case "$arch" in
i386)
target=i386-pc-solaris2.10
openssl_target=solaris-x86-gcc
ldlibs=
;;
sparc)
target=sparc-sun-solaris2.10
openssl_target=solaris-sparcv8-gcc
ldlibs=-latomic
;;
*)
echo >&2 "Unknown architecture: $arch"
exit 1
;;
esac
readonly target
readonly openssl_target
readonly ldlibs
readonly sha256sum="e15dda82fe2fe8139dc2ac21a36d4ca01d5313c75f99f46c4e8a27709b7294bf"
readonly filename="openssl-3.4.0"
readonly tarball="$filename.tar.gz"
cd /tmp
curl -OL "https://github.com/openssl/openssl/releases/download/$filename/$tarball"
echo "$sha256sum $tarball" > openssl.sha256sum
sha256sum --check openssl.sha256sum
tar xzf "$tarball"
prefix="/opt/cross/openssl/$target"
cd "$filename"
patch -p0 < "${BASH_SOURCE%/*}/openssl.patch"
env \
LDLIBS="$ldlibs" \
LDFLAGS="-Wl,-z,noexecstack" \
./Configure \
--prefix="$prefix" \
--cross-compile-prefix="/opt/cross/bin/$target-" \
--api=1.1.1 \
"$openssl_target" \
no-deprecated \
no-shared
if ! make -j $(nproc) >make.log 2>&1; then
tail -1000 make.log
exit 1
fi
if ! make install_sw >>make.log 2>&1; then
tail -1000 make.log
exit 1
fi
tar czf /root/openssl.tar.gz -C / "$prefix"

View File

@@ -0,0 +1,4 @@
m4
make
patch
perl

View File

@@ -0,0 +1,22 @@
--- crypto/sleep.orig
+++ crypto/sleep.c
@@ -10,6 +10,8 @@
#include <openssl/crypto.h>
#include "internal/e_os.h"
+#define OPENSSL_USE_USLEEP
+
/* system-specific variants defining OSSL_sleep() */
#if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__)
--- providers/implementations/rands/seeding/rand_unix.c.orig
+++ providers/implementations/rands/seeding/rand_unix.c
@@ -84,8 +84,6 @@
# define OSSL_POSIX_TIMER_OKAY
# endif
# endif
-# else
-# define OSSL_POSIX_TIMER_OKAY
# endif
# endif
#endif /* (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS))

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -e
arch="$1"
readonly arch
case "$arch" in
i386)
tarball="sysroot-i386-pc-solaris2.10-sunos5.10-1.tar.xz"
sha256sum="1b9251699f4e412ba5b0fde9c0fb96ceef6b8a1f47f0c1f2146ba0ba9da458b8"
;;
sparc)
tarball="sysroot-sparc-sun-solaris2.10-sunos5.10-1.tar.xz"
sha256sum="e6c668a63dc00de443d07cbe2be779335642ffe1b818ba85d23ab543982aaf23"
;;
*)
echo >&2 "Unknown architecture: $arch"
exit 1
;;
esac
# To build externally, provide a Solaris sysroot tarball:
# --build-arg SYSROOT_URL=...
# --build-arg SYSROOT_SHA256SUM=...
# The tarball must contain one of:
# sysroot/i386-pc-solaris2.10/{lib,usr/lib,usr/include}
# sysroot/sparc-sun-solaris2.10/{lib,usr/lib,usr/include}
# The content may be retrieved from a real Solaris host.
if test -n "$SYSROOT_URL"; then
url="$SYSROOT_URL"
if test -n "$SYSROOT_SHA256SUM"; then
sha256sum="$SYSROOT_SHA256SUM"
else
sha256sum=""
fi
tarball=$(basename "$url")
else
# This URL is only visible inside of Kitware's network.
url="https://cmake.org/files/dependencies/internal/sunos/$tarball"
fi
readonly url
readonly tarball
readonly sha256sum
cd /tmp
curl -OL "$url"
if test -n "$sha256sum"; then
echo "$sha256sum $tarball" > sysroot.sha256sum
sha256sum --check sysroot.sha256sum
fi
tar xf "$tarball" -C /opt/cross

View File

@@ -0,0 +1,25 @@
CMAKE_BUILD_TYPE:STRING=Release
# Link C++ library statically.
CMAKE_EXE_LINKER_FLAGS:STRING=-static-libstdc++ -static-libgcc -Wl,-z,noexecstack
# Enable ssl support in curl
CMAKE_USE_OPENSSL:BOOL=ON
OPENSSL_USE_STATIC_LIBS:BOOL=ON
OpenSSL_ROOT:PATH=/opt/cross/openssl/i386-pc-solaris2.10
# Enable ccmake
BUILD_CursesDialog:BOOL=ON
# Disable cmake-gui
BUILD_QtDialog:BOOL=OFF
# Disable tests.
BUILD_TESTING:BOOL=OFF
CMake_TEST_INSTALL:BOOL=OFF
# Disable unnecessary dependency.
CMAKE_SKIP_INSTALL_ALL_DEPENDENCY:BOOL=ON
# CPack package file name component for this platform.
CPACK_SYSTEM_NAME:STRING=sunos-i386

View File

@@ -0,0 +1,6 @@
set(CMAKE_SYSTEM_NAME SunOS)
set(CMAKE_SYSTEM_VERSION 5.10)
set(CMAKE_SYSTEM_PROCESSOR i386)
set(CMAKE_SYSROOT /opt/cross/sysroot/i386-pc-solaris2.10)
set(CMAKE_C_COMPILER /opt/cross/bin/i386-pc-solaris2.10-gcc)
set(CMAKE_CXX_COMPILER /opt/cross/bin/i386-pc-solaris2.10-g++)

View File

@@ -0,0 +1,26 @@
CMAKE_BUILD_TYPE:STRING=Release
# Link C++ library statically.
CMAKE_EXE_LINKER_FLAGS:STRING=-static-libstdc++ -static-libgcc -Wl,-z,noexecstack
# Enable ssl support in curl
CMAKE_USE_OPENSSL:BOOL=ON
OPENSSL_USE_STATIC_LIBS:BOOL=ON
OpenSSL_ROOT:PATH=/opt/cross/openssl/sparc-sun-solaris2.10
_OPENSSL_STATIC_LIBRARIES:STRING=/opt/cross/sparc-sun-solaris2.10/lib/libatomic.a
# Enable ccmake
BUILD_CursesDialog:BOOL=ON
# Disable cmake-gui
BUILD_QtDialog:BOOL=OFF
# Disable tests.
BUILD_TESTING:BOOL=OFF
CMake_TEST_INSTALL:BOOL=OFF
# Disable unnecessary dependency.
CMAKE_SKIP_INSTALL_ALL_DEPENDENCY:BOOL=ON
# CPack package file name component for this platform.
CPACK_SYSTEM_NAME:STRING=sunos-sparc

View File

@@ -0,0 +1,6 @@
set(CMAKE_SYSTEM_NAME SunOS)
set(CMAKE_SYSTEM_VERSION 5.10)
set(CMAKE_SYSTEM_PROCESSOR sparc)
set(CMAKE_SYSROOT /opt/cross/sysroot/sparc-sun-solaris2.10)
set(CMAKE_C_COMPILER /opt/cross/bin/sparc-sun-solaris2.10-gcc)
set(CMAKE_CXX_COMPILER /opt/cross/bin/sparc-sun-solaris2.10-g++)