summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAustin Wise <AustinWise@gmail.com>2020-06-09 14:18:49 -0700
committerAndrew Gallant <jamslam@gmail.com>2021-05-31 21:51:18 -0400
commit46d0130597a8340c19fdd41b107c209653451698 (patch)
treeebeaf4d779e897ca25b538e0b7fc9d7daea2afc1
parent7534d5144f5c5e89d67c791e663cdc0bee069b0e (diff)
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
-rw-r--r--.cargo/config.toml8
-rw-r--r--CHANGELOG.md2
-rw-r--r--README.md12
3 files changed, 13 insertions, 9 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 00000000..7db936b4
--- /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 daf68d2f..c8c88cd1 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 18037a1b..46938bc7 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: