-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to using the same cross-compiling workflow as wasmtime which ena…
…bles binary compatible builds and compiles for more platforms These prebuilt binaries will eventually be used within a wizer npm package (which itself will be used within the `@fastly/js-compute` npm package). I've tested both the macos builds and they are working I don't have a windows machine to test on and I don't have an x86_64 linux machine to test on unfortunately aarch64-linux and s390x-linux are commented out due to build errors these errors are solved in a newer version of wasmtime, when wizer updates to the newer wasmtime then we should uncomment these builds
- Loading branch information
1 parent
7e9855a
commit d3f5d04
Showing
12 changed files
with
322 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# binary-compatible-builds | ||
|
||
A small (ish) action which is intended to be used and will configure builds of | ||
Rust projects to be "more binary compatible". On Windows and macOS this | ||
involves setting a few env vars, and on Linux this involves spinning up a CentOS | ||
6 container which is running in the background. | ||
|
||
All subsequent build commands need to be wrapped in `$CENTOS` to optionally run | ||
on `$CENTOS` on Linux to ensure builds happen inside the container. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: 'Set up a CentOS 6 container to build releases in' | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# install-rust | ||
|
||
A small github action to install `rustup` and a Rust toolchain. This is | ||
generally expressed inline, but it was repeated enough in this repository it | ||
seemed worthwhile to extract. | ||
|
||
Some gotchas: | ||
|
||
* Can't `--self-update` on Windows due to permission errors (a bug in Github | ||
Actions) | ||
* `rustup` isn't installed on macOS (a bug in Github Actions) | ||
|
||
When the above are fixed we should delete this action and just use this inline: | ||
|
||
```yml | ||
- run: rustup update $toolchain && rustup default $toolchain | ||
shell: bash | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: 'Install Rust toolchain' | ||
description: 'Install both `rustup` and a Rust toolchain' | ||
|
||
inputs: | ||
toolchain: | ||
description: 'Default toolchan to install' | ||
required: false | ||
default: 'stable' | ||
|
||
runs: | ||
using: node12 | ||
main: 'main.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const child_process = require('child_process'); | ||
const toolchain = process.env.INPUT_TOOLCHAIN; | ||
const fs = require('fs'); | ||
|
||
function set_env(name, val) { | ||
fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`) | ||
} | ||
|
||
// Needed for now to get 1.24.2 which fixes a bug in 1.24.1 that causes issues | ||
// on Windows. | ||
if (process.platform === 'win32') { | ||
child_process.execFileSync('rustup', ['self', 'update']); | ||
} | ||
|
||
child_process.execFileSync('rustup', ['set', 'profile', 'minimal']); | ||
child_process.execFileSync('rustup', ['update', toolchain, '--no-self-update']); | ||
child_process.execFileSync('rustup', ['default', toolchain]); | ||
|
||
// Deny warnings on CI to keep our code warning-free as it lands in-tree. Don't | ||
// do this on nightly though since there's a fair amount of warning churn there. | ||
if (!toolchain.startsWith('nightly')) { | ||
set_env("RUSTFLAGS", "-D warnings"); | ||
} | ||
|
||
// Save disk space by avoiding incremental compilation, and also we don't use | ||
// any caching so incremental wouldn't help anyway. | ||
set_env("CARGO_INCREMENTAL", "0"); | ||
|
||
// Turn down debuginfo from 2 to 1 to help save disk space | ||
set_env("CARGO_PROFILE_DEV_DEBUG", "1"); | ||
set_env("CARGO_PROFILE_TEST_DEBUG", "1"); | ||
|
||
if (process.platform === 'darwin') { | ||
set_env("CARGO_PROFILE_DEV_SPLIT_DEBUGINFO", "unpacked"); | ||
set_env("CARGO_PROFILE_TEST_SPLIT_DEBUGINFO", "unpacked"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.