aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-06-30 14:19:41 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-07-01 07:08:02 +0000
commit6b6ff76945c80fb8b11b71d402b5146c85b86859 (patch)
tree69c8f5d23c42973df8d3299c4c16f64a6c71b29d /tools
parent425ba588a696db553eb2f025a03eed591e378e05 (diff)
Adding features to MSVC CROSSTOOL
This stops Bazel from passing some of the gcc options to wrapper script. Options we get rid of: -c -o -MD -MF -frandom-seed -isystem -iquote -I -- Change-Id: I416b393c6875a2033d5382a644471c416cd5e8d1 Reviewed-on: https://bazel-review.googlesource.com/#/c/3930 MOS_MIGRATED_REVID=126299789
Diffstat (limited to 'tools')
-rw-r--r--tools/cpp/CROSSTOOL115
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_cl.py10
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_tools.py30
3 files changed, 121 insertions, 34 deletions
diff --git a/tools/cpp/CROSSTOOL b/tools/cpp/CROSSTOOL
index 5a23b587ba..75623525ef 100644
--- a/tools/cpp/CROSSTOOL
+++ b/tools/cpp/CROSSTOOL
@@ -662,6 +662,121 @@ toolchain {
linker_flag: "-m64"
+ feature {
+ name: 'include_paths'
+ flag_set {
+ action: 'preprocess-assemble'
+ action: 'c-compile'
+ action: 'c++-compile'
+ action: 'c++-header-parsing'
+ action: 'c++-header-preprocessing'
+ action: 'c++-module-compile'
+ flag_group {
+ flag: '/I%{quote_include_paths}'
+ }
+ flag_group {
+ flag: '/I%{include_paths}'
+ }
+ flag_group {
+ flag: '/I%{system_include_paths}'
+ }
+ }
+ }
+
+ feature {
+ name: 'dependency_file'
+ flag_set {
+ action: 'assemble'
+ action: 'preprocess-assemble'
+ action: 'c-compile'
+ action: 'c++-compile'
+ action: 'c++-module-compile'
+ action: 'c++-header-preprocessing'
+ action: 'c++-header-parsing'
+ expand_if_all_available: 'dependency_file'
+ flag_group {
+ flag: '/DEPENDENCY_FILE'
+ flag: '%{dependency_file}'
+ }
+ }
+ }
+
+ # Stop passing -frandom-seed option
+ feature {
+ name: 'random_seed'
+ }
+
+ # This feature is just for enabling flag_set in action_config for -c and -o options during the transitional period
+ feature {
+ name: 'compile_action_flags_in_flag_set'
+ }
+
+ action_config {
+ config_name: 'c-compile'
+ action_name: 'c-compile'
+ tool {
+ tool_path: 'wrapper/bin/msvc_cl.bat'
+ }
+ flag_set {
+ flag_group {
+ flag: '/c'
+ flag: '%{source_file}'
+ }
+ }
+ flag_set {
+ expand_if_all_available: 'output_object_file'
+ flag_group {
+ flag: '/Fo%{output_object_file}'
+ }
+ }
+ flag_set {
+ expand_if_all_available: 'output_assembly_file'
+ flag_group {
+ flag: '/Fa%{output_assembly_file}'
+ }
+ }
+ flag_set {
+ expand_if_all_available: 'output_preprocess_file'
+ flag_group {
+ flag: '/P'
+ flag: '/Fi%{output_preprocess_file}'
+ }
+ }
+ }
+
+ action_config {
+ config_name: 'c++-compile'
+ action_name: 'c++-compile'
+ tool {
+ tool_path: 'wrapper/bin/msvc_cl.bat'
+ }
+ flag_set {
+ flag_group {
+ flag: '/c'
+ flag: '%{source_file}'
+ }
+ }
+ flag_set {
+ expand_if_all_available: 'output_object_file'
+ flag_group {
+ flag: '/Fo%{output_object_file}'
+ }
+ }
+ flag_set {
+ expand_if_all_available: 'output_assembly_file'
+ flag_group {
+ flag: '/Fa%{output_assembly_file}'
+ }
+ }
+ flag_set {
+ expand_if_all_available: 'output_preprocess_file'
+ flag_group {
+ flag: '/P'
+ flag: '/Fi%{output_preprocess_file}'
+ }
+ }
+ }
+
compilation_mode_flags {
mode: DBG
compiler_flag: "/DDEBUG=1"
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_cl.py b/tools/cpp/wrapper/bin/pydir/msvc_cl.py
index b8d4c8a7fd..7983099311 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_cl.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_cl.py
@@ -26,11 +26,9 @@ GCCPATTERNS = [
('-Xcompilation-mode=(dbg|fastbuild|opt)', ['$COMPILATION_MODE']),
('-msse', ['/arch:SSE']),
('-msse2', ['/arch:SSE2']),
- ('-c', ['/c']),
('-D(.+)', ['/D$0']),
('-U(.+)', ['/U$0']),
('-E', ['/E']),
- (('-o', '(.+)'), ['$COMPILE_OUTPUT0']),
('-O0', ['/Od']),
('-Os', ['/O1']),
('-O2', ['/O2']),
@@ -38,18 +36,13 @@ GCCPATTERNS = [
('-g', ['/MTd']),
('-fexceptions', ['/U_HAS_EXCEPTIONS', '/D_HAS_EXCEPTIONS=1', '/EHsc']),
('-fomit-frame-pointer', ['/Oy']),
- ('-frandom-seed(.+)', []),
('-fno-rtti', ['/GR-']),
('-frtti', ['/GR']),
('-fPIC', []),
# This is unneeded for Windows.
- (('-isystem', '(.*)'), ['/I$PATH0']),
- (('-iquote', '(.*)'), ['/I$PATH0']),
- ('-I(.+)', ['/I$PATH0']),
(('-include', '(.+)'), ['/FI$PATH0']),
- ('-MD', []),
- (('-MF', '(.+)'), ['$GENERATE_DEPS0']),
+ (('/DEPENDENCY_FILE', '(.+)'), ['$GENERATE_DEPS0']),
('-w', ['/w']),
('-Wall', ['/Wall']),
('-Wsign-compare', ['/we4018']),
@@ -68,7 +61,6 @@ GCCPATTERNS = [
('-Wno-string-plus-int', []),
('-Wl,S', []), # Stripping is unnecessary since msvc uses pdb files.
('-Wl,-rpath(.+)', []),
- (('-x', r'c\+\+-header'), ['$CREATE_PRECOMPILED_HEADER']),
('-B(.+)', []),
('-static', []),
('-shared', []),
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_tools.py b/tools/cpp/wrapper/bin/pydir/msvc_tools.py
index 9d3162b0da..f84efc33de 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_tools.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_tools.py
@@ -19,7 +19,6 @@ import ntpath
import os
import re
import subprocess
-import sys
MAX_PATH = 260 # The maximum number of characters in a Windows path.
MAX_OPTION_LENGTH = 10 # The maximum length of a compiler/linker option.
@@ -123,10 +122,14 @@ class ArgParser(object):
matched = []
unmatched = []
files = []
- is_pch = False
while i < len(argv):
num_matched, action, groups = self._MatchOneArg(argv[i:])
arg = argv[i]
+ if arg.startswith('/Fo') or arg.startswith('/Fa') or arg.startswith(
+ '/Fi'):
+ self.output_file = arg[3:]
+ self.options.append(
+ '/Fd%s.pdb' % self.NormPath(os.path.splitext(self.output_file)[0]))
if num_matched == 0:
# Strip out any .a's that have 0 size, they are header or intermediate
# dependency libraries and don't contain any code. 0-length files are
@@ -155,13 +158,6 @@ class ArgParser(object):
matched += argv[i:i + num_matched]
# Handle special options.
for entry in action:
- if entry == '$CREATE_PRECOMPILED_HEADER':
- # The PCH flag comes _first_ on blaze-generated command-lines, so all
- # we can do is set a flag here since we have not yet parsed any other
- # options.
- is_pch = True
- continue
-
if entry == '$TARGET_ARCH':
if arg == '-m32':
self.target_arch = 'x86'
@@ -205,22 +201,6 @@ class ArgParser(object):
exit(-1)
continue
- # Depending on whether we are creating precompiled headers cl.exe
- # needs different options for specifying the output file.
- if entry == ('$COMPILE_OUTPUT%d' % g):
- if is_pch:
- # Just touch the PCH file so that blaze is happy.
- with open(value, 'a'):
- os.utime(value, None)
- # Exit since we don't want to actually try to process a PCH.
- sys.exit(0)
- else:
- self.output_file = value
- self.options.append('/Fo%s' % self.NormPath(value))
- self.options.append('/Fd%s.pdb' %
- self.NormPath(os.path.splitext(value)[0]))
- continue
-
if entry == ('$GENERATE_DEPS%d' % g):
self.options.append('/showIncludes')
self.deps_file = value