Skip to content

Instantly share code, notes, and snippets.

@kaushalmodi
Created May 9, 2017 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaushalmodi/17f03efe2e57265d90c48d39f5dabc27 to your computer and use it in GitHub Desktop.
Save kaushalmodi/17f03efe2e57265d90c48d39f5dabc27 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Time-stamp: <2017-05-09 17:25:48 kmodi>
# Usage: ./mybuild.sh # Installs using origin/master
# ./mybuild.sh --rev 0.5.1
set -euo pipefail # http://redsymbol.net/articles/unofficial-bash-strict-mode
IFS=$'\n\t'
ripgrep_rev="origin/master"
while [ $# -gt 0 ]
do
case "$1" in
"-r"|"--rev" ) shift
ripgrep_rev="$1";;
* ) echo >&2 "Error: Invalid option: $*"
esac
shift # expose next argument
done
# If ${ripgrep_rev} is origin/master, ${ripgrep_rev_basename} = master
# If ${ripgrep_rev} is 0.5.1, ${ripgrep_rev_basename} = 0.5.1
ripgrep_rev_basename=$(basename "${ripgrep_rev}")
git fetch --all
git checkout "${ripgrep_rev_basename}"
git fetch --all
git reset --hard "${ripgrep_rev}"
# Disable debug info to reduce build size (size drops from 25MB to 5.8MB)
# https://github.com/BurntSushi/ripgrep/issues/413
sed -r -i.bkp 's/^(\s*debug\s*=\s*)true/\1false/' Cargo.toml
# Build
# RUSTFLAGS="-C target-cpu=native" cargo build --release
# https://github.com/BurntSushi/ripgrep/issues/85#issuecomment-249428112
rustup target add x86_64-unknown-linux-musl
# RUSTFLAGS="-C target-cpu=native" rustup run nightly cargo build --target x86_64-unknown-linux-musl --release --features simd-accel
RUSTFLAGS="-C target-cpu=native" rustup run stable cargo build --target x86_64-unknown-linux-musl --release
# Restore the modified Cargo.toml
mv Cargo.toml{.bkp,}
# https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md#027
# Mon Nov 07 12:01:17 EST 2016 - kmodi
# Unable to compile with simd on RHEL 6.6
# cargo build --release --features 'simd-accel avx-accel'
ripgrep_install_dir="${STOW_PKGS_ROOT}/ripgrep/${ripgrep_rev_basename}"
mkdir -p "${ripgrep_install_dir}"/{bin,share/man/man1}
cp -f ./target/x86_64-unknown-linux-musl/release/rg "${ripgrep_install_dir}"/bin/.
cp -f ./doc/rg.1 "${ripgrep_install_dir}"/share/man/man1/.
@BurntSushi
Copy link

Unable to compile with simd on RHEL 6.6

You need nightly Rust for that at the moment unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment