Skip to content

Commit dbc89f4

Browse files
committed
illumos: add CI using Buildomat
Add continuous integration for the x86_64-unknown-illumos target using the [buildomat] CI service, and fix up issues such that CI passes. ## What is buildomat? Buildomat is a CI service, similar in spirit to services like GitHub Actions. Buildomat is open source, built and maintained by us at Oxide, and is used by our own CI. Here's an example run with this PR: * [GitHub](https://github.com/sunshowers/libc/runs/33879292394) * [Buildomat](https://buildomat.eng.oxide.computer/wg/0/details/01JE79XGDC2N4VB80001F6T20Y/S6TwO6zHQJn0YdrmL6jTMx7b2IhpDb1fa5cLcGHX6eetNyS8/01JE79XW5Z6VCXEZ02FXPWYMCY) As part of this, at Oxide we're committing to maintaining the buildomat support. This includes: * Providing compute resources. * Maintaining and fixing issues in a timely manner. In order to have buildomat CI working, the rust-lang project would need to [install the buildomat app] (allowlisted to libc if desired). ## Why another CI system? The main alternative to buildomat would be something like [vmactions]. While vmactions provides an OmniOS build, OmniOS is actually a downstream distribution of illumos that includes several APIs not present in illumos. For example, OmniOS has an [inotify implementation] but upstream illumos doesn't. It would be easy to accidentally add inotify APIs to libc even though that wouldn't build on other illumos distributions. More importantly, at Oxide we don't feel confident providing support for a third-party service. We'd like to not just throw CI support over the wall but instead are committed to the long-term health of Rust on illumos. Since we use Buildomat ourselves, we're strongly incentivized to maintain it in a way that wouldn't be true for other solutions. [Buildomat]: https://github.com/oxidecomputer/buildomat [install the buildomat app]: https://github.com/apps/buildomat [vmactions]: https://github.com/vmactions [inotify implementation]: https://man.omnios.org/7/inotify
1 parent d76b3c8 commit dbc89f4

File tree

7 files changed

+92
-0
lines changed

7 files changed

+92
-0
lines changed

.github/buildomat/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Buildomat CI
2+
3+
Builds on illumos use Oxide Computer's [buildomat CI](https://github.com/oxidecomputer/buildomat).
4+
5+
Maintenance and compute resources are provided by Oxide Computer.

.github/buildomat/build-and-test.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
set -o xtrace
6+
7+
export TARGET="$1"
8+
9+
# Enable ANSI colors in Cargo output.
10+
export CARGO_TERM_COLOR=always
11+
12+
banner install
13+
# Note: we use ci/install-rust.sh rather than buildomat to install Rust, for
14+
# consistency with other CI jobs.
15+
TOOLCHAIN=stable INSTALL_RUSTUP=1 ptime -m sh ci/install-rust.sh
16+
17+
banner run.sh
18+
ptime -m sh ci/run.sh $TARGET

.github/buildomat/config.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Configuration for buildomat. See
2+
# https://github.com/oxidecomputer/buildomat/blob/main/README.md#per-repository-configuration.
3+
4+
enable = true
5+
# The buildomat jobs don't have access to any secrets, so it's okay for GitHub
6+
# users to create them.
7+
org_only = false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/env bash
2+
#:
3+
#: name = "x86_64-unknown-illumos"
4+
#: variety = "basic"
5+
#: target = "helios-latest"
6+
7+
exec .github/buildomat/build-and-test.sh x86_64-unknown-illumos

ci/install-rust.sh

+39
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,56 @@ echo "Setup toolchain"
77

88
toolchain="${TOOLCHAIN:-nightly}"
99
os="${OS:-}"
10+
install_rustup="${INSTALL_RUSTUP:-0}"
1011

1112
case "$(uname -s)" in
1213
Linux*) os=linux ;;
1314
Darwin*) os=macos ;;
1415
MINGW*) os=windows ;;
16+
# This captures both Solaris and illumos, which aren't possible to
17+
# distinguish via uname -s. But at the moment we don't need to make this
18+
# distinction -- the only distinction we care about is in TARGET, which is
19+
# expected to be set in the environment.
20+
SunOS*) os=solarish ;;
1521
*)
1622
echo "Unknown system $(uname -s)"
1723
exit 1
1824
;;
1925
esac
2026

27+
if [ "$install_rustup" = "1" ]; then
28+
echo "Install rustup"
29+
30+
# If the CI system already has Rust installed, we'll override that
31+
# installation via sourcing ~/.cargo/env.
32+
export RUSTUP_INIT_SKIP_PATH_CHECK=yes
33+
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
34+
# shellcheck source=/dev/null
35+
. "$HOME/.cargo/env"
36+
37+
# It is possible that "$HOME/.cargo/bin" was already in the PATH, in which
38+
# case the above source would not have any effect. If the directory wasn't
39+
# present on disk, then some shells negatively cache the PATH lookup and not
40+
# find the directory even after it is created. To work around this, force a
41+
# change to the PATH.
42+
#
43+
# This is a more portable version of `hash -r`. `hash -r` is part of the POSIX
44+
# spec [1] but may not be available in all shells. The manual suggests the
45+
# following, more portable option:
46+
#
47+
# PATH="$PATH"
48+
#
49+
# But empirically, that has been observed to not invalidate the cache in some
50+
# shells. Actually making a change to the PATH should always work (hopefully!)
51+
#
52+
# [1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/hash.html
53+
54+
# First, add a trailing colon.
55+
PATH="$PATH:"
56+
# Then, remove it.
57+
PATH="${PATH%:}"
58+
fi
59+
2160
if [ "$os" = "windows" ] && [ -n "${TARGET:-}" ]; then
2261
toolchain="$toolchain-$TARGET"
2362
rustup set profile minimal

libc-test/build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,13 @@ fn test_solarish(target: &str) {
966966
// This evaluates to a sysconf() call rather than a constant
967967
"PTHREAD_STACK_MIN" => true,
968968

969+
// Note: on illumos, the value of PTHREAD_MUTEX_DEFAULT was changed to a
970+
// new value, 0x8, in 2024-02:
971+
// https://github.com/illumos/illumos-gate/commit/50718d3ece2504ebcfdc3f385132f664b567cdd0.
972+
// libc still has the old value (= PTHREAD_MUTEX_NORMAL = 0x0) for a
973+
// window of time in case illumos systems are out of date.
974+
"PTHREAD_MUTEX_DEFAULT" if is_illumos => true,
975+
969976
// EPOLLEXCLUSIVE is a relatively recent addition to the epoll interface and may not be
970977
// defined on older systems. It is, however, safe to use on systems which do not
971978
// explicitly support it. (A no-op is an acceptable implementation of EPOLLEXCLUSIVE.)

src/unix/solarish/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,15 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
20632063
pub const PTHREAD_MUTEX_NORMAL: c_int = 0;
20642064
pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2;
20652065
pub const PTHREAD_MUTEX_RECURSIVE: c_int = 4;
2066+
2067+
// Note: on illumos, the value of PTHREAD_MUTEX_DEFAULT was changed to a new
2068+
// value, 0x8, in 2024-02:
2069+
// https://github.com/illumos/illumos-gate/commit/50718d3ece2504ebcfdc3f385132f664b567cdd0.
2070+
// libc still has the old value (= PTHREAD_MUTEX_NORMAL = 0x0) for a window of
2071+
// time in case illumos systems are out of date.
2072+
//
2073+
// Once this constant has been updated on illumos, the corresponding
2074+
// `cfg.skip_const` configuration in `libc-test/build.rs` should be removed.
20662075
pub const PTHREAD_MUTEX_DEFAULT: c_int = crate::PTHREAD_MUTEX_NORMAL;
20672076

20682077
pub const RTLD_NEXT: *mut c_void = -1isize as *mut c_void;

0 commit comments

Comments
 (0)