Windows, CROSSTOOL: add subsystem flag feature  in the
BUILD file. They must use "-" instead of "/"
otherwise Bazel believes the linkopts entry
declares a (invalid) label.
@@ -210,8 +210,6 @@ toolchain {
linker_flag: "/MACHINE:X64"
- linker_flag: "/SUBSYSTEM:CONSOLE"
-
feature {
name: "no_legacy_features"
}
@@ -432,6 +430,7 @@ toolchain {
implies: 'output_execpath_flags'
implies: 'input_param_flags'
implies: 'legacy_link_flags'
+ implies: 'linker_subsystem_flag'
implies: 'linker_param_file'
implies: 'msvc_env'
implies: 'use_linker'
@@ -449,6 +448,7 @@ toolchain {
implies: 'output_execpath_flags'
implies: 'input_param_flags'
implies: 'legacy_link_flags'
+ implies: 'linker_subsystem_flag'
implies: 'linker_param_file'
implies: 'msvc_env'
implies: 'use_linker'
@@ -687,6 +687,27 @@ toolchain {
}
}
+ # Since this feature is declared earlier in the CROSSTOOL than
+ # "legacy_link_flags", this feature will be applied prior to it anwyhere they
+ # are both implied. And since "legacy_link_flags" contains the linkopts from
+ # the build rule, this allows the user to override the /SUBSYSTEM in the BUILD
+ # file.
+ feature {
+ name: 'linker_subsystem_flag'
+ flag_set {
+ action: 'c++-link-executable'
+ action: 'c++-link-dynamic-library'
+ flag_group {
+ flag: '/SUBSYSTEM:CONSOLE'
+ }
+ }
+ }
+
+ # The "legacy_link_flags" may contain user-defined linkopts (from build rules)
+ # so it should be defined after features that declare user-overridable flags.
+ # For example the "linker_subsystem_flag" defines a default "/SUBSYSTEM" flag
+ # but we want to let the user override it, therefore "link_flag_subsystem" is
+ # defined earlier in the CROSSTOOL file than "legacy_link_flags".
feature {
name: 'legacy_link_flags'
flag_set {
