Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Unified Diff: build/config/compiler/BUILD.gn

Issue 1368263002: Separate out compiler and runtime configs on Windows and Android GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build/config/compiler/BUILD.gn
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index e8eb59a8b08e93b35f1b69156203298d4072b29f..74dec11c3b8b645c5030e3925a0ce950d7167e6e 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 = []

Powered by Google App Engine
This is Rietveld 408576698