build: use GNU ABI and fix linking order to build with the MinGW toolchain

diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml
index ed541cc..139d0a6 100644
--- a/.github/workflows/stable.yml
+++ b/.github/workflows/stable.yml
@@ -135,7 +135,7 @@
     runs-on: windows-2019
     strategy:
       matrix:
-        target: ["x86_64-pc-windows-msvc", "i686-pc-windows-msvc", "x86_64-pc-windows-gnu"]
+        target: ["x86_64-pc-windows-msvc", "i686-pc-windows-msvc", "x86_64-pc-windows-gnu", "i686-pc-windows-gnu"]
     # Only run on "pull_request" event for external PRs. This is to avoid
     # duplicate builds for PRs created from internal branches.
     if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
@@ -149,16 +149,19 @@
         uses: actions-rs/toolchain@v1
         with:
           profile: minimal
-          toolchain: ${{ env.TOOLCHAIN }}
+          toolchain: ${{ env.TOOLCHAIN }}-${{ matrix.target }}
           target: ${{ matrix.target }}
           override: true
 
-      - name: Set up MinGW
+      - name: Set up MinGW for 64 bit
         if: matrix.target == 'x86_64-pc-windows-gnu'
-        uses: egor-tensin/setup-mingw@v2
+        uses: bwoodsend/setup-winlibs-action@v1
+
+      - name: Set up MinGW for 32 bit
+        if: matrix.target == 'i686-pc-windows-gnu'
+        uses: bwoodsend/setup-winlibs-action@v1
         with:
-          platform: x64
-          cc: 1
+          architecture: i686
 
       - name: Install dependencies
         uses: crazy-max/ghaction-chocolatey@v1
@@ -166,14 +169,14 @@
           args: install nasm
 
       - name: Run cargo build
-        if: matrix.target == 'x86_64-pc-windows-gnu'
+        if: endsWith(matrix.target, '-gnu')
         uses: actions-rs/cargo@v1
         with:
           command: build
           args: --target=${{ matrix.target }} --verbose --all-targets --features=ffi,qlog
 
       - name: Run cargo test
-        if: matrix.target != 'x86_64-pc-windows-gnu'
+        if: endsWith(matrix.target, '-msvc')
         uses: actions-rs/cargo@v1
         with:
           command: test
diff --git a/quiche/src/build.rs b/quiche/src/build.rs
index 73f9f3f..d94bed5 100644
--- a/quiche/src/build.rs
+++ b/quiche/src/build.rs
@@ -32,9 +32,7 @@
 /// so adjust library location based on platform and build target.
 /// See issue: https://github.com/alexcrichton/cmake-rs/issues/18
 fn get_boringssl_platform_output_path() -> String {
-    let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();
-
-    if target_env == "msvc" {
+    if cfg!(target_env = "msvc") {
         // Code under this branch should match the logic in cmake-rs
         let debug_env_var =
             std::env::var("DEBUG").expect("DEBUG variable not defined in env");
@@ -157,18 +155,6 @@
             _ => boringssl_cmake,
         },
 
-        "windows" => match arch.as_ref() {
-            "x86_64" => {
-                // Override _WIN32_WINNT to use 64bit APIs,
-                // such as GetTickCount64().
-                boringssl_cmake.cxxflag("-D_WIN32_WINNT=0x0600");
-
-                boringssl_cmake
-            },
-
-            _ => boringssl_cmake,
-        },
-
         _ => {
             // Configure BoringSSL for building on 32-bit non-windows platforms.
             if arch == "x86" && os != "windows" {
@@ -242,7 +228,8 @@
                     .cxxflag("-DBORINGSSL_UNSAFE_FUZZER_MODE");
             }
 
-            cfg.build_target("bssl").build().display().to_string()
+            cfg.build_target("ssl").build();
+            cfg.build_target("crypto").build().display().to_string()
         });
 
         let build_path = get_boringssl_platform_output_path();