From 449dbe5272aef429067abe3226d30f640fd3bac3 Mon Sep 17 00:00:00 2001
From: Bert Belder <bertbelder@gmail.com>
Date: Mon, 23 Mar 2020 20:28:18 +0100
Subject: [PATCH] Statically link the C runtime library on Windows (#4469)

---
 .cargo/config            |  2 ++
 .github/workflows/ci.yml | 14 +++++++-------
 .gitignore               |  2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)
 create mode 100644 .cargo/config

diff --git a/.cargo/config b/.cargo/config
new file mode 100644
index 0000000000..ac2b23f814
--- /dev/null
+++ b/.cargo/config
@@ -0,0 +1,2 @@
+[target.x86_64-pc-windows-msvc]
+rustflags = ["-C", "target-feature=+crt-static"]
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 666db1dc79..79bd8bdaa7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -54,7 +54,7 @@ jobs:
         if: startsWith(matrix.config.os, 'ubuntu') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') && github.repository == 'denoland/deno'
         run: |
           mkdir -p target/release
-          tar --exclude=.cargo --exclude=".git*" --exclude=target --exclude=deno_typescript/typescript/tests --exclude=third_party/cpplint --exclude=third_party/node_modules --exclude=third_party/python_packages --exclude=third_party/prebuilt -czvf target/release/deno_src.tar.gz -C .. deno
+          tar --exclude=.cargo_home --exclude=".git*" --exclude=target --exclude=deno_typescript/typescript/tests --exclude=third_party/cpplint --exclude=third_party/node_modules --exclude=third_party/python_packages --exclude=third_party/prebuilt -czvf target/release/deno_src.tar.gz -C .. deno
 
       - name: Install rust
         uses: hecrj/setup-rust-action@v1
@@ -90,11 +90,11 @@ jobs:
 
       - name: Configure cargo data directory
         # After this point, all cargo registry and crate data is stored in
-        # $GITHUB_WORKSPACE/.cargo. This allows us to cache only the files that
-        # are needed during the build process. Additionally, this works around
-        # a bug in the 'cache' action that causes directories outside of the
-        # workspace dir to be saved/restored incorrectly.
-        run: echo "::set-env name=CARGO_HOME::$(pwd)/.cargo"
+        # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files
+        # that are needed during the build process. Additionally, this works
+        # around a bug in the 'cache' action that causes directories outside of
+        # the workspace dir to be saved/restored incorrectly.
+        run: echo "::set-env name=CARGO_HOME::$(pwd)/.cargo_home"
 
       - name: Cache
         uses: actions/cache@master
@@ -104,7 +104,7 @@ jobs:
           # so we cache only those subdirectories of target/{debug|release} that
           # contain the build output for crates that come from the registry.
           path: |-
-            .cargo
+            .cargo_home
             target/*/.*
             target/*/build
             target/*/deps
diff --git a/.gitignore b/.gitignore
index ce0e778c37..eff476d86e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,7 @@
 *.pyc
 *.swp
 
-/.cargo/
+/.cargo_home/
 /.idea/
 /.vscode/
 gclient_config.py_entries