Files
wasmtime/.github/actions/binary-compatible-builds/main.js
Alex Crichton 08b7c87793 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
2022-05-20 12:13:50 -05:00

57 lines
1.5 KiB
JavaScript
Executable File

#!/usr/bin/env node
const child_process = require('child_process');
const stdio = { stdio: 'inherit' };
const fs = require('fs');
function set_env(name, val) {
fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`)
}
// On OSX all we need to do is configure our deployment target as old as
// possible. For now 10.9 is the limit.
if (process.platform == 'darwin') {
set_env("MACOSX_DEPLOYMENT_TARGET", "10.9");
return;
}
// On Windows we build against the static CRT to reduce dll dependencies
if (process.platform == 'win32') {
set_env("RUSTFLAGS", "-Ctarget-feature=+crt-static");
return;
}
// ... and on Linux we do fancy things with containers. We'll spawn an old
// CentOS container in the background with a super old glibc, and then we'll run
// commands in there with the `$CENTOS` env var.
if (process.env.CENTOS !== undefined) {
const args = ['exec', '-w', process.cwd(), '-i', 'build-container'];
for (const arg of process.argv.slice(2)) {
args.push(arg);
}
child_process.execFileSync('docker', args, stdio);
return;
}
const name = process.env.INPUT_NAME;
child_process.execFileSync('docker', [
'build',
'--tag', 'build-image',
`${process.cwd()}/ci/docker/${name}`
], stdio);
child_process.execFileSync('docker', [
'run',
'--detach',
'--interactive',
'--name', 'build-container',
'-v', `${process.cwd()}:${process.cwd()}`,
'-v', `${child_process.execSync('rustc --print sysroot').toString().trim()}:/rust:ro`,
'build-image',
], stdio);
// Use ourselves to run future commands
set_env("CENTOS", __filename);