Refactor binary-compatible-builds for releases (#4171)
* Refactor binary-compatible-builds for releases I was poking around this yesterday and noticed a few things that could be improved for our release builds: * The centos container for the x86_64 builds contained a bunch of extra tooling we no longer need such as python3 and a C++ compiler. Along with custom toolchain things this could all get removed since the C we include now is quite simple. * The aarch64 and s390x cross-compiled builds had relatively high glibc version requirements compared to the x86_64 build. This was because we don't use a container to build the cross-compiled binaries. I added containers here along the lines of the x86_64 build to use an older glibc to build the release binary to lower our version requirement. This lower the aarch64 version requirement from glibc 2.28 to 2.17. Additionally the s390x requirement dropped from 2.28 to 2.16. * To make the containers a bit easier to read/write I added `Dockerfile`s for them in a new `ci/docker` directory instead of hardcoding install commands in JS. This isn't intended to be a really big change or anything for anyone, but it's intended to keep our Linux-based builds consistent at least as best we can. * Remove temporary change
This commit is contained in:
@@ -4,3 +4,7 @@ description: 'Set up a CentOS 6 container to build releases in'
|
|||||||
runs:
|
runs:
|
||||||
using: node12
|
using: node12
|
||||||
main: 'main.js'
|
main: 'main.js'
|
||||||
|
inputs:
|
||||||
|
name:
|
||||||
|
required: true
|
||||||
|
description: "Name of the build"
|
||||||
|
|||||||
43
.github/actions/binary-compatible-builds/main.js
vendored
43
.github/actions/binary-compatible-builds/main.js
vendored
@@ -12,14 +12,12 @@ function set_env(name, val) {
|
|||||||
// possible. For now 10.9 is the limit.
|
// possible. For now 10.9 is the limit.
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform == 'darwin') {
|
||||||
set_env("MACOSX_DEPLOYMENT_TARGET", "10.9");
|
set_env("MACOSX_DEPLOYMENT_TARGET", "10.9");
|
||||||
set_env("python", "python3");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Windows we build against the static CRT to reduce dll dependencies
|
// On Windows we build against the static CRT to reduce dll dependencies
|
||||||
if (process.platform == 'win32') {
|
if (process.platform == 'win32') {
|
||||||
set_env("RUSTFLAGS", "-Ctarget-feature=+crt-static");
|
set_env("RUSTFLAGS", "-Ctarget-feature=+crt-static");
|
||||||
set_env("python", "python");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +26,7 @@ if (process.platform == 'win32') {
|
|||||||
// commands in there with the `$CENTOS` env var.
|
// commands in there with the `$CENTOS` env var.
|
||||||
|
|
||||||
if (process.env.CENTOS !== undefined) {
|
if (process.env.CENTOS !== undefined) {
|
||||||
const args = ['exec', '-w', process.cwd(), '-i', 'centos'];
|
const args = ['exec', '-w', process.cwd(), '-i', 'build-container'];
|
||||||
for (const arg of process.argv.slice(2)) {
|
for (const arg of process.argv.slice(2)) {
|
||||||
args.push(arg);
|
args.push(arg);
|
||||||
}
|
}
|
||||||
@@ -36,40 +34,23 @@ if (process.env.CENTOS !== undefined) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add our rust mount onto PATH, but also add some stuff to PATH from
|
const name = process.env.INPUT_NAME;
|
||||||
// the packages that we install.
|
|
||||||
let path = process.env.PATH;
|
child_process.execFileSync('docker', [
|
||||||
path = `${path}:/rust/bin`;
|
'build',
|
||||||
path = `/opt/rh/devtoolset-8/root/usr/bin:${path}`;
|
'--tag', 'build-image',
|
||||||
|
`${process.cwd()}/ci/docker/${name}`
|
||||||
|
], stdio);
|
||||||
|
|
||||||
// Spawn a container daemonized in the background which we'll connect to via
|
|
||||||
// `docker exec`. This'll have access to the current directory.
|
|
||||||
child_process.execFileSync('docker', [
|
child_process.execFileSync('docker', [
|
||||||
'run',
|
'run',
|
||||||
'-di',
|
'--detach',
|
||||||
'--name', 'centos',
|
'--interactive',
|
||||||
|
'--name', 'build-container',
|
||||||
'-v', `${process.cwd()}:${process.cwd()}`,
|
'-v', `${process.cwd()}:${process.cwd()}`,
|
||||||
'-v', `${child_process.execSync('rustc --print sysroot').toString().trim()}:/rust:ro`,
|
'-v', `${child_process.execSync('rustc --print sysroot').toString().trim()}:/rust:ro`,
|
||||||
'--env', `PATH=${path}`,
|
'build-image',
|
||||||
// FIXME(rust-lang/rust#80703) this shouldn't be necessary
|
|
||||||
'--env', `LD_LIBRARY_PATH=/rust/lib`,
|
|
||||||
'centos:7',
|
|
||||||
], stdio);
|
], stdio);
|
||||||
|
|
||||||
// Use ourselves to run future commands
|
// Use ourselves to run future commands
|
||||||
set_env("CENTOS", __filename);
|
set_env("CENTOS", __filename);
|
||||||
|
|
||||||
// See https://edwards.sdsu.edu/research/c11-on-centos-6/ for where these
|
|
||||||
const exec = s => {
|
|
||||||
child_process.execSync(`docker exec centos ${s}`, stdio);
|
|
||||||
};
|
|
||||||
exec('yum install -y centos-release-scl cmake xz epel-release');
|
|
||||||
exec('yum install -y python3 patchelf unzip');
|
|
||||||
exec('yum install -y devtoolset-8-gcc devtoolset-8-binutils devtoolset-8-gcc-c++');
|
|
||||||
exec('yum install -y git');
|
|
||||||
|
|
||||||
// Delete `libstdc++.so` to force gcc to link against `libstdc++.a` instead.
|
|
||||||
// This is a hack and not the right way to do this, but it ends up doing the
|
|
||||||
// right thing for now.
|
|
||||||
exec('rm -f /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.so');
|
|
||||||
set_env("python", "python3");
|
|
||||||
|
|||||||
16
.github/workflows/main.yml
vendored
16
.github/workflows/main.yml
vendored
@@ -376,29 +376,17 @@ jobs:
|
|||||||
- build: aarch64-linux
|
- build: aarch64-linux
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
target: aarch64-unknown-linux-gnu
|
target: aarch64-unknown-linux-gnu
|
||||||
gcc_package: gcc-aarch64-linux-gnu
|
|
||||||
gcc: aarch64-linux-gnu-gcc
|
|
||||||
- build: s390x-linux
|
- build: s390x-linux
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
target: s390x-unknown-linux-gnu
|
target: s390x-unknown-linux-gnu
|
||||||
gcc_package: gcc-s390x-linux-gnu
|
|
||||||
gcc: s390x-linux-gnu-gcc
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: ./.github/actions/install-rust
|
- uses: ./.github/actions/install-rust
|
||||||
- uses: ./.github/actions/binary-compatible-builds
|
- uses: ./.github/actions/binary-compatible-builds
|
||||||
if: matrix.target == ''
|
with:
|
||||||
|
name: ${{ matrix.build }}
|
||||||
- name: Install cross-compilation tools
|
|
||||||
run: |
|
|
||||||
set -ex
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y ${{ matrix.gcc_package }}
|
|
||||||
upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
|
|
||||||
echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
|
|
||||||
if: matrix.target != '' && matrix.os == 'ubuntu-latest'
|
|
||||||
- run: |
|
- run: |
|
||||||
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
|
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
|
||||||
rustup target add ${{ matrix.target }}
|
rustup target add ${{ matrix.target }}
|
||||||
|
|||||||
7
ci/docker/aarch64-linux/Dockerfile
Normal file
7
ci/docker/aarch64-linux/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
RUN apt-get update -y && apt-get install -y gcc gcc-aarch64-linux-gnu ca-certificates
|
||||||
|
|
||||||
|
ENV PATH=$PATH:/rust/bin
|
||||||
|
ENV CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu
|
||||||
|
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
|
||||||
7
ci/docker/s390x-linux/Dockerfile
Normal file
7
ci/docker/s390x-linux/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
RUN apt-get update -y && apt-get install -y gcc gcc-s390x-linux-gnu ca-certificates
|
||||||
|
|
||||||
|
ENV PATH=$PATH:/rust/bin
|
||||||
|
ENV CARGO_BUILD_TARGET=s390x-unknown-linux-gnu
|
||||||
|
ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc
|
||||||
5
ci/docker/x86_64-linux/Dockerfile
Normal file
5
ci/docker/x86_64-linux/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM centos:7
|
||||||
|
|
||||||
|
RUN yum install -y git gcc
|
||||||
|
|
||||||
|
ENV PATH=$PATH:/rust/bin
|
||||||
Reference in New Issue
Block a user