Skip to content
Rob Lourens edited this page Jun 29, 2020 · 10 revisions

Note - this is now obsolete. See microsoft/ripgrep-prebuilt

How to update ripgrep for VS Code

  • Clone ripgrep and checkout the latest release tag (from upstream)
  • Build for each platform and architecture (see below)
  • Strip symbols from the binary by running strip ./rg
  • Zip each build, and name with the same scheme as in earlier releases
  • Create a release for the ripgrep tag on roblourens/ripgrep, and upload the .zips
  • If the ripgrep version number changed, update vscode-ripgrep to reference the newer version, and publish vscode-ripgrep
  • Update the vscode-ripgrep dep in vscode

How to produce ripgrep builds

Start by installing Rust and following the directions at https://github.com/roblourens/ripgrep#building - it's generally very easy. cargo build --release will leave the resulting binary at ./target/release/rg.

Note: Once you have followed the setup steps, you can use the build scripts at https://github.com/roblourens/vscode-ripgrep/blob/master/tools/. Leaving the full manual steps here for reference.

Mac OS

Nothing special.

Windows

We need to build both 32 and 64-bit for Windows. It also needs to be statically compiled so that it will run on machines that don't have the Visual C++ Runtime installed.

  • You probably have rustup installed and on your path. If not, install it.
  • Run rustup target add i686-pc-windows-msvc to install the 32 bit toolchain
  • Run $env:RUSTFLAGS='-C target-feature=+crt-static -Z unstable-options'
  • Run cargo build --release --target=i686-pc-windows-msvc to build 32-bit
  • Run cargo build --release --target=x86_64-pc-windows-msvc to build 64-bit
  • Done!

Useful Windows scripts

  • dumpbin /headers rg.exe - Check whether a binary is built for 32-bit or 64-bit
  • dumpbin /dependents rg.exe - Check whether a binary is statically linked - it should not depend on VCRUNTIME140.dll

Linux

On Linux we need to build 64-bit, 32-bit, and ARM. These steps assume that your Linux OS is 64-bit.

  • To build 64-bit, add a new target: rustup target add x86_64-unknown-linux-musl
    • Then build with that target: cargo build --release --target=x86_64-unknown-linux-musl to produce a statically-linked binary.
  • To build 32-bit, first add the Rust target: rustup target add i686-unknown-linux-musl
    • sudo apt-get install musl-tools
    • Then ensure you have the 32-bit libraries you need for GCC: sudo apt-get install gcc-multilib
    • Then ensure that GCC uses the stuff you just installed: export CFLAGS=-m32
    • Finally, cargo build --release --target=i686-unknown-linux-musl
  • To build ARM, add the ARM target: rustup target add arm-unknown-linux-gnueabihf
    • Install a bunch of stuff: sudo apt-get install binutils-arm-linux-gnueabi gcc-4.8-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
    • Create a file at .cargo/config with the following contents:
[target.arm-unknown-linux-gnueabihf]
  linker = "arm-linux-gnueabihf-gcc-4.8"
  
[target.aarch64-unknown-linux-gnu]
  linker = "aarch64-linux-gnu-gcc-4.8"
  • Build: cargo build --release --target=arm-unknown-linux-gnueabihf
  • To strip symbols, you'll need to run arm-linux-gnueabi-strip ./rg instead of using strip.
  • To build aarch64 (64-bit ARM), add the aarch64 target: rustup target add aarch64-unknown-linux-gnu
    • Install tools: sudo apt-get install gcc-4.8-aarch64-linux-gnu
    • Create a file at .cargo/config:
      [target.aarch64-unknown-linux-gnu]
      linker = "aarch64-linux-gnu-gcc-4.8"
    • Build: cargo build --release --target=aarch64-unknown-linux-gnu
    • To strip symbols, you'll need to run aarch64-linux-gnu-strip ./rg instead of using strip.
Clone this wiki locally