Commit d4061911 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

win: Reorganize some build flags.

- Move global win-only flags from //build/config/compiler to
  //build/config/win:compiler which the former already references if is_win

- Move /FC from the toolchain to //build/config/win:compiler too: The
  toolchain isn't where random compiler flags should be added.

- This allows moving msvc_use_absolute_paths from a gni file to a gn file,
  so do that as well.

No intended behavior change.

Bug: none
Change-Id: I1b35a4242649105e005b94df911849ebf44d7c5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1541636
Commit-Queue: Nico Weber <thakis@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarHans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644799}
parent ac3a0c7f
...@@ -276,14 +276,6 @@ config("compiler") { ...@@ -276,14 +276,6 @@ config("compiler") {
ldflags += [ "-Wl,--fatal-warnings" ] ldflags += [ "-Wl,--fatal-warnings" ]
} }
} else { } else {
cflags += [
# Assume UTF-8 by default to avoid code page dependencies.
"/utf-8",
]
if (is_clang) {
# Don't look for includes in %INCLUDE%.
cflags += [ "/X" ]
}
} }
if (is_clang && is_debug) { if (is_clang && is_debug) {
...@@ -493,13 +485,6 @@ config("compiler") { ...@@ -493,13 +485,6 @@ config("compiler") {
] ]
} }
# Print absolute paths in diagnostics. There is no precedent for doing this
# on Linux/Mac (GCC doesn't support it), but MSVC does this with /FC and
# Windows developers rely on it (crbug.com/636109) so only do this on Windows.
if (msvc_use_absolute_paths && is_clang && is_win) {
cflags += [ "-fdiagnostics-absolute-paths" ]
}
# C11/C++11 compiler flags setup. # C11/C++11 compiler flags setup.
# --------------------------- # ---------------------------
if (is_linux || is_android || (is_nacl && is_clang) || current_os == "aix") { if (is_linux || is_android || (is_nacl && is_clang) || current_os == "aix") {
......
...@@ -45,6 +45,12 @@ declare_args() { ...@@ -45,6 +45,12 @@ declare_args() {
# and with this switch, clang emits it like this: # and with this switch, clang emits it like this:
# foo/bar.cc:12:34: error: something went wrong # foo/bar.cc:12:34: error: something went wrong
use_clang_diagnostics_format = false use_clang_diagnostics_format = false
# Use absolute file paths in the compiler diagnostics and (for non-clang)
# __FILE__ macro if needed. Note that enabling this makes your build
# dependent your checkout's path, which means you won't get to use goma's
# global cache, and without clang your builds won't be deterministic.
msvc_use_absolute_paths = false
} }
# This is included by reference in the //build/config/compiler config that # This is included by reference in the //build/config/compiler config that
...@@ -66,6 +72,7 @@ config("compiler") { ...@@ -66,6 +72,7 @@ config("compiler") {
"/Gy", # Enable function-level linking. "/Gy", # Enable function-level linking.
"/FS", # Preserve previous PDB behavior. "/FS", # Preserve previous PDB behavior.
"/bigobj", # Some of our files are bigger than the regular limits. "/bigobj", # Some of our files are bigger than the regular limits.
"/utf-8", # Assume UTF-8 by default to avoid code page dependencies.
] ]
# Force C/C++ mode for the given GN detected file type. This is necessary # Force C/C++ mode for the given GN detected file type. This is necessary
...@@ -79,7 +86,28 @@ config("compiler") { ...@@ -79,7 +86,28 @@ config("compiler") {
"/Zc:sizedDealloc-", "/Zc:sizedDealloc-",
] ]
if (msvc_use_absolute_paths) {
# Pass /FC flag to the compiler if needed.
cflags += "/FC "
# Print absolute paths in diagnostics. There is no precedent for doing this
# on Linux/Mac (GCC doesn't support it), but MSVC does this with /FC and
# Windows developers rely on it (crbug.com/636109) so only do this on
# Windows.
# TODO(thakis): This comment no longer really make sense after
# https://chromium-review.googlesource.com/c/chromium/src/+/558871/
# See if we can remove msvc_use_absolute_paths. See also discussion in
# https://reviews.llvm.org/D23816
if (is_clang) {
cflags += [ "-fdiagnostics-absolute-paths" ]
}
}
if (is_clang) { if (is_clang) {
# Don't look for includes in %INCLUDE%.
cflags += [ "/X" ]
# Tell clang which version of MSVC to emulate.
cflags += [ "-fmsc-version=1911" ] cflags += [ "-fmsc-version=1911" ]
if (is_component_build) { if (is_component_build) {
......
...@@ -24,10 +24,6 @@ declare_args() { ...@@ -24,10 +24,6 @@ declare_args() {
# Used for binary size analysis. # Used for binary size analysis.
generate_linker_map = is_android && is_official_build generate_linker_map = is_android && is_official_build
# Use absolute file paths in the compiler diagnostics and __FILE__ macro
# if needed.
msvc_use_absolute_paths = false
} }
if (generate_linker_map) { if (generate_linker_map) {
......
...@@ -165,13 +165,6 @@ template("msvc_toolchain") { ...@@ -165,13 +165,6 @@ template("msvc_toolchain") {
sys_lib_flags = "" sys_lib_flags = ""
} }
clflags = ""
# Pass /FC flag to the compiler if needed.
if (msvc_use_absolute_paths) {
clflags += "/FC "
}
tool("cc") { tool("cc") {
precompiled_header_type = "msvc" precompiled_header_type = "msvc"
pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
...@@ -185,7 +178,7 @@ template("msvc_toolchain") { ...@@ -185,7 +178,7 @@ template("msvc_toolchain") {
"$object_subdir/{{source_name_part}}.obj", "$object_subdir/{{source_name_part}}.obj",
] ]
command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" command = "$env_wrapper$cl /nologo /showIncludes $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
} }
tool("cxx") { tool("cxx") {
...@@ -201,7 +194,7 @@ template("msvc_toolchain") { ...@@ -201,7 +194,7 @@ template("msvc_toolchain") {
"$object_subdir/{{source_name_part}}.obj", "$object_subdir/{{source_name_part}}.obj",
] ]
command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" command = "$env_wrapper$cl /nologo /showIncludes $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
} }
tool("rc") { tool("rc") {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment