summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2019-04-25 10:49:59 -0400
committerAndrew Gallant <jamslam@gmail.com>2019-04-25 11:12:14 -0400
commit5ce2d7351dba9c113318f4e43c041be7c25eaee4 (patch)
tree4b519245d76ade4ed9c2b1e8c1be7d10623f6b94
parent9dcfd9a205914af1398d0c655956b2045f51b125 (diff)
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: https://github.com/gnzlbg/jemallocator/issues/124
-rw-r--r--Cargo.toml2
-rwxr-xr-xci/before_deploy.sh5
-rwxr-xr-xci/script.sh8
-rw-r--r--ci/utils.sh23
-rw-r--r--src/main.rs5
5 files changed, 36 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index d8c68d75..7bd62d4f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -61,7 +61,7 @@ version = "2.32.0"
default-features = false
features = ["suggestions"]
-[target.'cfg(target_env = "musl")'.dependencies.jemallocator]
+[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator]
version = "0.3.0"
[build-dependencies]
diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh
index d352a88b..561cbb51 100755
--- a/ci/before_deploy.sh
+++ b/ci/before_deploy.sh
@@ -8,12 +8,13 @@ set -ex
# Generate artifacts for release
mk_artifacts() {
+ CARGO="$(builder)"
if is_arm; then
- cargo build --target "$TARGET" --release
+ "$CARGO" build --target "$TARGET" --release
else
# Technically, MUSL builds will force PCRE2 to get statically compiled,
# but we also want PCRE2 statically build for macOS binaries.
- PCRE2_SYS_STATIC=1 cargo build --target "$TARGET" --release --features 'pcre2'
+ PCRE2_SYS_STATIC=1 "$CARGO" build --target "$TARGET" --release --features 'pcre2'
fi
}
diff --git a/ci/script.sh b/ci/script.sh
index d1799e29..80bfabfc 100755
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -7,11 +7,13 @@ set -ex
. "$(dirname $0)/utils.sh"
main() {
+ CARGO="$(builder)"
+
# Test a normal debug build.
if is_arm; then
- cargo build --target "$TARGET" --verbose
+ "$CARGO" build --target "$TARGET" --verbose
else
- cargo build --target "$TARGET" --verbose --all --features 'pcre2'
+ "$CARGO" build --target "$TARGET" --verbose --all --features 'pcre2'
fi
# Show the output of the most recent build.rs stderr.
@@ -44,7 +46,7 @@ main() {
"$(dirname "${0}")/test_complete.sh"
# Run tests for ripgrep and all sub-crates.
- cargo test --target "$TARGET" --verbose --all --features 'pcre2'
+ "$CARGO" test --target "$TARGET" --verbose --all --features 'pcre2'
}
main
diff --git a/ci/utils.sh b/ci/utils.sh
index 1cf2b6dc..f3dc96d2 100644
--- a/ci/utils.sh
+++ b/ci/utils.sh
@@ -55,6 +55,13 @@ gcc_prefix() {
esac
}
+is_musl() {
+ case "$TARGET" in
+ *-musl) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
is_x86() {
case "$(architecture)" in
amd64|i386) return 0 ;;
@@ -62,6 +69,13 @@ is_x86() {
esac
}
+is_x86_64() {
+ case "$(architecture)" in
+ amd64) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
is_arm() {
case "$(architecture)" in
armhf) return 0 ;;
@@ -82,3 +96,12 @@ is_osx() {
*) return 1 ;;
esac
}
+
+builder() {
+ if is_musl && is_x86_64; then
+ cargo install cross
+ echo "cross"
+ else
+ echo "cargo"
+ fi
+}
diff --git a/src/main.rs b/src/main.rs
index d5c67a0b..bed33296 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -35,7 +35,10 @@ mod subject;
// We don't unconditionally use jemalloc because it can be nice to use the
// system's default allocator by default. Moreover, jemalloc seems to increase
// compilation times by a bit.
-#[cfg(target_env = "musl")]
+//
+// Moreover, we only do this on 64-bit systems since jemalloc doesn't support
+// i686.
+#[cfg(all(target_env = "musl", target_pointer_width = "64"))]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;