Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Backport][Windows] Pass "/MD" and variants outside the "runtime_libr…
Browse files Browse the repository at this point in the history
…ary" target

This patch is required for the .NET extension bridge to be built.

BUG=XWALK-7336

> Create separate configurations for passing "/MD", "/MT" and their debug
> variants: "dynamic_crt" passes "/MD" and "/MDd", whereas "static_crt"
> passes "/MT" and "/MTd". BUILDCONFIG then depends on "default_crt",
> which has some logic to choose whether to use either dynamic_crt or
> static_crt.
>
> The main reason behind this is to allow users to config -= the
> "default_crt" config: in gyp, it was possible to configure what was
> going to be passed to the compiler via the
> "win_{release,debug}_RuntimeLibrary" variable, which was useful when
> building code that needs to pass "/CLR", as it requires "/MD" and does
> not work with "/MT".
>
> [email protected],[email protected],[email protected]
>
> Review-Url: https://codereview.chromium.org/2379573003
  • Loading branch information
Raphael Kubo da Costa committed Oct 11, 2016
1 parent 64345ff commit ee335c1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
1 change: 1 addition & 0 deletions build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ _native_compiler_configs = [
]
if (is_win) {
_native_compiler_configs += [
"//build/config/win:default_crt",
"//build/config/win:lean_and_mean",
"//build/config/win:nominmax",
"//build/config/win:unicode",
Expand Down
65 changes: 38 additions & 27 deletions build/config/win/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -183,33 +183,6 @@ config("runtime_library") {
# However it is prohibited when using /analyze
defines += [ "_USING_V110_SDK71_" ]
}

if (is_component_build) {
# Component mode: dynamic CRT. Since the library is shared, it requires
# exceptions or will give errors about things not matching, so keep
# exceptions on.
if (is_debug) {
cflags += [ "/MDd" ]
} else {
cflags += [ "/MD" ]
}
} else {
if (current_os != "win") {
# WindowsRT: use the dynamic CRT.
if (is_debug) {
cflags += [ "/MDd" ]
} else {
cflags += [ "/MD" ]
}
} else {
# Desktop Windows: static CRT.
if (is_debug) {
cflags += [ "/MTd" ]
} else {
cflags += [ "/MT" ]
}
}
}
}

# Sets the default Windows build version. This is separated because some
Expand Down Expand Up @@ -278,6 +251,44 @@ config("common_linker_setup") {
}
}

# CRT --------------------------------------------------------------------------

# Configures how the runtime library (CRT) is going to be used.
# See https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx for a reference of
# what each value does.
config("default_crt") {
if (is_component_build) {
# Component mode: dynamic CRT. Since the library is shared, it requires
# exceptions or will give errors about things not matching, so keep
# exceptions on.
configs = [ ":dynamic_crt" ]
} else {
if (current_os != "win") {
# WindowsRT: use the dynamic CRT.
configs = [ ":dynamic_crt" ]
} else {
# Desktop Windows: static CRT.
configs = [ ":static_crt" ]
}
}
}

config("dynamic_crt") {
if (is_debug) {
cflags = [ "/MDd" ]
} else {
cflags = [ "/MD" ]
}
}

config("static_crt") {
if (is_debug) {
cflags = [ "/MTd" ]
} else {
cflags = [ "/MT" ]
}
}

# Subsystem --------------------------------------------------------------------

# This is appended to the subsystem to specify a minimum version.
Expand Down

0 comments on commit ee335c1

Please sign in to comment.