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

build dist for x86_64-pc-solaris and sparcv9-sun-solaris #138699

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -2008,8 +2008,7 @@ dependencies = [
[[package]]
name = "libffi-sys"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36115160c57e8529781b4183c2bb51fdc1f6d6d1ed345591d84be7703befb3c"
source = "git+https://github.com/psumbera/libffi-rs.git?branch=sparcv9#dff93b3d171736632ce48f9cb07548f30ccc9f61"
dependencies = [
"cc",
]
@@ -2316,8 +2315,7 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "nix"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
source = "git+https://github.com/psumbera/nix.git?branch=mypatch#9491d8fb08f8d104cd7b421121142bb82ea3ad6d"
dependencies = [
"bitflags",
"cfg-if",
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -89,3 +89,7 @@ codegen-units = 1
# FIXME: LTO cannot be enabled for binaries in a workspace
# <https://github.com/rust-lang/cargo/issues/9330>
# lto = true

[patch.crates-io]
nix = { git = "https://github.com/psumbera/nix.git", branch = "mypatch" }
libffi-sys = { git = "https://github.com/psumbera/libffi-rs.git", branch = "sparcv9" }
Comment on lines +93 to +95
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be fixed upstream, we really cannot be repointing these deps to the non-upstream forks.

39 changes: 39 additions & 0 deletions src/ci/docker/host-x86_64/dist-sparcv9-solaris/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:18.04

# Enable source repositories, which are disabled by default on Ubuntu >= 18.04
RUN sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list

COPY scripts/cross-apt-packages.sh /tmp/
RUN bash /tmp/cross-apt-packages.sh

# Required for cross-build gcc, and we install python2 to test general compatibility.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgmp-dev \
libmpfr-dev \
libmpc-dev \
python2.7 \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/solaris-toolchain.sh /tmp/

RUN bash /tmp/solaris-toolchain.sh sparcv9 sysroot
RUN bash /tmp/solaris-toolchain.sh sparcv9 binutils
RUN bash /tmp/solaris-toolchain.sh sparcv9 gcc

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

COPY scripts/cmake.sh /scripts/
RUN /scripts/cmake.sh

ENV \
AR_sparcv9_sun_solaris=sparcv9-solaris-ar \
RANLIB_sparcv9_sun_solaris=sparcv9-solaris-ranlib \
CC_sparcv9_sun_solaris=sparcv9-solaris-gcc \
CXX_sparcv9_sun_solaris=sparcv9-solaris-g++

ENV HOSTS=sparcv9-sun-solaris

ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
11 changes: 0 additions & 11 deletions src/ci/docker/host-x86_64/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
@@ -43,12 +43,6 @@ ENV \
CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++ \
CXXFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \
LDFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -L/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/lib" \
AR_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-ar \
CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-gcc \
CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \
AR_x86_64_pc_solaris=x86_64-pc-solaris2.10-ar \
CC_x86_64_pc_solaris=x86_64-pc-solaris2.10-gcc \
CXX_x86_64_pc_solaris=x86_64-pc-solaris2.10-g++ \
CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-9 \
CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-9 \
AR_x86_64_fortanix_unknown_sgx=ar \
@@ -84,9 +78,6 @@ WORKDIR /tmp
COPY scripts/shared.sh /tmp/
COPY scripts/build-fuchsia-toolchain.sh /tmp/
RUN /tmp/build-fuchsia-toolchain.sh
COPY host-x86_64/dist-various-2/build-solaris-toolchain.sh /tmp/
RUN /tmp/build-solaris-toolchain.sh x86_64 amd64 solaris-i386 pc
RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc sun
COPY host-x86_64/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh

@@ -118,8 +109,6 @@ ENV TARGETS=$TARGETS,wasm32-wasip1
ENV TARGETS=$TARGETS,wasm32-wasip1-threads
ENV TARGETS=$TARGETS,wasm32-wasip2
ENV TARGETS=$TARGETS,wasm32v1-none
ENV TARGETS=$TARGETS,sparcv9-sun-solaris
ENV TARGETS=$TARGETS,x86_64-pc-solaris
ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32
ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx
ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda
111 changes: 0 additions & 111 deletions src/ci/docker/host-x86_64/dist-various-2/build-solaris-toolchain.sh

This file was deleted.

39 changes: 39 additions & 0 deletions src/ci/docker/host-x86_64/dist-x86_64-solaris/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:18.04

# Enable source repositories, which are disabled by default on Ubuntu >= 18.04
RUN sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list

COPY scripts/cross-apt-packages.sh /tmp/
RUN bash /tmp/cross-apt-packages.sh

# Required for cross-build gcc, and we install python2 to test general compatibility.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgmp-dev \
libmpfr-dev \
libmpc-dev \
python2.7 \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/solaris-toolchain.sh /tmp/

RUN bash /tmp/solaris-toolchain.sh x86_64 sysroot
RUN bash /tmp/solaris-toolchain.sh x86_64 binutils
RUN bash /tmp/solaris-toolchain.sh x86_64 gcc

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

COPY scripts/cmake.sh /scripts/
RUN /scripts/cmake.sh

ENV \
AR_x86_64_pc_solaris=x86_64-solaris-ar \
RANLIB_x86_64_pc_solaris=x86_64-solaris-ranlib \
CC_x86_64_pc_solaris=x86_64-solaris-gcc \
CXX_x86_64_pc_solaris=x86_64-solaris-g++

ENV HOSTS=x86_64-pc-solaris

ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
207 changes: 207 additions & 0 deletions src/ci/docker/scripts/solaris-toolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o xtrace

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 configure
# 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://ftp.gnu.org/gnu/gcc/$GCC_BASE/$GCC_TAR"

if [ $ARCH = "x86_64" ]; then
SYSROOT_VER='2025-02-21'
SYSROOT_SUM='e82b78c14464cc2dc71f3cdab312df3dd63441d7c23eeeaf34d41d8b947688d3'
SYSROOT_TAR="solaris-11.4.42.111.0-i386-sysroot-v$SYSROOT_VER.tar.bz2"
SYSROOT_URL="https://github.com/psumbera/solaris-sysroot/releases/download/v$SYSROOT_VER/"
SYSROOT_URL+="$SYSROOT_TAR"
SYSROOT_DIR="$PREFIX/sysroot-x86_64"
else
SYSROOT_VER='2025-02-21'
SYSROOT_SUM='e249a7ef781b9b3297419bd014fa0574800703981d84e113d6af3a897a8b4ffc'
SYSROOT_TAR="solaris-11.4.42.111.0-sparc-sysroot-v$SYSROOT_VER.tar.bz2"
SYSROOT_URL="https://github.com/psumbera/solaris-sysroot/releases/download/v$SYSROOT_VER/"
SYSROOT_URL+="$SYSROOT_TAR"
SYSROOT_DIR="$PREFIX/sysroot-sparcv9"
fi

BINUTILS_VERSION='2.44'
BINUTILS_SUM='f66390a661faa117d00fab2e79cf2dc9d097b42cc296bf3f8677d1e7b452dc3a'
BINUTILS_BASE="binutils-$BINUTILS_VERSION"
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 -xjf "/tmp/$SYSROOT_TAR"
rm -f "/tmp/$SYSROOT_TAR"
;;

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"
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
expand -t 4 binutils-2.44/bfd/elflink.c > binutils-2.44/bfd/elflink.c.exp
mv binutils-2.44/bfd/elflink.c.exp binutils-2.44/bfd/elflink.c
patch binutils-2.44/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_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"

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
6 changes: 6 additions & 0 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
@@ -222,6 +222,12 @@ auto:
- name: dist-x86_64-netbsd
<<: *job-linux-4c

- name: dist-x86_64-solaris
<<: *job-linux-4c

- name: dist-sparcv9-solaris
<<: *job-linux-4c

# The i686-gnu job is split into multiple jobs to run tests in parallel.
# i686-gnu-1 skips tests that run in i686-gnu-2.
- name: i686-gnu-1
3 changes: 1 addition & 2 deletions src/tools/rust-analyzer/Cargo.lock
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ inherits = "release"
debug = 2

[patch.'crates-io']
nix = { git = "https://github.com/psumbera/nix.git", branch = "mypatch-v28" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not going to happen, this will break our crates-io releases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is waiting for new nix version the only option here? Last nix release is from May 2024..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I think that's the case, AFAIK neither r-a nor the root manifest here can use cargo patch functionality.

For the root manifest here, I believe we can't be pointing to non-rust-lang/* forks via git dependencies too for supply-chain security reasons, cc @pietroalbini.

# rowan = { path = "../rowan" }

# chalk-solve = { path = "../chalk/chalk-solve" }
Loading