aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-04-07 16:39:19 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-04-07 17:06:12 +0000
commit114ead3d1dd8cf4802d580a54c20c7f82336507f (patch)
treef83ae75e1ab74f5789b2960f792ab7401170de70
parent986cb3e0beb22465577dae2aca7c148ae11c3d6d (diff)
Add msvc crosstool definiton
This patch add the msvc crosstool definiton to CROSSTOOL file and BUILD file. Two paths are expected to exist: for msvc: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/ for windows sdk: C:/Program Files (x86)/Windows Kits/10/ -- Change-Id: I2b21e566a588459f9fef767c5dc9dab1565d1ae8 Reviewed-on: https://bazel-review.googlesource.com/#/c/3266 MOS_MIGRATED_REVID=119276027
-rw-r--r--tools/cpp/BUILD29
-rw-r--r--tools/cpp/CROSSTOOL146
2 files changed, 175 insertions, 0 deletions
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index cd671e1f12..70454ccc6d 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -37,6 +37,7 @@ filegroup(
":cc-compiler-freebsd",
":cc-compiler-local",
":cc-compiler-x64_windows",
+ ":cc-compiler-x64_windows_msvc",
":empty",
],
)
@@ -125,6 +126,34 @@ cc_toolchain(
supports_param_files = 0,
)
+cc_toolchain(
+ name = "cc-compiler-x64_windows_msvc",
+ all_files = ":every-file-x64_windows",
+ compiler_files = ":compile-x64_windows",
+ cpu = "x64_windows",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+)
+
+filegroup(
+ name = "every-file-x64_windows",
+ srcs = [
+ ":compile-x64_windows",
+ ],
+)
+
+filegroup(
+ name = "compile-x64_windows",
+ srcs = glob([
+ "wrapper/bin/msvc_*",
+ "wrapper/bin/pydir/msvc*",
+ ]),
+)
+
filegroup(
name = "srcs",
srcs = glob(["**"]) + ["//tools/cpp/test:srcs"],
diff --git a/tools/cpp/CROSSTOOL b/tools/cpp/CROSSTOOL
index a668263a19..8dc1b47959 100644
--- a/tools/cpp/CROSSTOOL
+++ b/tools/cpp/CROSSTOOL
@@ -30,6 +30,10 @@ default_toolchain {
cpu: "x64_windows"
toolchain_identifier: "local_windows_msys64"
}
+default_toolchain {
+ cpu: "x64_windows_msvc"
+ toolchain_identifier: "vc_14_0_x64"
+}
toolchain {
abi_version: "armeabi-v7a"
@@ -546,3 +550,145 @@ toolchain {
tool_path { name: "strip" path: "C:/tools/msys64/usr/bin/strip" }
linking_mode_flags { mode: DYNAMIC }
}
+
+toolchain {
+ toolchain_identifier: "vc_14_0_x64"
+ host_system_name: "local"
+ target_system_name: "local"
+
+ abi_version: "local"
+ abi_libc_version: "local"
+ target_cpu: "x64_windows"
+ compiler: "cl"
+ target_libc: "msvcrt140"
+ default_python_version: "python2.7"
+ cxx_builtin_include_directory: "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/INCLUDE"
+ cxx_builtin_include_directory: "C:/Program Files (x86)/Windows Kits/10/include/10.0.10240.0/ucrt"
+ tool_path {
+ name: "ar"
+ path: "wrapper/bin/msvc_link.bat"
+ }
+ tool_path {
+ name: "cpp"
+ path: "wrapper/bin/msvc_cl.bat"
+ }
+ tool_path {
+ name: "gcc"
+ path: "wrapper/bin/msvc_cl.bat"
+ }
+ tool_path {
+ name: "gcov"
+ path: "wrapper/bin/msvc_nop.bat"
+ }
+ tool_path {
+ name: "ld"
+ path: "wrapper/bin/msvc_link.bat"
+ }
+ tool_path {
+ name: "nm"
+ path: "wrapper/bin/msvc_nop.bat"
+ }
+ tool_path {
+ name: "objcopy"
+ path: "wrapper/bin/msvc_nop.bat"
+ }
+ tool_path {
+ name: "objdump"
+ path: "wrapper/bin/msvc_nop.bat"
+ }
+ tool_path {
+ name: "strip"
+ path: "wrapper/bin/msvc_nop.bat"
+ }
+ supports_gold_linker: false
+ supports_thin_archives: false
+ supports_start_end_lib: false
+ supports_interface_shared_objects: false
+ supports_incremental_linker: false
+ supports_normalizing_ar: true
+ needsPic: false
+
+ compiler_flag: "-m64"
+
+ # TODO(pcloudy): Review those flags below, they should be defined by cl.exe
+ compiler_flag: "/DOS_WINDOWS=OS_WINDOWS"
+ compiler_flag: "/DCOMPILER_MSVC"
+
+ # Don't pollute with GDI macros in windows.h.
+ compiler_flag: "/DNOGDI"
+ # Don't define min/max macros in windows.h.
+ compiler_flag: "/DNOMINMAX"
+ compiler_flag: "/DPRAGMA_SUPPORTED"
+ # Platform defines.
+ compiler_flag: "/D_WIN32"
+ compiler_flag: "/DWIN32"
+ compiler_flag: "/D_WIN32_WINNT=0x0502"
+ compiler_flag: "/DWINVER=0x0502"
+ compiler_flag: "/D_MSC_VER=1900"
+ compiler_flag: "/D_WINDOWS"
+ # Turn off warning messages.
+ compiler_flag: "/D_CRT_SECURE_NO_DEPRECATE"
+ compiler_flag: "/D_CRT_SECURE_NO_WARNINGS"
+ compiler_flag: "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS"
+ # Use math constants (M_PI, etc.) from the math library
+ compiler_flag: "/D_USE_MATH_DEFINES"
+ # Don't bloat namespace with incompatible winsock versions.
+ compiler_flag: "/DWIN32_LEAN_AND_MEAN"
+
+ # Useful options to have on for compilation.
+ # Suppress startup banner.
+ compiler_flag: "/nologo"
+ # Treat warnings as errors.
+ compiler_flag: "/WX"
+ # Increase the capacity of object files to 2^32 sections.
+ compiler_flag: "/bigobj"
+ # Allocate 500MB for precomputed headers.
+ compiler_flag: "/Zm500"
+ # Use unsigned char by default.
+ compiler_flag: "/J"
+ # Use function level linking.
+ compiler_flag: "/Gy"
+ # Use string pooling.
+ compiler_flag: "/GF"
+ # Warning level 3 (could possibly go to 4 in the future).
+ compiler_flag: "/W3"
+ # Catch both asynchronous (structured) and synchronous (C++) exceptions.
+ compiler_flag: "/EHsc"
+
+ # Globally disabled warnings.
+ # Don't warn about elements of array being be default initialized.
+ compiler_flag: "/wd4351"
+ # Don't warn about no matching delete found.
+ compiler_flag: "/wd4291"
+ # Don't warn about diamond inheritance patterns.
+ compiler_flag: "/wd4250"
+ # Don't warn about insecure functions (e.g. non _s functions).
+ compiler_flag: "/wd4996"
+
+ linker_flag: "-m64"
+
+ compilation_mode_flags {
+ mode: DBG
+ compiler_flag: "/DDEBUG=1"
+ # This will signal the wrapper that we are doing a debug build, which sets
+ # some internal state of the toolchain wrapper. It is intentionally a "-"
+ # flag to make this very obvious.
+ compiler_flag: "-g"
+ compiler_flag: "/Od"
+ compiler_flag: "-Xcompilation-mode=dbg"
+ }
+
+ compilation_mode_flags {
+ mode: FASTBUILD
+ compiler_flag: "/DNDEBUG"
+ compiler_flag: "/Od"
+ compiler_flag: "-Xcompilation-mode=fastbuild"
+ }
+
+ compilation_mode_flags {
+ mode: OPT
+ compiler_flag: "/DNDEBUG"
+ compiler_flag: "/O2"
+ compiler_flag: "-Xcompilation-mode=opt"
+ }
+}