| Index: build/config/compiler/BUILD.gn
|
| diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
|
| index 29566e6d3f5e2fb8f87f16e0fc56ff1fe337bd19..29dc2d4eecd435725e295dd0554ad61d584636a7 100644
|
| --- a/build/config/compiler/BUILD.gn
|
| +++ b/build/config/compiler/BUILD.gn
|
| @@ -131,6 +131,12 @@ config("compiler") {
|
| configs += [ "//build/config/mac:compiler" ]
|
| }
|
|
|
| + # See the definitions below.
|
| + configs += [
|
| + ":compiler_cpu_abi",
|
| + ":compiler_codegen",
|
| + ]
|
| +
|
| # In general, Windows is totally different, but all the other builds share
|
| # some common GCC configuration.
|
| if (!is_win) {
|
| @@ -213,124 +219,6 @@ config("compiler") {
|
| }
|
| }
|
|
|
| - # CPU architecture. We may or may not be doing a cross compile now, so for
|
| - # simplicity we always explicitly set the architecture.
|
| - if (current_cpu == "x64") {
|
| - cflags += [
|
| - "-m64",
|
| - "-march=x86-64",
|
| - ]
|
| - ldflags += [ "-m64" ]
|
| - } else if (current_cpu == "x86") {
|
| - cflags += [ "-m32" ]
|
| - ldflags += [ "-m32" ]
|
| - if (is_clang) {
|
| - cflags += [
|
| - # Else building libyuv gives clang's register allocator issues,
|
| - # see llvm.org/PR15798 / crbug.com/233709
|
| - "-momit-leaf-frame-pointer",
|
| -
|
| - # Align the stack on 16-byte boundaries, http://crbug.com/418554.
|
| - "-mstack-alignment=16",
|
| - "-mstackrealign",
|
| - ]
|
| - }
|
| - } else if (current_cpu == "arm") {
|
| - if (is_clang && !is_android && !is_nacl) {
|
| - cflags += [
|
| - "-target",
|
| - "arm-linux-gnueabihf",
|
| - ]
|
| - ldflags += [
|
| - "-target",
|
| - "arm-linux-gnueabihf",
|
| - ]
|
| -
|
| - # We need to disable clang's builtin assembler as it can't
|
| - # handle several asm files, crbug.com/124610
|
| - cflags += [ "-no-integrated-as" ]
|
| - }
|
| - if (!is_nacl) {
|
| - cflags += [
|
| - "-march=$arm_arch",
|
| - "-mfloat-abi=$arm_float_abi",
|
| - ]
|
| - if (arm_use_thumb) {
|
| - cflags += [ "-mthumb" ]
|
| - if (is_android && !is_clang) {
|
| - # Clang doesn't support this option.
|
| - cflags += [ "-mthumb-interwork" ]
|
| - }
|
| - }
|
| - }
|
| - if (arm_tune != "") {
|
| - cflags += [ "-mtune=$arm_tune" ]
|
| - }
|
| - if (!is_clang) {
|
| - # Clang doesn't support these flags.
|
| - cflags += [
|
| - # The tree-sra optimization (scalar replacement for
|
| - # aggregates enabling subsequent optimizations) leads to
|
| - # invalid code generation when using the Android NDK's
|
| - # compiler (r5-r7). This can be verified using
|
| - # webkit_unit_tests' WTF.Checked_int8_t test.
|
| - "-fno-tree-sra",
|
| -
|
| - # The following option is disabled to improve binary
|
| - # size and performance in gcc 4.9.
|
| - "-fno-caller-saves",
|
| - ]
|
| - }
|
| - } else if (current_cpu == "mipsel") {
|
| - if (mips_arch_variant == "r6") {
|
| - cflags += [
|
| - "-mips32r6",
|
| - "-Wa,-mips32r6",
|
| - ]
|
| - if (is_android) {
|
| - ldflags += [
|
| - "-mips32r6",
|
| - "-Wl,-melf32ltsmip",
|
| - ]
|
| - }
|
| - } else if (mips_arch_variant == "r2") {
|
| - cflags += [
|
| - "-mips32r2",
|
| - "-Wa,-mips32r2",
|
| - ]
|
| - if (mips_float_abi == "hard" && mips_fpu_mode != "") {
|
| - cflags += [ "-m$mips_fpu_mode" ]
|
| - }
|
| - } else if (mips_arch_variant == "r1") {
|
| - cflags += [
|
| - "-mips32",
|
| - "-Wa,-mips32",
|
| - ]
|
| - }
|
| -
|
| - if (mips_dsp_rev == 1) {
|
| - cflags += [ "-mdsp" ]
|
| - } else if (mips_dsp_rev == 2) {
|
| - cflags += [ "-mdspr2" ]
|
| - }
|
| -
|
| - cflags += [ "-m${mips_float_abi}-float" ]
|
| - } else if (current_cpu == "mips64el") {
|
| - if (mips_arch_variant == "r6") {
|
| - cflags += [
|
| - "-mips64r6",
|
| - "-Wa,-mips64r6",
|
| - ]
|
| - ldflags += [ "-mips64r6" ]
|
| - } else if (mips_arch_variant == "r2") {
|
| - cflags += [
|
| - "-mips64r2",
|
| - "-Wa,-mips64r2",
|
| - ]
|
| - ldflags += [ "-mips64r2" ]
|
| - }
|
| - }
|
| -
|
| defines += [ "_FILE_OFFSET_BITS=64" ]
|
|
|
| if (!is_android) {
|
| @@ -446,6 +334,155 @@ config("compiler") {
|
| }
|
| }
|
|
|
| +# This provides the basic options to select the target CPU and ABI.
|
| +# It is factored out of "compiler" so that special cases can use this
|
| +# without using everything that "compiler" brings in. Options that
|
| +# tweak code generation for a particular CPU do not belong here!
|
| +# See "compiler_codegen", below.
|
| +config("compiler_cpu_abi") {
|
| + cflags = []
|
| + ldflags = []
|
| +
|
| + if (is_posix && !(is_mac || is_ios)) {
|
| + # CPU architecture. We may or may not be doing a cross compile now, so for
|
| + # simplicity we always explicitly set the architecture.
|
| + if (current_cpu == "x64") {
|
| + cflags += [
|
| + "-m64",
|
| + "-march=x86-64",
|
| + ]
|
| + ldflags += [ "-m64" ]
|
| + } else if (current_cpu == "x86") {
|
| + cflags += [ "-m32" ]
|
| + ldflags += [ "-m32" ]
|
| + } else if (current_cpu == "arm") {
|
| + if (is_clang && !is_android && !is_nacl) {
|
| + cflags += [
|
| + "-target",
|
| + "arm-linux-gnueabihf",
|
| + ]
|
| + ldflags += [
|
| + "-target",
|
| + "arm-linux-gnueabihf",
|
| + ]
|
| + }
|
| + if (!is_nacl) {
|
| + cflags += [
|
| + "-march=$arm_arch",
|
| + "-mfloat-abi=$arm_float_abi",
|
| + ]
|
| + if (arm_use_thumb) {
|
| + cflags += [ "-mthumb" ]
|
| + if (is_android && !is_clang) {
|
| + # Clang doesn't support this option.
|
| + cflags += [ "-mthumb-interwork" ]
|
| + }
|
| + }
|
| + }
|
| + if (arm_tune != "") {
|
| + cflags += [ "-mtune=$arm_tune" ]
|
| + }
|
| + } else if (current_cpu == "mipsel") {
|
| + if (mips_arch_variant == "r6") {
|
| + cflags += [
|
| + "-mips32r6",
|
| + "-Wa,-mips32r6",
|
| + ]
|
| + if (is_android) {
|
| + ldflags += [
|
| + "-mips32r6",
|
| + "-Wl,-melf32ltsmip",
|
| + ]
|
| + }
|
| + } else if (mips_arch_variant == "r2") {
|
| + cflags += [
|
| + "-mips32r2",
|
| + "-Wa,-mips32r2",
|
| + ]
|
| + if (mips_float_abi == "hard" && mips_fpu_mode != "") {
|
| + cflags += [ "-m$mips_fpu_mode" ]
|
| + }
|
| + } else if (mips_arch_variant == "r1") {
|
| + cflags += [
|
| + "-mips32",
|
| + "-Wa,-mips32",
|
| + ]
|
| + }
|
| +
|
| + if (mips_dsp_rev == 1) {
|
| + cflags += [ "-mdsp" ]
|
| + } else if (mips_dsp_rev == 2) {
|
| + cflags += [ "-mdspr2" ]
|
| + }
|
| +
|
| + cflags += [ "-m${mips_float_abi}-float" ]
|
| + } else if (current_cpu == "mips64el") {
|
| + if (mips_arch_variant == "r6") {
|
| + cflags += [
|
| + "-mips64r6",
|
| + "-Wa,-mips64r6",
|
| + ]
|
| + ldflags += [ "-mips64r6" ]
|
| + } else if (mips_arch_variant == "r2") {
|
| + cflags += [
|
| + "-mips64r2",
|
| + "-Wa,-mips64r2",
|
| + ]
|
| + ldflags += [ "-mips64r2" ]
|
| + }
|
| + }
|
| + }
|
| +
|
| + asmflags = cflags
|
| +}
|
| +
|
| +# This provides options to tweak code generation that are necessary
|
| +# for particular Chromium code or for working around particular
|
| +# compiler bugs (or the combination of the two).
|
| +config("compiler_codegen") {
|
| + cflags = []
|
| +
|
| + if (is_posix && !is_mac && !is_ios && !is_nacl) {
|
| + if (current_cpu == "x86") {
|
| + if (is_clang) {
|
| + cflags += [
|
| + # Else building libyuv gives clang's register allocator issues,
|
| + # see llvm.org/PR15798 / crbug.com/233709
|
| + "-momit-leaf-frame-pointer",
|
| +
|
| + # Align the stack on 16-byte boundaries, http://crbug.com/418554.
|
| + "-mstack-alignment=16",
|
| + "-mstackrealign",
|
| + ]
|
| + }
|
| + } else if (current_cpu == "arm") {
|
| + if (is_clang) {
|
| + if (!is_android) {
|
| + # We need to disable clang's builtin assembler as it can't
|
| + # handle several asm files, crbug.com/124610
|
| + cflags += [ "-no-integrated-as" ]
|
| + }
|
| + } else {
|
| + # Clang doesn't support these flags.
|
| + cflags += [
|
| + # The tree-sra optimization (scalar replacement for
|
| + # aggregates enabling subsequent optimizations) leads to
|
| + # invalid code generation when using the Android NDK's
|
| + # compiler (r5-r7). This can be verified using
|
| + # webkit_unit_tests' WTF.Checked_int8_t test.
|
| + "-fno-tree-sra",
|
| +
|
| + # The following option is disabled to improve binary
|
| + # size and performance in gcc 4.9.
|
| + "-fno-caller-saves",
|
| + ]
|
| + }
|
| + }
|
| + }
|
| +
|
| + asmflags = cflags
|
| +}
|
| +
|
| config("compiler_arm_fpu") {
|
| if (current_cpu == "arm" && !is_ios && !is_nacl) {
|
| cflags = [ "-mfpu=$arm_fpu" ]
|
|
|