Refactor Windows C++ toolchain selection
We used to have --cpu=x64_windows_msys for selecting msys gcc toolchain,
this is a misuse of --cpu flag.
Instead, we should use --compiler flag to select C++ toolchain.
For example, --compiler=msvc-cl, --compiler=msys-gcc, --compiler=mingw-gcc
After this change, we can use mingw gcc toolchain by following steps:
1. In MSYS, install mingw by `pacman -S mingw-w64-x86_64-gcc`
2. Add /mingw64:/mingw64/bin into PATH
3. build with --compiler=mingw-gcc
Related:
https://github.com/bazelbuild/rules_go/issues/736
Change-Id: I4b5f77ce0698cfcafefe5d2ab17657f9c9e295d3
PiperOrigin-RevId: 180678829
diff --git a/tools/cpp/CROSSTOOL.tpl b/tools/cpp/CROSSTOOL.tpl
index 2b86bbb..2f224e6 100644
--- a/tools/cpp/CROSSTOOL.tpl
+++ b/tools/cpp/CROSSTOOL.tpl
@@ -149,6 +149,23 @@
}
toolchain {
+ toolchain_identifier: "msys_x64_mingw"
+ abi_version: "local"
+ abi_libc_version: "local"
+ builtin_sysroot: ""
+ compiler: "mingw-gcc"
+ host_system_name: "local"
+ needsPic: false
+ target_libc: "mingw"
+ target_cpu: "x64_windows"
+ target_system_name: "local"
+
+%{msys_x64_mingw_content}
+
+ linking_mode_flags { mode: DYNAMIC }
+}
+
+toolchain {
toolchain_identifier: "msvc_x64"
host_system_name: "local"
target_system_name: "local"
@@ -156,8 +173,8 @@
abi_version: "local"
abi_libc_version: "local"
target_cpu: "x64_windows"
- compiler: "cl"
- target_libc: "msvcrt140"
+ compiler: "msvc-cl"
+ target_libc: "msvcrt"
default_python_version: "python2.7"
%{cxx_builtin_include_directory}