Commit 7a73be6e authored by andybons's avatar andybons Committed by Commit bot

[GN]: BUILD file housecleaning

+ Turn on precompiled headers on Mac.
+ Change the toolchains to use asmflags instead of cflags and cflags_c.
+ Remove a TODO to hardcode the Mac SDK since the location of the SDK is not always guaranteed (on bots, for example).
+ GN: .S or .asm files no longer trigger cflags or cflags_c to be written to the ninja file.

BUG=none

Review URL: https://codereview.chromium.org/1368223002

Cr-Commit-Position: refs/heads/master@{#351202}
parent bc49adcb
...@@ -449,9 +449,7 @@ config("precompiled_headers") { ...@@ -449,9 +449,7 @@ config("precompiled_headers") {
# then delete the precompile.c.obj file, then build again. # then delete the precompile.c.obj file, then build again.
cflags_c = [ "/wd4206" ] cflags_c = [ "/wd4206" ]
} else if (is_mac && !is_official_build && !use_goma) { } else if (is_mac && !is_official_build && !use_goma) {
# TODO(andybons): enable this when GCC PCH support in the binary has been precompiled_header = "build/precompile.h"
# rolled. precompiled_source = "//build/precompile.h"
#precompiled_header = "build/precompile.h"
#precompiled_source = "//build/precompile.h"
} }
} }
...@@ -115,6 +115,10 @@ config("compiler") { ...@@ -115,6 +115,10 @@ config("compiler") {
abi_target, abi_target,
] ]
} }
# Assign any flags set for the C compiler to asmflags so that they are sent
# to the assembler.
asmflags = cflags
} }
# This is included by reference in the //build/config/compiler:runtime_library # This is included by reference in the //build/config/compiler:runtime_library
...@@ -194,6 +198,7 @@ config("runtime_library") { ...@@ -194,6 +198,7 @@ config("runtime_library") {
config("sdk") { config("sdk") {
if (sysroot != "") { if (sysroot != "") {
cflags = [ "--sysroot=" + sysroot ] cflags = [ "--sysroot=" + sysroot ]
asmflags = [ "--sysroot=" + sysroot ]
ldflags = [ "--sysroot=" + sysroot ] ldflags = [ "--sysroot=" + sysroot ]
# Need to get some linker flags out of the sysroot. # Need to get some linker flags out of the sysroot.
...@@ -209,6 +214,7 @@ config("sdk") { ...@@ -209,6 +214,7 @@ config("sdk") {
config("executable_config") { config("executable_config") {
cflags = [ "-fPIE" ] cflags = [ "-fPIE" ]
asmflags = [ "-fPIE" ]
ldflags = [ "-pie" ] ldflags = [ "-pie" ]
} }
......
...@@ -93,6 +93,7 @@ config("default_include_dirs") { ...@@ -93,6 +93,7 @@ config("default_include_dirs") {
# where stuff should go. Put warning related stuff in the "warnings" config. # where stuff should go. Put warning related stuff in the "warnings" config.
config("compiler") { config("compiler") {
asmflags = []
cflags = [] cflags = []
cflags_c = [] cflags_c = []
cflags_cc = [] cflags_cc = []
...@@ -453,11 +454,20 @@ config("compiler") { ...@@ -453,11 +454,20 @@ config("compiler") {
# Pass the same C/C++ flags to the objective C/C++ compiler. # Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c cflags_objc += cflags_c
cflags_objcc += cflags_cc cflags_objcc += cflags_cc
# Assign any flags set for the C compiler to asmflags so that they are sent
# to the assembler. The Windows assembler takes different types of flags
# so only do so for posix platforms.
if (is_posix) {
asmflags += cflags
asmflags += cflags_c
}
} }
config("compiler_arm_fpu") { config("compiler_arm_fpu") {
if (current_cpu == "arm" && !is_ios && !is_nacl) { if (current_cpu == "arm" && !is_ios && !is_nacl) {
cflags = [ "-mfpu=$arm_fpu" ] cflags = [ "-mfpu=$arm_fpu" ]
asmflags = cflags
} }
} }
...@@ -806,6 +816,7 @@ config("no_chromium_code") { ...@@ -806,6 +816,7 @@ config("no_chromium_code") {
"-Wno-deprecated", "-Wno-deprecated",
] ]
} }
cflags += default_warning_flags cflags += default_warning_flags
cflags_cc += default_warning_flags_cc cflags_cc += default_warning_flags_cc
} }
...@@ -1083,6 +1094,7 @@ config("symbols") { ...@@ -1083,6 +1094,7 @@ config("symbols") {
if (use_debug_fission) { if (use_debug_fission) {
cflags += [ "-gsplit-dwarf" ] cflags += [ "-gsplit-dwarf" ]
} }
asmflags = cflags
ldflags = [] ldflags = []
} }
} }
...@@ -1105,6 +1117,7 @@ config("minimal_symbols") { ...@@ -1105,6 +1117,7 @@ config("minimal_symbols") {
if (use_debug_fission) { if (use_debug_fission) {
cflags += [ "-gsplit-dwarf" ] cflags += [ "-gsplit-dwarf" ]
} }
asmflags = cflags
ldflags = [] ldflags = []
} }
} }
...@@ -1113,6 +1126,7 @@ config("minimal_symbols") { ...@@ -1113,6 +1126,7 @@ config("minimal_symbols") {
config("no_symbols") { config("no_symbols") {
if (!is_win) { if (!is_win) {
cflags = [ "-g0" ] cflags = [ "-g0" ]
asmflags = cflags
} }
} }
......
...@@ -12,6 +12,7 @@ config("sdk") { ...@@ -12,6 +12,7 @@ config("sdk") {
"-mmacosx-version-min=$mac_deployment_target", "-mmacosx-version-min=$mac_deployment_target",
] ]
asmflags = common_flags
cflags = common_flags cflags = common_flags
ldflags = common_flags ldflags = common_flags
} }
......
...@@ -34,11 +34,5 @@ find_sdk_lines = ...@@ -34,11 +34,5 @@ find_sdk_lines =
exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines") exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines")
mac_sdk_version = find_sdk_lines[1] mac_sdk_version = find_sdk_lines[1]
if (mac_sdk_path == "") { if (mac_sdk_path == "") {
# TODO(brettw) http://crbug.com/335325 when everybody moves to XCode 5 we
# can remove the --print_sdk_path argument to find_sdk and instead just use
# the following two lines to get the path. Although it looks longer here, it
# saves forking a process in find_sdk.py so will be faster.
#mac_sdk_root = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX"
#mac_sdk_path = mac_sdk_root + mac_sdk_version + ".sdk"
mac_sdk_path = find_sdk_lines[0] mac_sdk_path = find_sdk_lines[0]
} }
...@@ -12,6 +12,14 @@ assert(is_win) ...@@ -12,6 +12,14 @@ assert(is_win)
# is applied to all targets. It is here to separate out the logic that is # is applied to all targets. It is here to separate out the logic that is
# Windows-only. # Windows-only.
config("compiler") { config("compiler") {
asmflags = [
# When /SAFESEH is specified, the linker will only produce an image if it
# can also produce a table of the image's safe exception handlers. This
# table specifies for the operating system which exception handlers are
# valid for the image.
"/SAFESEH",
]
cflags = [ cflags = [
"/Gy", # Enable function-level linking. "/Gy", # Enable function-level linking.
"/GS", # Enable buffer security checking. "/GS", # Enable buffer security checking.
......
...@@ -194,7 +194,7 @@ template("gcc_toolchain") { ...@@ -194,7 +194,7 @@ template("gcc_toolchain") {
tool("asm") { tool("asm") {
# For GCC we can just use the C compiler to compile assembly. # For GCC we can just use the C compiler to compile assembly.
depfile = "{{output}}.d" depfile = "{{output}}.d"
command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
depsformat = "gcc" depsformat = "gcc"
description = "ASM {{output}}" description = "ASM {{output}}"
outputs = [ outputs = [
......
...@@ -50,10 +50,7 @@ template("mac_toolchain") { ...@@ -50,10 +50,7 @@ template("mac_toolchain") {
tool("cc") { tool("cc") {
depfile = "{{output}}.d" depfile = "{{output}}.d"
precompiled_header_type = "gcc"
# TODO(andybons): enable this when GCC PCH support in the binary has been
# rolled.
#precompiled_header_type = "gcc"
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
depsformat = "gcc" depsformat = "gcc"
description = "CC {{output}}" description = "CC {{output}}"
...@@ -64,10 +61,7 @@ template("mac_toolchain") { ...@@ -64,10 +61,7 @@ template("mac_toolchain") {
tool("cxx") { tool("cxx") {
depfile = "{{output}}.d" depfile = "{{output}}.d"
precompiled_header_type = "gcc"
# TODO(andybons): enable this when GCC PCH support in the binary has been
# rolled.
#precompiled_header_type = "gcc"
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
depsformat = "gcc" depsformat = "gcc"
description = "CXX {{output}}" description = "CXX {{output}}"
...@@ -79,7 +73,7 @@ template("mac_toolchain") { ...@@ -79,7 +73,7 @@ template("mac_toolchain") {
tool("asm") { tool("asm") {
# For GCC we can just use the C compiler to compile assembly. # For GCC we can just use the C compiler to compile assembly.
depfile = "{{output}}.d" depfile = "{{output}}.d"
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
depsformat = "gcc" depsformat = "gcc"
description = "ASM {{output}}" description = "ASM {{output}}"
outputs = [ outputs = [
...@@ -90,10 +84,7 @@ template("mac_toolchain") { ...@@ -90,10 +84,7 @@ template("mac_toolchain") {
tool("objc") { tool("objc") {
depfile = "{{output}}.d" depfile = "{{output}}.d"
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}" command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}"
precompiled_header_type = "gcc"
# TODO(andybons): enable this when GCC PCH support in the binary has been
# rolled.
#precompiled_header_type = "gcc"
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}" command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}"
depsformat = "gcc" depsformat = "gcc"
description = "OBJC {{output}}" description = "OBJC {{output}}"
...@@ -105,10 +96,7 @@ template("mac_toolchain") { ...@@ -105,10 +96,7 @@ template("mac_toolchain") {
tool("objcxx") { tool("objcxx") {
depfile = "{{output}}.d" depfile = "{{output}}.d"
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objcc}} -c {{source}} -o {{output}}" command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objcc}} -c {{source}} -o {{output}}"
precompiled_header_type = "gcc"
# TODO(andybons): enable this when GCC PCH support in the binary has been
# rolled.
#precompiled_header_type = "gcc"
depsformat = "gcc" depsformat = "gcc"
description = "OBJCXX {{output}}" description = "OBJCXX {{output}}"
outputs = [ outputs = [
......
...@@ -120,9 +120,7 @@ template("msvc_toolchain") { ...@@ -120,9 +120,7 @@ template("msvc_toolchain") {
} }
tool("asm") { tool("asm") {
# TODO(brettw): "/safeseh" assembler argument is hardcoded here. Extract command = "$python_path gyp-win-tool asm-wrapper $env ml.exe {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}"
# assembler flags to a variable like cflags. crbug.com/418613
command = "$python_path gyp-win-tool asm-wrapper $env ml.exe {{defines}} {{include_dirs}} /safeseh /c /Fo {{output}} {{source}}"
description = "ASM {{output}}" description = "ASM {{output}}"
outputs = [ outputs = [
"{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj", "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj",
......
...@@ -420,16 +420,12 @@ void NinjaBinaryTargetWriter::WriteCompilerVars( ...@@ -420,16 +420,12 @@ void NinjaBinaryTargetWriter::WriteCompilerVars(
WriteOneFlag(SUBSTITUTION_ASMFLAGS, false, Toolchain::TYPE_NONE, WriteOneFlag(SUBSTITUTION_ASMFLAGS, false, Toolchain::TYPE_NONE,
&ConfigValues::asmflags, opts); &ConfigValues::asmflags, opts);
} }
// TODO(andybons): Remove SOURCE_S and SOURCE_ASM checks once asmflags is
// used.
if (used_types.Get(SOURCE_C) || used_types.Get(SOURCE_CPP) || if (used_types.Get(SOURCE_C) || used_types.Get(SOURCE_CPP) ||
used_types.Get(SOURCE_M) || used_types.Get(SOURCE_MM) || used_types.Get(SOURCE_M) || used_types.Get(SOURCE_MM)) {
used_types.Get(SOURCE_S) || used_types.Get(SOURCE_ASM)) {
WriteOneFlag(SUBSTITUTION_CFLAGS, false, Toolchain::TYPE_NONE, WriteOneFlag(SUBSTITUTION_CFLAGS, false, Toolchain::TYPE_NONE,
&ConfigValues::cflags, opts); &ConfigValues::cflags, opts);
} }
if (used_types.Get(SOURCE_C) || used_types.Get(SOURCE_S) || if (used_types.Get(SOURCE_C)) {
used_types.Get(SOURCE_ASM)) {
WriteOneFlag(SUBSTITUTION_CFLAGS_C, has_precompiled_headers, WriteOneFlag(SUBSTITUTION_CFLAGS_C, has_precompiled_headers,
Toolchain::TYPE_CC, &ConfigValues::cflags_c, opts); Toolchain::TYPE_CC, &ConfigValues::cflags_c, opts);
} }
......
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