about summary refs log tree commit diff
path: root/src/ci/docker/scripts
diff options
context:
space:
mode:
authorPetr Sumbera <sumbera@volny.cz>2025-03-04 12:19:22 +0000
committerPetr Sumbera <sumbera@volny.cz>2025-05-30 09:18:31 +0000
commit0f1579b4bb21af7a79331a1a26dc2370ec182fc4 (patch)
tree0f60905e53b6daa5e52071e5c6572d2bcf039f20 /src/ci/docker/scripts
parent1ac1950c337039add1a83113ed6d1bd64bcb1142 (diff)
downloadrust-0f1579b4bb21af7a79331a1a26dc2370ec182fc4.tar.gz
rust-0f1579b4bb21af7a79331a1a26dc2370ec182fc4.zip
build dist for x86_64-pc-solaris and sparcv9-sun-solaris
Diffstat (limited to 'src/ci/docker/scripts')
-rw-r--r--src/ci/docker/scripts/illumos-toolchain.sh52
-rw-r--r--src/ci/docker/scripts/shared.sh34
-rw-r--r--src/ci/docker/scripts/solaris-toolchain.sh162
3 files changed, 201 insertions, 47 deletions
diff --git a/src/ci/docker/scripts/illumos-toolchain.sh b/src/ci/docker/scripts/illumos-toolchain.sh
index 0b2c09b3eed..7a3ca875554 100644
--- a/src/ci/docker/scripts/illumos-toolchain.sh
+++ b/src/ci/docker/scripts/illumos-toolchain.sh
@@ -4,6 +4,8 @@ set -o errexit
 set -o pipefail
 set -o xtrace
 
+source /tmp/shared.sh
+
 ARCH="$1"
 PHASE="$2"
 
@@ -59,52 +61,13 @@ BINUTILS_TAR="$BINUTILS_BASE.tar.bz2"
 BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/$BINUTILS_TAR"
 
 
-download_file() {
-        local file="$1"
-        local url="$2"
-        local sum="$3"
-
-        while :; do
-                if [[ -f "$file" ]]; then
-                        if ! h="$(sha256sum "$file" | awk '{ print $1 }')"; then
-                                printf 'ERROR: reading hash\n' >&2
-                                exit 1
-                        fi
-
-                        if [[ "$h" == "$sum" ]]; then
-                                return 0
-                        fi
-
-                        printf 'WARNING: hash mismatch: %s != expected %s\n' \
-                            "$h" "$sum" >&2
-                        rm -f "$file"
-                fi
-
-                printf 'Downloading: %s\n' "$url"
-                if ! curl -f -L -o "$file" "$url"; then
-                        rm -f "$file"
-                        sleep 1
-                fi
-        done
-}
-
-
 case "$PHASE" in
 sysroot)
-        download_file "/tmp/$SYSROOT_TAR" "$SYSROOT_URL" "$SYSROOT_SUM"
-        mkdir -p "$SYSROOT_DIR"
-        cd "$SYSROOT_DIR"
-        tar -xzf "/tmp/$SYSROOT_TAR"
-        rm -f "/tmp/$SYSROOT_TAR"
+        download_tar_and_extract_into_dir "$SYSROOT_URL" "$SYSROOT_SUM" "$SYSROOT_DIR"
         ;;
 
 binutils)
-        download_file "/tmp/$BINUTILS_TAR" "$BINUTILS_URL" "$BINUTILS_SUM"
-        mkdir -p /ws/src/binutils
-        cd /ws/src/binutils
-        tar -xjf "/tmp/$BINUTILS_TAR"
-        rm -f "/tmp/$BINUTILS_TAR"
-
+        download_tar_and_extract_into_dir "$BINUTILS_URL" "$BINUTILS_SUM" /ws/src/binutils
         mkdir -p /ws/build/binutils
         cd /ws/build/binutils
         "/ws/src/binutils/$BINUTILS_BASE/configure" \
@@ -123,12 +86,7 @@ binutils)
         ;;
 
 gcc)
-        download_file "/tmp/$GCC_TAR" "$GCC_URL" "$GCC_SUM"
-        mkdir -p /ws/src/gcc
-        cd /ws/src/gcc
-        tar -xJf "/tmp/$GCC_TAR"
-        rm -f "/tmp/$GCC_TAR"
-
+        download_tar_and_extract_into_dir "$GCC_URL" "$GCC_SUM" /ws/src/gcc
         mkdir -p /ws/build/gcc
         cd /ws/build/gcc
         export CFLAGS='-fPIC'
diff --git a/src/ci/docker/scripts/shared.sh b/src/ci/docker/scripts/shared.sh
index 9969659088d..6efdbb2070d 100644
--- a/src/ci/docker/scripts/shared.sh
+++ b/src/ci/docker/scripts/shared.sh
@@ -40,3 +40,37 @@ function retry {
     }
   done
 }
+
+download_tar_and_extract_into_dir() {
+  local url="$1"
+  local sum="$2"
+  local dir="$3"
+  local file=$(mktemp -u)
+
+  while :; do
+    if [[ -f "$file" ]]; then
+      if ! h="$(sha256sum "$file" | awk '{ print $1 }')"; then
+        printf 'ERROR: reading hash\n' >&2
+        exit 1
+      fi
+
+      if [[ "$h" == "$sum" ]]; then
+        break
+      fi
+
+      printf 'WARNING: hash mismatch: %s != expected %s\n' "$h" "$sum" >&2
+      rm -f "$file"
+    fi
+
+    printf 'Downloading: %s\n' "$url"
+    if ! curl -f -L -o "$file" "$url"; then
+       rm -f "$file"
+      sleep 1
+    fi
+  done
+
+  mkdir -p "$dir"
+  cd "$dir"
+  tar -xf "$file"
+  rm -f "$file"
+}
diff --git a/src/ci/docker/scripts/solaris-toolchain.sh b/src/ci/docker/scripts/solaris-toolchain.sh
new file mode 100644
index 00000000000..82f0f105523
--- /dev/null
+++ b/src/ci/docker/scripts/solaris-toolchain.sh
@@ -0,0 +1,162 @@
+#!/bin/bash
+
+set -o errexit
+set -o pipefail
+set -o xtrace
+
+source /tmp/shared.sh
+
+ARCH="$1"
+PHASE="$2"
+
+JOBS="$(getconf _NPROCESSORS_ONLN)"
+
+case "$ARCH" in
+x86_64)
+        SYSROOT_MACH='i386'
+        ;;
+sparcv9)
+        SYSROOT_MACH='sparc'
+        ;;
+*)
+        printf 'ERROR: unknown architecture: %s\n' "$ARCH"
+        exit 1
+esac
+
+BUILD_TARGET="$ARCH-pc-solaris2.11"
+
+#
+# The illumos and the Solaris build both use the same GCC-level host triple,
+# though different versions of GCC are used and with different configuration
+# options.  To ensure as little accidental cross-pollination as possible, we
+# build the illumos toolchain in a specific directory tree and just symlink the
+# expected tools into /usr/local/bin at the end.  We omit /usr/local/bin from
+# PATH here for similar reasons.
+#
+PREFIX="/opt/solaris/$ARCH"
+export PATH="$PREFIX/bin:/usr/bin:/bin:/usr/sbin:/sbin"
+
+#
+# NOTE: The compiler version selected here is more specific than might appear.
+# GCC 7.X releases do not appear to cross-compile correctly for Solaris
+# targets, at least insofar as they refuse to enable TLS in libstdc++.  When
+# changing the GCC version in future, one must carefully verify that TLS is
+# enabled in all of the static libraries we intend to include in output
+# binaries.
+#
+GCC_VERSION='8.4.0'
+GCC_SUM='e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4'
+GCC_BASE="gcc-$GCC_VERSION"
+GCC_TAR="gcc-$GCC_VERSION.tar.xz"
+GCC_URL="https://ci-mirrors.rust-lang.org/rustc/$GCC_TAR"
+
+SYSROOT_VER='2025-02-21'
+if [ $ARCH = "x86_64" ]; then
+SYSROOT_SUM='e82b78c14464cc2dc71f3cdab312df3dd63441d7c23eeeaf34d41d8b947688d3'
+SYSROOT_TAR="solaris-11.4.42.111.0-i386-sysroot-v$SYSROOT_VER.tar.bz2"
+SYSROOT_DIR="$PREFIX/sysroot-x86_64"
+else
+SYSROOT_SUM='e249a7ef781b9b3297419bd014fa0574800703981d84e113d6af3a897a8b4ffc'
+SYSROOT_TAR="solaris-11.4.42.111.0-sparc-sysroot-v$SYSROOT_VER.tar.bz2"
+SYSROOT_DIR="$PREFIX/sysroot-sparcv9"
+fi
+SYSROOT_URL="https://ci-mirrors.rust-lang.org/rustc/$SYSROOT_TAR"
+
+BINUTILS_VERSION='2.44'
+BINUTILS_SUM='ce2017e059d63e67ddb9240e9d4ec49c2893605035cd60e92ad53177f4377237'
+BINUTILS_BASE="binutils-$BINUTILS_VERSION"
+BINUTILS_TAR="$BINUTILS_BASE.tar.xz"
+BINUTILS_URL="https://ci-mirrors.rust-lang.org/rustc/$BINUTILS_TAR"
+
+
+case "$PHASE" in
+sysroot)
+        download_tar_and_extract_into_dir "$SYSROOT_URL" "$SYSROOT_SUM" "$SYSROOT_DIR"
+        ;;
+
+binutils)
+        download_tar_and_extract_into_dir "$BINUTILS_URL" "$BINUTILS_SUM" /ws/src/binutils
+        cat > binutils.patch <<EOF
+Workaround for: https://github.com/rust-lang/rust/issues/137997
+--- binutils-2.44/bfd/elflink.c
++++ binutils-2.44/bfd/elflink.c
+@@ -5150,7 +5150,7 @@
+          if it is not a function, because it might be the version
+          symbol itself.  FIXME: What if it isn't?  */
+       if ((iver.vs_vers & VERSYM_HIDDEN) != 0
+-          || (vernum > 1
++          || (vernum > 1 && strcmp(name, "logb") != 0
+           && (!bfd_is_abs_section (sec)
+               || bed->is_function_type (ELF_ST_TYPE (isym->st_info)))))
+         {
+EOF
+        f=binutils-$BINUTILS_VERSION/bfd/elflink.c && expand -t 4 "$f" > "$f.exp"
+        mv binutils-$BINUTILS_VERSION/bfd/elflink.c.exp binutils-$BINUTILS_VERSION/bfd/elflink.c
+        patch binutils-$BINUTILS_VERSION/bfd/elflink.c < binutils.patch
+        rm binutils.patch
+
+        mkdir -p /ws/build/binutils
+        cd /ws/build/binutils
+        "/ws/src/binutils/$BINUTILS_BASE/configure" \
+            --prefix="$PREFIX" \
+            --target="$BUILD_TARGET" \
+            --program-prefix="$ARCH-solaris-" \
+            --with-sysroot="$SYSROOT_DIR"
+
+        make -j "$JOBS"
+
+        mkdir -p "$PREFIX"
+        make install
+
+        cd
+        rm -rf /ws/src/binutils /ws/build/binutils
+        ;;
+
+gcc)
+        download_tar_and_extract_into_dir "$GCC_URL" "$GCC_SUM" /ws/src/gcc
+        mkdir -p /ws/build/gcc
+        cd /ws/build/gcc
+        export CFLAGS='-fPIC'
+        export CXXFLAGS='-fPIC'
+        export CXXFLAGS_FOR_TARGET='-fPIC'
+        export CFLAGS_FOR_TARGET='-fPIC'
+        "/ws/src/gcc/$GCC_BASE/configure" \
+            --prefix="$PREFIX" \
+            --target="$BUILD_TARGET" \
+            --program-prefix="$ARCH-solaris-" \
+            --with-sysroot="$SYSROOT_DIR" \
+            --with-gnu-as \
+            --with-gnu-ld \
+            --disable-nls \
+            --disable-libgomp \
+            --disable-libquadmath \
+            --disable-libssp \
+            --disable-libvtv \
+            --disable-libcilkrts \
+            --disable-libada \
+            --disable-libsanitizer \
+            --disable-libquadmath-support \
+            --disable-shared \
+            --enable-tls
+
+        make -j "$JOBS"
+
+        mkdir -p "$PREFIX"
+        make install
+
+        #
+        # Link toolchain commands into /usr/local/bin so that cmake and others
+        # can find them:
+        #
+        (cd "$PREFIX/bin" && ls -U) | grep "^$ARCH-solaris-" |
+            xargs -t -I% ln -s "$PREFIX/bin/%" '/usr/local/bin/'
+
+        cd
+        rm -rf /ws/src/gcc /ws/build/gcc
+        ;;
+
+*)
+        printf 'ERROR: unknown phase "%s"\n' "$PHASE" >&2
+        exit 100
+        ;;
+esac