From a5b0143f415f84700e12ac87ccd71c8943551837 Mon Sep 17 00:00:00 2001 From: Austin Wise Date: Tue, 9 Jun 2020 14:18:49 -0700 Subject: [PATCH] cargo: statically link binary on Windows/MSVC Before this change, rg.exe depended on vcruntime140.dll, which does not exist on a fresh install of Windows. Closes #1613 --- .cargo/config.toml | 8 ++++++++ CHANGELOG.md | 2 ++ README.md | 12 +++--------- 3 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..7db936b49 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,8 @@ +# On Windows MSVC, statically link the C runtime so that the resulting EXE does +# not depend on the vcruntime DLL. +# +# See: https://github.com/BurntSushi/ripgrep/pull/1613 +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"] +[target.i686-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"] diff --git a/CHANGELOG.md b/CHANGELOG.md index daf68d2f6..c8c88cd19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ Feature enhancements: Yang. * [FEATURE #1404](https://github.com/BurntSushi/ripgrep/pull/1404): ripgrep now prints a warning if nothing is searched. +* [FEATURE #1613](https://github.com/BurntSushi/ripgrep/pull/1613): + Cargo will now produce static executables on Windows when using MSVC. * [FEATURE #1680](https://github.com/BurntSushi/ripgrep/pull/1680): Add `-.` as a short flag alias for `--hidden`. * [FEATURE #1856](https://github.com/BurntSushi/ripgrep/pull/1856): diff --git a/README.md b/README.md index 18037a1bf..46938bc73 100644 --- a/README.md +++ b/README.md @@ -192,15 +192,9 @@ multiline search and opt-in fancy regex support via PCRE2. The binary name for ripgrep is `rg`. **[Archives of precompiled binaries for ripgrep are available for Windows, -macOS and Linux.](https://github.com/BurntSushi/ripgrep/releases)** Users of -platforms not explicitly mentioned below are advised to download one of these -archives. - -Linux binaries are static executables. Windows binaries are available either as -built with MinGW (GNU) or with Microsoft Visual C++ (MSVC). When possible, -prefer MSVC over GNU, but you'll need to have the [Microsoft VC++ 2015 -redistributable](https://www.microsoft.com/en-us/download/details.aspx?id=48145) -installed. +macOS and Linux.](https://github.com/BurntSushi/ripgrep/releases)** Linux and +Windows binaries are static executables. Users of platforms not explicitly +mentioned below are advised to download one of these archives. If you're a **macOS Homebrew** or a **Linuxbrew** user, then you can install ripgrep from homebrew-core: