summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw <brettw@chromium.org>2015-09-27 19:32:35 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-28 02:33:25 +0000
commita43e85a1b6cfa9833e4ab5b8d286989f9204523d (patch)
tree199adfbd47606217704e0f6fc0745251321c7e8a
parent172cd932bdf5bb1cc21a7b5bcaa164d33365075c (diff)
downloadchromium_src-a43e85a1b6cfa9833e4ab5b8d286989f9204523d.zip
chromium_src-a43e85a1b6cfa9833e4ab5b8d286989f9204523d.tar.gz
chromium_src-a43e85a1b6cfa9833e4ab5b8d286989f9204523d.tar.bz2
Separate out compiler and runtime configs on Windows and Android GN.
This should be a NOP from a build setup perspective, but aims to make the large common shared build configuration files easier to understand. Review URL: https://codereview.chromium.org/1368263002 Cr-Commit-Position: refs/heads/master@{#351015}
-rw-r--r--build/config/android/BUILD.gn126
-rw-r--r--build/config/android/config.gni5
-rw-r--r--build/config/compiler/BUILD.gn193
-rw-r--r--build/config/win/BUILD.gn106
4 files changed, 226 insertions, 204 deletions
diff --git a/build/config/android/BUILD.gn b/build/config/android/BUILD.gn
index 6f9258f..0514b43 100644
--- a/build/config/android/BUILD.gn
+++ b/build/config/android/BUILD.gn
@@ -8,32 +8,6 @@ import("//build/config/sysroot.gni")
assert(is_android)
-config("sdk") {
- if (sysroot != "") {
- cflags = [ "--sysroot=" + sysroot ]
- ldflags = [ "--sysroot=" + sysroot ]
-
- # Need to get some linker flags out of the sysroot.
- sysroot_ld_path = rebase_path("//build/config/linux/sysroot_ld_path.py")
- ldflags += [ exec_script(sysroot_ld_path,
- [
- rebase_path("//build/linux/sysroot_ld_path.sh"),
- sysroot,
- ],
- "value") ]
- }
-}
-
-config("executable_config") {
- cflags = [ "-fPIE" ]
- ldflags = [ "-pie" ]
-}
-
-config("hide_native_jni_exports") {
- ldflags = [ "-Wl,--version-script=" +
- rebase_path("//build/android/android_no_jni_exports.lst") ]
-}
-
# This is included by reference in the //build/config/compiler config that
# is applied to all targets. It is here to separate out the logic that is
# Android-only.
@@ -142,3 +116,103 @@ config("compiler") {
]
}
}
+
+# This is included by reference in the //build/config/compiler:runtime_library
+# config that is applied to all targets. It is here to separate out the logic
+# that is Android-only. Please see that target for advice on what should go in
+# :runtime_library vs. :compiler.
+config("runtime_library") {
+ # NOTE: The libc++ header include paths below are specified in cflags
+ # rather than include_dirs because they need to come after include_dirs.
+ # Think of them like system headers, but don't use '-isystem' because the
+ # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit
+ # strange errors. The include ordering here is important; change with
+ # caution.
+ cflags = [
+ "-isystem" +
+ rebase_path("$android_libcpp_root/libcxx/include", root_build_dir),
+ "-isystem" + rebase_path(
+ "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/include",
+ root_build_dir),
+ "-isystem" +
+ rebase_path("$android_ndk_root/sources/android/support/include",
+ root_build_dir),
+ ]
+
+ defines = [ "__GNU_SOURCE=1" ] # Necessary for clone().
+ ldflags = [ "-nostdlib" ]
+ lib_dirs = [ "$android_libcpp_root/libs/$android_app_abi" ]
+ libs = [
+ "c",
+ "dl",
+ "m",
+ ]
+
+ # The libc++ runtime library.
+ if (is_component_build) {
+ libs += [ "c++_shared" ]
+ } else {
+ libs += [ "c++_static" ]
+ }
+
+ if (is_clang) {
+ # Work around incompatibilities between bionic and clang headers.
+ defines += [
+ "__compiler_offsetof=__builtin_offsetof",
+ "nan=__builtin_nan",
+ ]
+ }
+
+ # TODO(jdduke) Re-enable on mips after resolving linking
+ # issues with libc++ (crbug.com/456380).
+ if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+ ldflags += [ "-Wl,--warn-shared-textrel" ]
+ }
+
+ if (current_cpu == "mipsel") {
+ libs += [
+ # ld linker is used for mips Android, and ld does not accept library
+ # absolute path prefixed by "-l"; Since libgcc does not exist in mips
+ # sysroot the proper library will be linked.
+ # TODO(gordanac): Remove once gold linker is used for mips Android.
+ "gcc",
+ ]
+ } else {
+ libs += [
+ # Manually link the libgcc.a that the cross compiler uses. This is
+ # absolute because the linker will look inside the sysroot if it's not.
+ rebase_path(android_libgcc_file),
+ ]
+ }
+
+ # Clang with libc++ does not require an explicit atomic library reference.
+ if (!is_clang) {
+ libs += [ "atomic" ]
+ }
+}
+
+config("sdk") {
+ if (sysroot != "") {
+ cflags = [ "--sysroot=" + sysroot ]
+ ldflags = [ "--sysroot=" + sysroot ]
+
+ # Need to get some linker flags out of the sysroot.
+ sysroot_ld_path = rebase_path("//build/config/linux/sysroot_ld_path.py")
+ ldflags += [ exec_script(sysroot_ld_path,
+ [
+ rebase_path("//build/linux/sysroot_ld_path.sh"),
+ sysroot,
+ ],
+ "value") ]
+ }
+}
+
+config("executable_config") {
+ cflags = [ "-fPIE" ]
+ ldflags = [ "-pie" ]
+}
+
+config("hide_native_jni_exports") {
+ ldflags = [ "-Wl,--version-script=" +
+ rebase_path("//build/android/android_no_jni_exports.lst") ]
+}
diff --git a/build/config/android/config.gni b/build/config/android/config.gni
index f3989e9..1b77769 100644
--- a/build/config/android/config.gni
+++ b/build/config/android/config.gni
@@ -195,11 +195,6 @@ if (is_android) {
# Toolchain stuff ------------------------------------------------------------
android_libcpp_root = "$android_ndk_root/sources/cxx-stl/llvm-libc++"
- if (is_component_build) {
- android_libcpp_library = "c++_shared"
- } else {
- android_libcpp_library = "c++_static"
- }
# ABI ------------------------------------------------------------------------
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index e8eb59a..74dec11 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -102,69 +102,18 @@ config("compiler") {
defines = []
configs = []
- # In general, Windows is totally different, but all the other builds share
- # some common GCC configuration. This section sets up Windows and the common
- # GCC flags, and then we handle the other non-Windows platforms specifically
- # below.
+ # System-specific flags. If your compiler flags apply to one of the
+ # categories here, add it to the associated file to keep this shared config
+ # smaller.
if (is_win) {
- # Windows compiler flags setup.
- # -----------------------------
- cflags += [
- "/Gy", # Enable function-level linking.
- "/GS", # Enable buffer security checking.
- "/FS", # Preserve previous PDB behavior.
- "/bigobj", # Some of our files are bigger than the regular limits.
- ]
-
- if (visual_studio_version == "2015") {
- # Work around crbug.com/526851, bug in VS 2015 RTM compiler.
- cflags += [ "/Zc:sizedDealloc-" ]
- }
-
- # Force C/C++ mode for the given GN detected file type. This is necessary
- # for precompiled headers where the same source file is compiled in both
- # modes.
- cflags_c += [ "/TC" ]
- cflags_cc += [ "/TP" ]
-
- # Building with Clang on Windows is a work in progress and very
- # experimental. See crbug.com/82385.
- # Keep this in sync with the similar block in build/common.gypi
- if (is_clang) {
- cflags += [
- # Many files use intrinsics without including this header.
- # TODO(hans): Fix those files, or move this to sub-GYPs.
- "/FIIntrin.h",
- ]
-
- if (visual_studio_version == "2013") {
- cflags += [ "-fmsc-version=1800" ]
- } else if (visual_studio_version == "2015") {
- cflags += [ "-fmsc-version=1900" ]
- }
-
- if (current_cpu == "x86") {
- cflags += [ "-m32" ]
- } else {
- cflags += [ "-m64" ]
- }
-
- if (exec_script("//build/win/use_ansi_codes.py", [], "trim string") ==
- "True") {
- cflags += [
- # cmd.exe doesn't understand ANSI escape codes by default,
- # so only enable them if something emulating them is around.
- "-fansi-escape-codes",
- ]
- }
- }
+ configs += [ "//build/config/win:compiler" ]
+ } else if (is_android) {
+ configs += [ "//build/config/android:compiler" ]
+ }
- if (is_syzyasan) {
- # SyzyAsan needs /PROFILE turned on to produce appropriate pdbs.
- assert(!is_win_fastlink, "/PROFILE and /DEBUG:FASTLINK are incompatible")
- ldflags += [ "/PROFILE" ]
- }
- } else {
+ # In general, Windows is totally different, but all the other builds share
+ # some common GCC configuration.
+ if (!is_win) {
# Common GCC compiler flags setup.
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
@@ -601,12 +550,6 @@ config("compiler") {
cflags_cc += [ "-std=c++11" ]
}
- # Android-specific flags setup.
- # -----------------------------
- if (is_android) {
- configs += [ "//build/config/android:compiler" ]
- }
-
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
@@ -629,117 +572,20 @@ config("compiler_arm_fpu") {
# target wants the option regardless, put it in the compiler config.
config("runtime_library") {
- cflags = []
defines = []
- ldflags = []
- lib_dirs = []
- libs = []
-
- if (is_component_build) {
- # Component mode: dynamic CRT.
- defines += [ "COMPONENT_BUILD" ]
- if (is_win) {
- # Since the library is shared, it requires exceptions or will give errors
- # about things not matching, so keep exceptions on.
- if (is_debug) {
- cflags += [ "/MDd" ]
- } else {
- cflags += [ "/MD" ]
- }
- }
- } else {
- if (is_win && current_os != "win") {
- # WindowsRT: use the dynamic CRT.
- if (is_debug) {
- cflags += [ "/MDd" ]
- } else {
- cflags += [ "/MD" ]
- }
- } else if (is_win) {
- # Desktop Windows: static CRT.
- if (is_debug) {
- cflags += [ "/MTd" ]
- } else {
- cflags += [ "/MT" ]
- }
- }
- }
+ configs = []
+ # System-specific flags. If your compiler flags apply to one of the
+ # categories here, add it to the associated file to keep this shared config
+ # smaller.
if (is_win) {
- defines += [
- "__STD_C",
- "_CRT_RAND_S",
- "_CRT_SECURE_NO_DEPRECATE",
- "_HAS_EXCEPTIONS=0",
- "_SCL_SECURE_NO_DEPRECATE",
- ]
+ configs += [ "//build/config/win:runtime_library" ]
+ } else if (is_android) {
+ configs += [ "//build/config/android:runtime_library" ]
}
- # Android standard library setup.
- if (is_android) {
- if (is_clang) {
- # Work around incompatibilities between bionic and clang headers.
- defines += [
- "__compiler_offsetof=__builtin_offsetof",
- "nan=__builtin_nan",
- ]
- }
-
- defines += [ "__GNU_SOURCE=1" ] # Necessary for clone().
-
- # TODO(jdduke) Re-enable on mips after resolving linking
- # issues with libc++ (crbug.com/456380).
- if (current_cpu != "mipsel" && current_cpu != "mips64el") {
- ldflags += [ "-Wl,--warn-shared-textrel" ]
- }
- ldflags += [ "-nostdlib" ]
-
- # NOTE: The libc++ header include paths below are specified in cflags
- # rather than include_dirs because they need to come after include_dirs.
- # Think of them like system headers, but don't use '-isystem' because the
- # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit
- # strange errors. The include ordering here is important; change with
- # caution.
- cflags += [
- "-isystem" +
- rebase_path("$android_libcpp_root/libcxx/include", root_build_dir),
- "-isystem" + rebase_path(
- "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/include",
- root_build_dir),
- "-isystem" +
- rebase_path("$android_ndk_root/sources/android/support/include",
- root_build_dir),
- ]
-
- lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ]
- libs += [ "$android_libcpp_library" ]
-
- if (current_cpu == "mipsel") {
- libs += [
- # ld linker is used for mips Android, and ld does not accept library
- # absolute path prefixed by "-l"; Since libgcc does not exist in mips
- # sysroot the proper library will be linked.
- # TODO(gordanac): Remove once gold linker is used for mips Android.
- "gcc",
- ]
- } else {
- libs += [
- # Manually link the libgcc.a that the cross compiler uses. This is
- # absolute because the linker will look inside the sysroot if it's not.
- rebase_path(android_libgcc_file),
- ]
- }
-
- libs += [
- "c",
- "dl",
- "m",
- ]
-
- # Clang with libc++ does not require an explicit atomic library reference.
- if (!is_clang) {
- libs += [ "atomic" ]
- }
+ if (is_component_build) {
+ defines += [ "COMPONENT_BUILD" ]
}
}
@@ -1010,6 +856,7 @@ config("chromium_code") {
cflags += default_warning_flags
cflags_cc = default_warning_flags_cc
}
+
config("no_chromium_code") {
cflags = []
cflags_cc = []
diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn
index e00c6d8..a93ed30 100644
--- a/build/config/win/BUILD.gn
+++ b/build/config/win/BUILD.gn
@@ -6,6 +6,112 @@ import("//build/config/compiler/compiler.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/win/visual_studio_version.gni")
+assert(is_win)
+
+# This is included by reference in the //build/config/compiler config that
+# is applied to all targets. It is here to separate out the logic that is
+# Windows-only.
+config("compiler") {
+ cflags = [
+ "/Gy", # Enable function-level linking.
+ "/GS", # Enable buffer security checking.
+ "/FS", # Preserve previous PDB behavior.
+ "/bigobj", # Some of our files are bigger than the regular limits.
+ ]
+
+ # Force C/C++ mode for the given GN detected file type. This is necessary
+ # for precompiled headers where the same source file is compiled in both
+ # modes.
+ cflags_c = [ "/TC" ]
+ cflags_cc = [ "/TP" ]
+
+ # Work around crbug.com/526851, bug in VS 2015 RTM compiler.
+ if (visual_studio_version == "2015") {
+ cflags += [ "/Zc:sizedDealloc-" ]
+ }
+
+ # Building with Clang on Windows is a work in progress and very
+ # experimental. See crbug.com/82385.
+ # Keep this in sync with the similar block in build/common.gypi
+ if (is_clang) {
+ cflags += [
+ # Many files use intrinsics without including this header.
+ # TODO(hans): Fix those files, or move this to sub-GYPs.
+ "/FIIntrin.h",
+ ]
+
+ if (visual_studio_version == "2013") {
+ cflags += [ "-fmsc-version=1800" ]
+ } else if (visual_studio_version == "2015") {
+ cflags += [ "-fmsc-version=1900" ]
+ }
+
+ if (current_cpu == "x86") {
+ cflags += [ "-m32" ]
+ } else {
+ cflags += [ "-m64" ]
+ }
+
+ if (exec_script("//build/win/use_ansi_codes.py", [], "trim string") ==
+ "True") {
+ cflags += [
+ # cmd.exe doesn't understand ANSI escape codes by default,
+ # so only enable them if something emulating them is around.
+ "-fansi-escape-codes",
+ ]
+ }
+ }
+
+ if (is_syzyasan) {
+ # SyzyAsan needs /PROFILE turned on to produce appropriate pdbs.
+ assert(!is_win_fastlink, "/PROFILE and /DEBUG:FASTLINK are incompatible")
+ ldflags = [ "/PROFILE" ]
+ }
+}
+
+# This is included by reference in the //build/config/compiler:runtime_library
+# config that is applied to all targets. It is here to separate out the logic
+# that is Windows-only. Please see that target for advice on what should go in
+# :runtime_library vs. :compiler.
+config("runtime_library") {
+ cflags = []
+
+ defines = [
+ "__STD_C",
+ "_CRT_RAND_S",
+ "_CRT_SECURE_NO_DEPRECATE",
+ "_HAS_EXCEPTIONS=0",
+ "_SCL_SECURE_NO_DEPRECATE",
+ ]
+
+ if (is_component_build) {
+ # Component mode: dynamic CRT. Since the library is shared, it requires
+ # exceptions or will give errors about things not matching, so keep
+ # exceptions on.
+ if (is_debug) {
+ cflags += [ "/MDd" ]
+ } else {
+ cflags += [ "/MD" ]
+ }
+ } else {
+ if (current_os != "win") {
+ # WindowsRT: use the dynamic CRT.
+ if (is_debug) {
+ cflags += [ "/MDd" ]
+ } else {
+ cflags += [ "/MD" ]
+ }
+ } else {
+ # Desktop Windows: static CRT.
+ if (is_debug) {
+ cflags += [ "/MTd" ]
+ } else {
+ cflags += [ "/MT" ]
+ }
+ }
+ }
+}
+
# Compiler setup for the Windows SDK. Applied to all targets.
config("sdk") {
# The include path is the stuff returned by the script.