aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2017-04-24 13:37:46 +0200
committerGravatar Vladimir Moskva <vladmos@google.com>2017-04-24 16:52:14 +0200
commitf3fd3a4ad2e7f2878e7d8f71cfb4cb53fc15e04e (patch)
tree4413a424d9801ca1f2195ee48b8a7995371eccdc /tools
parent20df206caf8fdec39f92d2359f1c7e85ce6dae6a (diff)
Clean up more things in MSVC wrapper scripts
1. Moved /nologo flag into feature 2. No need to specify -m64, adding /MACHINVE:X64 as linker flag 3. Still use wrapper script to add /MT or /MD for now, because our users are depending on it: https://github.com/bazelbuild/bazel/issues/2120 We need a plan first before move them into CROSSTOOL Change-Id: If5e4c01a900fcf9e93877e04a893879897bff3a3 PiperOrigin-RevId: 154036870
Diffstat (limited to 'tools')
-rw-r--r--tools/cpp/CROSSTOOL.tpl49
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_cl.py4
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_link.py18
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl3
4 files changed, 45 insertions, 29 deletions
diff --git a/tools/cpp/CROSSTOOL.tpl b/tools/cpp/CROSSTOOL.tpl
index 8bf57e5808..2d394c62f1 100644
--- a/tools/cpp/CROSSTOOL.tpl
+++ b/tools/cpp/CROSSTOOL.tpl
@@ -171,8 +171,6 @@ toolchain {
supports_normalizing_ar: true
needsPic: false
- compiler_flag: "-m64"
- compiler_flag: "/D__inline__=__inline"
# TODO(pcloudy): Review those flags below, they should be defined by cl.exe
compiler_flag: "/DOS_WINDOWS=OS_WINDOWS"
compiler_flag: "/DCOMPILER_MSVC"
@@ -192,8 +190,6 @@ toolchain {
compiler_flag: "/D_USE_MATH_DEFINES"
# Useful options to have on for compilation.
- # Suppress startup banner.
- compiler_flag: "/nologo"
# Increase the capacity of object files to 2^32 sections.
compiler_flag: "/bigobj"
# Allocate 500MB for precomputed headers.
@@ -219,7 +215,33 @@ toolchain {
# Don't warn about insecure functions (e.g. non _s functions).
compiler_flag: "/wd4996"
- linker_flag: "-m64"
+ linker_flag: "/MACHINE:X64"
+
+ linker_flag: "/SUBSYSTEM:CONSOLE"
+
+ # Suppress startup banner.
+ feature {
+ name: "nologo"
+ flag_set {
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-module-compile"
+ action: "c++-module-codegen"
+ action: "c++-header-parsing"
+ action: "c++-header-preprocessing"
+ action: "assemble"
+ action: "preprocess-assemble"
+ action: "c++-link-executable"
+ action: "c++-link-dynamic-library"
+ action: "c++-link-static-library"
+ action: "c++-link-alwayslink-static-library"
+ action: "c++-link-pic-static-library"
+ action: "c++-link-alwayslink-pic-static-library"
+ flag_group {
+ flag: "/nologo"
+ }
+ }
+ }
feature {
name: "msvc_env"
@@ -227,6 +249,7 @@ toolchain {
action: "c-compile"
action: "c++-compile"
action: "c++-module-compile"
+ action: "c++-module-codegen"
action: "c++-header-parsing"
action: "c++-header-preprocessing"
action: "assemble"
@@ -336,6 +359,7 @@ toolchain {
flag: '/Fi%{output_preprocess_file}'
}
}
+ implies: 'nologo'
implies: 'msvc_env'
}
@@ -370,6 +394,7 @@ toolchain {
flag: '/Fi%{output_preprocess_file}'
}
}
+ implies: 'nologo'
implies: 'msvc_env'
}
@@ -379,6 +404,7 @@ toolchain {
tool {
tool_path: 'wrapper/bin/msvc_link.bat'
}
+ implies: 'nologo'
implies: 'strip_debug_symbols'
implies: 'linkstamps'
implies: 'output_execpath_flags'
@@ -394,6 +420,7 @@ toolchain {
tool {
tool_path: 'wrapper/bin/msvc_link.bat'
}
+ implies: 'nologo'
implies: 'strip_debug_symbols'
implies: 'shared_flag'
implies: 'linkstamps'
@@ -411,6 +438,7 @@ toolchain {
tool {
tool_path: 'wrapper/bin/msvc_link.bat'
}
+ implies: 'nologo'
implies: 'input_param_flags'
implies: 'linker_param_file'
implies: 'msvc_env'
@@ -422,6 +450,7 @@ toolchain {
tool {
tool_path: 'wrapper/bin/msvc_link.bat'
}
+ implies: 'nologo'
implies: 'input_param_flags'
implies: 'linker_param_file'
implies: 'msvc_env'
@@ -435,6 +464,7 @@ toolchain {
tool {
tool_path: 'wrapper/bin/msvc_link.bat'
}
+ implies: 'nologo'
implies: 'input_param_flags'
implies: 'linker_param_file'
implies: 'msvc_env'
@@ -446,6 +476,7 @@ toolchain {
tool {
tool_path: 'wrapper/bin/msvc_link.bat'
}
+ implies: 'nologo'
implies: 'input_param_flags'
implies: 'linker_param_file'
implies: 'msvc_env'
@@ -457,6 +488,7 @@ toolchain {
tool {
tool_path: 'wrapper/bin/msvc_link.bat'
}
+ implies: 'nologo'
implies: 'strip_debug_symbols'
implies: 'linker_param_file'
implies: 'msvc_env'
@@ -680,8 +712,11 @@ toolchain {
action: 'c++-compile'
flag_group {
flag: "/Od"
- flag: '/MTd'
flag: "/Z7"
+ # 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.
+ flag: "-g"
}
}
flag_set {
@@ -702,7 +737,6 @@ toolchain {
action: 'c++-compile'
flag_group {
flag: "/Od"
- flag: '/MT'
flag: "/Z7"
}
}
@@ -724,7 +758,6 @@ toolchain {
action: 'c++-compile'
flag_group {
flag: "/O2"
- flag: '/MT'
}
}
}
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_cl.py b/tools/cpp/wrapper/bin/pydir/msvc_cl.py
index 716db2207b..89766a6fb7 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_cl.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_cl.py
@@ -106,13 +106,11 @@ class MsvcCompiler(msvc_tools.WindowsRunner):
ValueError: if target architecture isn't specified
"""
parser = msvc_tools.ArgParser(self, argv, GCCPATTERNS)
- if not parser.target_arch:
- raise ValueError('Must specify target architecture (-m32 or -m64)')
compiler = 'cl'
if parser.is_cuda_compilation:
compiler = 'nvcc'
- return self.RunBinary(compiler, parser.options, parser.target_arch, parser)
+ return self.RunBinary(compiler, parser.options, parser)
def main(argv):
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_link.py b/tools/cpp/wrapper/bin/pydir/msvc_link.py
index 79ce688cf7..79d118d5d0 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_link.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_link.py
@@ -62,7 +62,7 @@ class MsvcLinker(msvc_tools.WindowsRunner):
"""
# For now assume we are building a library.
tool = 'lib'
- default_args = ['/nologo']
+ default_args = []
# Build argument list.
parser = msvc_tools.ArgParser(self, argv, LINKPATTERNS)
@@ -90,19 +90,6 @@ class MsvcLinker(msvc_tools.WindowsRunner):
if os.path.splitext(name)[1] not in ['.a', '.lo']:
tool = 'link'
- if not parser.target_arch:
- raise ValueError('Must specify target architecture (-m32 or -m64)')
-
- # Append explicit machine type.
- if parser.target_arch == 'x64':
- default_args.append('/MACHINE:X64')
- else:
- default_args.append('/MACHINE:X86')
-
- # Args for buildng a console application. These must appear here since
- # blaze will not properly pass them to the linker.
- # /SUBSYSTEM:CONSOLE: Build a console application.
- default_args += ['/SUBSYSTEM:CONSOLE']
# If there is no .o on the command line, then we need to add the
# run-time library for the target. Without this the linker gives a
# LNK4001 error and cannot find an entry point.
@@ -123,8 +110,7 @@ class MsvcLinker(msvc_tools.WindowsRunner):
default_args.insert(0, rtlib %
('d' if parser.compilation_mode == 'dbg' else ''))
- return self.RunBinary(tool, default_args + parser.options,
- parser.target_arch, parser)
+ return self.RunBinary(tool, default_args + parser.options, parser)
def main(argv):
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl b/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl
index 127aa87c06..76a5aa57a5 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl
+++ b/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl
@@ -441,13 +441,12 @@ class WindowsRunner(object):
% (str(abspath), MAX_PATH_ADJUSTED, len(abspath)))
return abspath
- def RunBinary(self, binary, args, build_arch, parser):
+ def RunBinary(self, binary, args, parser):
"""Runs binary on Windows with the passed args.
Args:
binary: The binary to run.
args: The arguments to pass to binary.
- build_arch: Either 'x64' or 'x86', which binary architecture to build for.
parser: An ArgParser that contains parsed arguments.
Returns: