diff --git a/.github/actions/binary-compatible-builds/action.yml b/.github/actions/binary-compatible-builds/action.yml index de2e74ec77..c2950d99b0 100644 --- a/.github/actions/binary-compatible-builds/action.yml +++ b/.github/actions/binary-compatible-builds/action.yml @@ -4,3 +4,7 @@ description: 'Set up a CentOS 6 container to build releases in' runs: using: node12 main: 'main.js' +inputs: + name: + required: true + description: "Name of the build" diff --git a/.github/actions/binary-compatible-builds/main.js b/.github/actions/binary-compatible-builds/main.js index a70cd76e83..378c5c202c 100755 --- a/.github/actions/binary-compatible-builds/main.js +++ b/.github/actions/binary-compatible-builds/main.js @@ -12,14 +12,12 @@ function set_env(name, val) { // possible. For now 10.9 is the limit. if (process.platform == 'darwin') { set_env("MACOSX_DEPLOYMENT_TARGET", "10.9"); - set_env("python", "python3"); return; } // On Windows we build against the static CRT to reduce dll dependencies if (process.platform == 'win32') { set_env("RUSTFLAGS", "-Ctarget-feature=+crt-static"); - set_env("python", "python"); return; } @@ -28,7 +26,7 @@ if (process.platform == 'win32') { // commands in there with the `$CENTOS` env var. 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)) { args.push(arg); } @@ -36,40 +34,23 @@ if (process.env.CENTOS !== undefined) { return; } -// Add our rust mount onto PATH, but also add some stuff to PATH from -// the packages that we install. -let path = process.env.PATH; -path = `${path}:/rust/bin`; -path = `/opt/rh/devtoolset-8/root/usr/bin:${path}`; +const name = process.env.INPUT_NAME; + +child_process.execFileSync('docker', [ + 'build', + '--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', [ 'run', - '-di', - '--name', 'centos', + '--detach', + '--interactive', + '--name', 'build-container', '-v', `${process.cwd()}:${process.cwd()}`, '-v', `${child_process.execSync('rustc --print sysroot').toString().trim()}:/rust:ro`, - '--env', `PATH=${path}`, - // FIXME(rust-lang/rust#80703) this shouldn't be necessary - '--env', `LD_LIBRARY_PATH=/rust/lib`, - 'centos:7', + 'build-image', ], stdio); // Use ourselves to run future commands 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"); diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 663fac5f2d..bed0f81c1f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -376,29 +376,17 @@ jobs: - build: aarch64-linux os: ubuntu-latest target: aarch64-unknown-linux-gnu - gcc_package: gcc-aarch64-linux-gnu - gcc: aarch64-linux-gnu-gcc - build: s390x-linux os: ubuntu-latest target: s390x-unknown-linux-gnu - gcc_package: gcc-s390x-linux-gnu - gcc: s390x-linux-gnu-gcc steps: - uses: actions/checkout@v2 with: submodules: true - uses: ./.github/actions/install-rust - uses: ./.github/actions/binary-compatible-builds - if: matrix.target == '' - - - 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' + with: + name: ${{ matrix.build }} - run: | echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV rustup target add ${{ matrix.target }} diff --git a/ci/docker/aarch64-linux/Dockerfile b/ci/docker/aarch64-linux/Dockerfile new file mode 100644 index 0000000000..06c7cefc8d --- /dev/null +++ b/ci/docker/aarch64-linux/Dockerfile @@ -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 diff --git a/ci/docker/s390x-linux/Dockerfile b/ci/docker/s390x-linux/Dockerfile new file mode 100644 index 0000000000..19acf1d825 --- /dev/null +++ b/ci/docker/s390x-linux/Dockerfile @@ -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 diff --git a/ci/docker/x86_64-linux/Dockerfile b/ci/docker/x86_64-linux/Dockerfile new file mode 100644 index 0000000000..89ddc2b282 --- /dev/null +++ b/ci/docker/x86_64-linux/Dockerfile @@ -0,0 +1,5 @@ +FROM centos:7 + +RUN yum install -y git gcc + +ENV PATH=$PATH:/rust/bin