Skip to content

Commit 58e8869

Browse files
committed
ci: use cross for musl x86_64 builds
This is necessary because jemalloc + musl + Ubuntu 16.04 is apparently broken. Moreover, jemalloc doesn't support i686, so we accept the performance regression there. See also: gnzlbg/jemallocator#124
1 parent 1d44365 commit 58e8869

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ version = "2.32.0"
6161
default-features = false
6262
features = ["suggestions"]
6363

64-
[target.'cfg(target_env = "musl")'.dependencies.jemallocator]
64+
[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator]
6565
version = "0.3.0"
6666

6767
[build-dependencies]

ci/before_deploy.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ set -ex
88

99
# Generate artifacts for release
1010
mk_artifacts() {
11+
CARGO="$(builder)"
1112
if is_arm; then
12-
cargo build --target "$TARGET" --release
13+
"$CARGO" build --target "$TARGET" --release
1314
else
1415
# Technically, MUSL builds will force PCRE2 to get statically compiled,
1516
# but we also want PCRE2 statically build for macOS binaries.
16-
PCRE2_SYS_STATIC=1 cargo build --target "$TARGET" --release --features 'pcre2'
17+
PCRE2_SYS_STATIC=1 "$CARGO" build --target "$TARGET" --release --features 'pcre2'
1718
fi
1819
}
1920

ci/script.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ set -ex
77
. "$(dirname $0)/utils.sh"
88

99
main() {
10+
CARGO="$(builder)"
11+
1012
# Test a normal debug build.
1113
if is_arm; then
12-
cargo build --target "$TARGET" --verbose
14+
"$CARGO" build --target "$TARGET" --verbose
1315
else
14-
cargo build --target "$TARGET" --verbose --all --features 'pcre2'
16+
"$CARGO" build --target "$TARGET" --verbose --all --features 'pcre2'
1517
fi
1618

1719
# Show the output of the most recent build.rs stderr.
@@ -44,7 +46,7 @@ main() {
4446
"$(dirname "${0}")/test_complete.sh"
4547

4648
# Run tests for ripgrep and all sub-crates.
47-
cargo test --target "$TARGET" --verbose --all --features 'pcre2'
49+
"$CARGO" test --target "$TARGET" --verbose --all --features 'pcre2'
4850
}
4951

5052
main

ci/utils.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,27 @@ gcc_prefix() {
5555
esac
5656
}
5757

58+
is_musl() {
59+
case "$TARGET" in
60+
*-musl) return 0 ;;
61+
*) return 1 ;;
62+
esac
63+
}
64+
5865
is_x86() {
5966
case "$(architecture)" in
6067
amd64|i386) return 0 ;;
6168
*) return 1 ;;
6269
esac
6370
}
6471

72+
is_x86_64() {
73+
case "$(architecture)" in
74+
amd64) return 0 ;;
75+
*) return 1 ;;
76+
esac
77+
}
78+
6579
is_arm() {
6680
case "$(architecture)" in
6781
armhf) return 0 ;;
@@ -82,3 +96,12 @@ is_osx() {
8296
*) return 1 ;;
8397
esac
8498
}
99+
100+
builder() {
101+
if is_musl && is_x86_64; then
102+
cargo install cross
103+
echo "cross"
104+
else
105+
echo "cargo"
106+
fi
107+
}

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ mod subject;
3535
// We don't unconditionally use jemalloc because it can be nice to use the
3636
// system's default allocator by default. Moreover, jemalloc seems to increase
3737
// compilation times by a bit.
38-
#[cfg(target_env = "musl")]
38+
//
39+
// Moreover, we only do this on 64-bit systems since jemalloc doesn't support
40+
// i686.
41+
#[cfg(all(target_env = "musl", target_pointer_width = "64"))]
3942
#[global_allocator]
4043
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
4144

0 commit comments

Comments
 (0)