diff options
author | agrieve <agrieve@chromium.org> | 2015-08-06 16:18:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-06 23:19:30 +0000 |
commit | 91d9b7ee4e51168ef413265e33b8fe25253a1758 (patch) | |
tree | ae879d43044b60b83eee7cdee682ad4812522e3d | |
parent | 7a9c8c3a97d66f19f3493319ae5594982333868a (diff) | |
download | chromium_src-91d9b7ee4e51168ef413265e33b8fe25253a1758.zip chromium_src-91d9b7ee4e51168ef413265e33b8fe25253a1758.tar.gz chromium_src-91d9b7ee4e51168ef413265e33b8fe25253a1758.tar.bz2 |
GN (Android): Make is_clang work for (at least for arm32)
There seem to be more compiler flags to tweak for other target
architectures, but with this I could at least build & run chrome_apk
with is_clang=true
BUG=402625
Review URL: https://codereview.chromium.org/1258923012
Cr-Commit-Position: refs/heads/master@{#342227}
-rw-r--r-- | build/config/BUILDCONFIG.gn | 6 | ||||
-rw-r--r-- | build/config/compiler/BUILD.gn | 55 | ||||
-rw-r--r-- | build/toolchain/android/BUILD.gn | 46 |
3 files changed, 83 insertions, 24 deletions
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index fc5b392..337aaf5 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -574,7 +574,11 @@ if (is_win) { } else { assert(false, "Unknown host for android cross compile") } - set_default_toolchain("//build/toolchain/android:$current_cpu") + if (is_clang) { + set_default_toolchain("//build/toolchain/android:clang_$current_cpu") + } else { + set_default_toolchain("//build/toolchain/android:$current_cpu") + } } else if (is_linux) { if (is_clang) { host_toolchain = "//build/toolchain/linux:clang_$host_cpu" diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index f6cdd06..ffd3088 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -177,11 +177,14 @@ config("compiler") { # Stack protection. if (is_mac) { cflags += [ "-fstack-protector-all" ] - } else if (is_linux) { - cflags += [ - "-fstack-protector", - "--param=ssp-buffer-size=4", - ] + } else if (is_posix && !is_chromeos && !is_nacl) { + # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it. + cflags += [ "--param=ssp-buffer-size=4" ] + if (is_android && (current_cpu == "arm64" || current_cpu == "x86")) { + cflags += [ "-fno-stack-protector" ] + } else { + cflags += [ "-fstack-protector" ] + } } # Linker warnings. @@ -528,7 +531,15 @@ config("compiler") { "-funwind-tables", "-fno-short-enums", ] - if (!is_clang) { + if (is_clang) { + rebased_android_toolchain_root = + rebase_path(android_toolchain_root, root_build_dir) + cflags += [ + # TODO(hans) Enable integrated-as (crbug.com/124610). + "-no-integrated-as", + "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets picked up. + ] + } else { # Clang doesn't support these flags. cflags += [ "-finline-limit=64" ] } @@ -551,8 +562,7 @@ config("compiler") { ldflags += [ "-fuse-ld=gold" ] if (is_clang) { # Let clang find the ld.gold in the NDK. - ldflags += [ "--gcc-toolchain=" + - rebase_path(android_toolchain_root, root_build_dir) ] + ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ] } } @@ -578,11 +588,23 @@ config("compiler") { if (is_clang) { if (current_cpu == "arm") { - cflags += [ "-target arm-linux-androideabi" ] - ldflags += [ "-target arm-linux-androideabi" ] + cflags += [ + "-target", + "arm-linux-androideabi", + ] + ldflags += [ + "-target", + "arm-linux-androideabi", + ] } else if (current_cpu == "x86") { - cflags += [ "-target i686-linux-androideabi" ] - ldflags += [ "-target i686-linux-androideabi" ] + cflags += [ + "-target", + "i686-linux-androideabi", + ] + ldflags += [ + "-target", + "i686-linux-androideabi", + ] } } } @@ -853,10 +875,13 @@ if (is_win) { default_warning_flags_cc += [ # See comment for -Wno-c++11-narrowing. "-Wno-narrowing", - - # TODO(thakis): Remove, http://crbug.com/263960 - "-Wno-literal-suffix", ] + if (!is_clang) { + default_warning_flags_cc += [ + # TODO(thakis): Remove, http://crbug.com/263960 + "-Wno-literal-suffix", + ] + } } # Suppress warnings about ABI changes on ARM (Clang doesn't give this diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn index 087f04b..867fa48 100644 --- a/build/toolchain/android/BUILD.gn +++ b/build/toolchain/android/BUILD.gn @@ -45,8 +45,21 @@ template("android_gcc_toolchain") { compiler_prefix = "" } - cc = compiler_prefix + tool_prefix + "gcc" - cxx = compiler_prefix + tool_prefix + "g++" + is_clang = invoker.is_clang + if (is_clang) { + if (use_clang_type_profiler) { + prefix = rebase_path("//third_party/llvm-allocated-type/Linux_x64/bin", + root_build_dir) + } else { + prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", + root_build_dir) + } + cc = "${compiler_prefix}$prefix/clang" + cxx = "${compiler_prefix}$prefix/clang++" + } else { + cc = "${compiler_prefix}${tool_prefix}gcc" + cxx = "${compiler_prefix}${tool_prefix}g++" + } ar = tool_prefix + "ar" ld = cxx readelf = compiler_prefix + tool_prefix + "readelf" @@ -80,7 +93,24 @@ template("android_gcc_toolchain") { } } -android_gcc_toolchain("x86") { +template("android_gcc_toolchains_helper") { + android_gcc_toolchain(target_name) { + android_ndk_sysroot = invoker.android_ndk_sysroot + android_ndk_lib_dir = invoker.android_ndk_lib_dir + tool_prefix = invoker.tool_prefix + toolchain_cpu = invoker.toolchain_cpu + } + + android_gcc_toolchain("clang_$target_name") { + android_ndk_sysroot = invoker.android_ndk_sysroot + android_ndk_lib_dir = invoker.android_ndk_lib_dir + tool_prefix = invoker.tool_prefix + toolchain_cpu = invoker.toolchain_cpu + is_clang = true + } +} + +android_gcc_toolchains_helper("x86") { android_ndk_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" android_ndk_lib_dir = "usr/lib" @@ -88,7 +118,7 @@ android_gcc_toolchain("x86") { toolchain_cpu = "x86" } -android_gcc_toolchain("arm") { +android_gcc_toolchains_helper("arm") { android_ndk_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" android_ndk_lib_dir = "usr/lib" @@ -96,7 +126,7 @@ android_gcc_toolchain("arm") { toolchain_cpu = "arm" } -android_gcc_toolchain("mipsel") { +android_gcc_toolchains_helper("mipsel") { android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" android_ndk_lib_dir = "usr/lib" @@ -104,7 +134,7 @@ android_gcc_toolchain("mipsel") { toolchain_cpu = "mipsel" } -android_gcc_toolchain("x64") { +android_gcc_toolchains_helper("x64") { android_ndk_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" android_ndk_lib_dir = "usr/lib64" @@ -112,7 +142,7 @@ android_gcc_toolchain("x64") { toolchain_cpu = "x86_64" } -android_gcc_toolchain("arm64") { +android_gcc_toolchains_helper("arm64") { android_ndk_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" android_ndk_lib_dir = "usr/lib" @@ -120,7 +150,7 @@ android_gcc_toolchain("arm64") { toolchain_cpu = "aarch64" } -android_gcc_toolchain("mips64el") { +android_gcc_toolchains_helper("mips64el") { android_ndk_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" android_ndk_lib_dir = "usr/lib64" |