From 209832333aa90a58a447e4e181c6edf2f6eb70b2 Mon Sep 17 00:00:00 2001 From: andybons Date: Mon, 28 Sep 2015 16:35:17 -0700 Subject: [PATCH] [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-Original-Commit-Position: refs/heads/master@{#351202} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 7a73be6eb4963662a1e9455dcdab0d5130324901 --- config/BUILD.gn | 6 ++---- config/android/BUILD.gn | 6 ++++++ config/compiler/BUILD.gn | 14 ++++++++++++++ config/mac/BUILD.gn | 1 + config/mac/mac_sdk.gni | 6 ------ config/win/BUILD.gn | 8 ++++++++ toolchain/gcc_toolchain.gni | 2 +- toolchain/mac/BUILD.gn | 22 +++++----------------- toolchain/win/BUILD.gn | 4 +--- 9 files changed, 38 insertions(+), 31 deletions(-) diff --git a/config/BUILD.gn b/config/BUILD.gn index f7c52f8ad..c8da54678 100644 --- a/config/BUILD.gn +++ b/config/BUILD.gn @@ -449,9 +449,7 @@ config("precompiled_headers") { # then delete the precompile.c.obj file, then build again. cflags_c = [ "/wd4206" ] } else if (is_mac && !is_official_build && !use_goma) { - # TODO(andybons): enable this when GCC PCH support in the binary has been - # rolled. - #precompiled_header = "build/precompile.h" - #precompiled_source = "//build/precompile.h" + precompiled_header = "build/precompile.h" + precompiled_source = "//build/precompile.h" } } diff --git a/config/android/BUILD.gn b/config/android/BUILD.gn index 0514b43e7..db6b7a8bb 100644 --- a/config/android/BUILD.gn +++ b/config/android/BUILD.gn @@ -115,6 +115,10 @@ config("compiler") { 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 @@ -194,6 +198,7 @@ config("runtime_library") { config("sdk") { if (sysroot != "") { cflags = [ "--sysroot=" + sysroot ] + asmflags = [ "--sysroot=" + sysroot ] ldflags = [ "--sysroot=" + sysroot ] # Need to get some linker flags out of the sysroot. @@ -209,6 +214,7 @@ config("sdk") { config("executable_config") { cflags = [ "-fPIE" ] + asmflags = [ "-fPIE" ] ldflags = [ "-pie" ] } diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index 53ca6cb6e..67505a030 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -93,6 +93,7 @@ config("default_include_dirs") { # where stuff should go. Put warning related stuff in the "warnings" config. config("compiler") { + asmflags = [] cflags = [] cflags_c = [] cflags_cc = [] @@ -453,11 +454,20 @@ config("compiler") { # Pass the same C/C++ flags to the objective C/C++ compiler. cflags_objc += cflags_c 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") { if (current_cpu == "arm" && !is_ios && !is_nacl) { cflags = [ "-mfpu=$arm_fpu" ] + asmflags = cflags } } @@ -806,6 +816,7 @@ config("no_chromium_code") { "-Wno-deprecated", ] } + cflags += default_warning_flags cflags_cc += default_warning_flags_cc } @@ -1083,6 +1094,7 @@ config("symbols") { if (use_debug_fission) { cflags += [ "-gsplit-dwarf" ] } + asmflags = cflags ldflags = [] } } @@ -1105,6 +1117,7 @@ config("minimal_symbols") { if (use_debug_fission) { cflags += [ "-gsplit-dwarf" ] } + asmflags = cflags ldflags = [] } } @@ -1113,6 +1126,7 @@ config("minimal_symbols") { config("no_symbols") { if (!is_win) { cflags = [ "-g0" ] + asmflags = cflags } } diff --git a/config/mac/BUILD.gn b/config/mac/BUILD.gn index 61c85bcc1..7653b9664 100644 --- a/config/mac/BUILD.gn +++ b/config/mac/BUILD.gn @@ -12,6 +12,7 @@ config("sdk") { "-mmacosx-version-min=$mac_deployment_target", ] + asmflags = common_flags cflags = common_flags ldflags = common_flags } diff --git a/config/mac/mac_sdk.gni b/config/mac/mac_sdk.gni index 20008d479..8767aa410 100644 --- a/config/mac/mac_sdk.gni +++ b/config/mac/mac_sdk.gni @@ -34,11 +34,5 @@ find_sdk_lines = exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines") mac_sdk_version = find_sdk_lines[1] 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] } diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index a93ed30da..d1f670e9f 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -12,6 +12,14 @@ assert(is_win) # is applied to all targets. It is here to separate out the logic that is # Windows-only. 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 = [ "/Gy", # Enable function-level linking. "/GS", # Enable buffer security checking. diff --git a/toolchain/gcc_toolchain.gni b/toolchain/gcc_toolchain.gni index 74dbf0735..3871b3fa8 100644 --- a/toolchain/gcc_toolchain.gni +++ b/toolchain/gcc_toolchain.gni @@ -194,7 +194,7 @@ template("gcc_toolchain") { tool("asm") { # For GCC we can just use the C compiler to compile assembly. 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" description = "ASM {{output}}" outputs = [ diff --git a/toolchain/mac/BUILD.gn b/toolchain/mac/BUILD.gn index dd3ff6107..b0c233a19 100644 --- a/toolchain/mac/BUILD.gn +++ b/toolchain/mac/BUILD.gn @@ -50,10 +50,7 @@ template("mac_toolchain") { tool("cc") { depfile = "{{output}}.d" - - # TODO(andybons): enable this when GCC PCH support in the binary has been - # rolled. - #precompiled_header_type = "gcc" + precompiled_header_type = "gcc" command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" depsformat = "gcc" description = "CC {{output}}" @@ -64,10 +61,7 @@ template("mac_toolchain") { tool("cxx") { depfile = "{{output}}.d" - - # TODO(andybons): enable this when GCC PCH support in the binary has been - # rolled. - #precompiled_header_type = "gcc" + precompiled_header_type = "gcc" command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" depsformat = "gcc" description = "CXX {{output}}" @@ -79,7 +73,7 @@ template("mac_toolchain") { tool("asm") { # For GCC we can just use the C compiler to compile assembly. 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" description = "ASM {{output}}" outputs = [ @@ -90,10 +84,7 @@ template("mac_toolchain") { tool("objc") { depfile = "{{output}}.d" command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}" - - # TODO(andybons): enable this when GCC PCH support in the binary has been - # rolled. - #precompiled_header_type = "gcc" + precompiled_header_type = "gcc" command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}" depsformat = "gcc" description = "OBJC {{output}}" @@ -105,10 +96,7 @@ template("mac_toolchain") { tool("objcxx") { depfile = "{{output}}.d" command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objcc}} -c {{source}} -o {{output}}" - - # TODO(andybons): enable this when GCC PCH support in the binary has been - # rolled. - #precompiled_header_type = "gcc" + precompiled_header_type = "gcc" depsformat = "gcc" description = "OBJCXX {{output}}" outputs = [ diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index a0542678e..7a0ecbb4a 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -120,9 +120,7 @@ template("msvc_toolchain") { } tool("asm") { - # TODO(brettw): "/safeseh" assembler argument is hardcoded here. Extract - # 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}}" + command = "$python_path gyp-win-tool asm-wrapper $env ml.exe {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" description = "ASM {{output}}" outputs = [ "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj",