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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import("//build/config/android/config.gni") 5 import("//build/config/android/config.gni")
6 import("//build/config/chrome_build.gni") 6 import("//build/config/chrome_build.gni")
7 import("//build/config/compiler/compiler.gni") 7 import("//build/config/compiler/compiler.gni")
8 import("//build/toolchain/ccache.gni") 8 import("//build/toolchain/ccache.gni")
9 9
10 if (current_cpu == "arm") { 10 if (current_cpu == "arm") {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 config("compiler") { 95 config("compiler") {
96 cflags = [] 96 cflags = []
97 cflags_c = [] 97 cflags_c = []
98 cflags_cc = [] 98 cflags_cc = []
99 cflags_objc = [] 99 cflags_objc = []
100 cflags_objcc = [] 100 cflags_objcc = []
101 ldflags = [] 101 ldflags = []
102 defines = [] 102 defines = []
103 configs = [] 103 configs = []
104 104
105 # System-specific flags. If your compiler flags apply to one of the
106 # categories here, add it to the associated file to keep this shared config
107 # smaller.
108 if (is_win) {
109 configs += [ "//build/config/win:compiler" ]
110 } else if (is_android) {
111 configs += [ "//build/config/android:compiler" ]
112 }
113
105 # In general, Windows is totally different, but all the other builds share 114 # In general, Windows is totally different, but all the other builds share
106 # some common GCC configuration. This section sets up Windows and the common 115 # some common GCC configuration.
107 # GCC flags, and then we handle the other non-Windows platforms specifically 116 if (!is_win) {
108 # below.
109 if (is_win) {
110 # Windows compiler flags setup.
111 # -----------------------------
112 cflags += [
113 "/Gy", # Enable function-level linking.
114 "/GS", # Enable buffer security checking.
115 "/FS", # Preserve previous PDB behavior.
116 "/bigobj", # Some of our files are bigger than the regular limits.
117 ]
118
119 if (visual_studio_version == "2015") {
120 # Work around crbug.com/526851, bug in VS 2015 RTM compiler.
121 cflags += [ "/Zc:sizedDealloc-" ]
122 }
123
124 # Force C/C++ mode for the given GN detected file type. This is necessary
125 # for precompiled headers where the same source file is compiled in both
126 # modes.
127 cflags_c += [ "/TC" ]
128 cflags_cc += [ "/TP" ]
129
130 # Building with Clang on Windows is a work in progress and very
131 # experimental. See crbug.com/82385.
132 # Keep this in sync with the similar block in build/common.gypi
133 if (is_clang) {
134 cflags += [
135 # Many files use intrinsics without including this header.
136 # TODO(hans): Fix those files, or move this to sub-GYPs.
137 "/FIIntrin.h",
138 ]
139
140 if (visual_studio_version == "2013") {
141 cflags += [ "-fmsc-version=1800" ]
142 } else if (visual_studio_version == "2015") {
143 cflags += [ "-fmsc-version=1900" ]
144 }
145
146 if (current_cpu == "x86") {
147 cflags += [ "-m32" ]
148 } else {
149 cflags += [ "-m64" ]
150 }
151
152 if (exec_script("//build/win/use_ansi_codes.py", [], "trim string") ==
153 "True") {
154 cflags += [
155 # cmd.exe doesn't understand ANSI escape codes by default,
156 # so only enable them if something emulating them is around.
157 "-fansi-escape-codes",
158 ]
159 }
160 }
161
162 if (is_syzyasan) {
163 # SyzyAsan needs /PROFILE turned on to produce appropriate pdbs.
164 assert(!is_win_fastlink, "/PROFILE and /DEBUG:FASTLINK are incompatible")
165 ldflags += [ "/PROFILE" ]
166 }
167 } else {
168 # Common GCC compiler flags setup. 117 # Common GCC compiler flags setup.
169 # -------------------------------- 118 # --------------------------------
170 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 119 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
171 cflags_cc += [ 120 cflags_cc += [
172 "-fno-threadsafe-statics", 121 "-fno-threadsafe-statics",
173 122
174 # Not exporting C++ inline functions can generally be applied anywhere 123 # Not exporting C++ inline functions can generally be applied anywhere
175 # so we do so here. Normal function visibility is controlled by 124 # so we do so here. Normal function visibility is controlled by
176 # //build/config/gcc:symbol_visibility_hidden. 125 # //build/config/gcc:symbol_visibility_hidden.
177 "-fvisibility-inlines-hidden", 126 "-fvisibility-inlines-hidden",
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 # http://crbug.com/427584 543 # http://crbug.com/427584
595 cflags_cc += [ "-std=gnu++11" ] 544 cflags_cc += [ "-std=gnu++11" ]
596 } else if (!is_win && !is_nacl) { 545 } else if (!is_win && !is_nacl) {
597 # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either gnu++11 546 # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either gnu++11
598 # or c++11; we technically don't need this toolchain any more, but there 547 # or c++11; we technically don't need this toolchain any more, but there
599 # are still a few buildbots using it, so until those are turned off 548 # are still a few buildbots using it, so until those are turned off
600 # we need the !is_nacl clause and the (is_nacl && is_clang) clause, above. 549 # we need the !is_nacl clause and the (is_nacl && is_clang) clause, above.
601 cflags_cc += [ "-std=c++11" ] 550 cflags_cc += [ "-std=c++11" ]
602 } 551 }
603 552
604 # Android-specific flags setup.
605 # -----------------------------
606 if (is_android) {
607 configs += [ "//build/config/android:compiler" ]
608 }
609
610 # Pass the same C/C++ flags to the objective C/C++ compiler. 553 # Pass the same C/C++ flags to the objective C/C++ compiler.
611 cflags_objc += cflags_c 554 cflags_objc += cflags_c
612 cflags_objcc += cflags_cc 555 cflags_objcc += cflags_cc
613 } 556 }
614 557
615 config("compiler_arm_fpu") { 558 config("compiler_arm_fpu") {
616 if (current_cpu == "arm" && !is_ios && !is_nacl) { 559 if (current_cpu == "arm" && !is_ios && !is_nacl) {
617 cflags = [ "-mfpu=$arm_fpu" ] 560 cflags = [ "-mfpu=$arm_fpu" ]
618 } 561 }
619 } 562 }
620 563
621 # runtime_library ------------------------------------------------------------- 564 # runtime_library -------------------------------------------------------------
622 # 565 #
623 # Sets the runtime library and associated options. 566 # Sets the runtime library and associated options.
624 # 567 #
625 # How do you determine what should go in here vs. "compiler" above? Consider if 568 # How do you determine what should go in here vs. "compiler" above? Consider if
626 # a target might choose to use a different runtime library (ignore for a moment 569 # a target might choose to use a different runtime library (ignore for a moment
627 # if this is possible or reasonable on your system). If such a target would want 570 # if this is possible or reasonable on your system). If such a target would want
628 # to change or remove your option, put it in the runtime_library config. If a 571 # to change or remove your option, put it in the runtime_library config. If a
629 # target wants the option regardless, put it in the compiler config. 572 # target wants the option regardless, put it in the compiler config.
630 573
631 config("runtime_library") { 574 config("runtime_library") {
632 cflags = []
633 defines = [] 575 defines = []
634 ldflags = [] 576 configs = []
635 lib_dirs = [] 577
636 libs = [] 578 # System-specific flags. If your compiler flags apply to one of the
579 # categories here, add it to the associated file to keep this shared config
580 # smaller.
581 if (is_win) {
582 configs += [ "//build/config/win:runtime_library" ]
583 } else if (is_android) {
584 configs += [ "//build/config/android:runtime_library" ]
585 }
637 586
638 if (is_component_build) { 587 if (is_component_build) {
639 # Component mode: dynamic CRT.
640 defines += [ "COMPONENT_BUILD" ] 588 defines += [ "COMPONENT_BUILD" ]
641 if (is_win) {
642 # Since the library is shared, it requires exceptions or will give errors
643 # about things not matching, so keep exceptions on.
644 if (is_debug) {
645 cflags += [ "/MDd" ]
646 } else {
647 cflags += [ "/MD" ]
648 }
649 }
650 } else {
651 if (is_win && current_os != "win") {
652 # WindowsRT: use the dynamic CRT.
653 if (is_debug) {
654 cflags += [ "/MDd" ]
655 } else {
656 cflags += [ "/MD" ]
657 }
658 } else if (is_win) {
659 # Desktop Windows: static CRT.
660 if (is_debug) {
661 cflags += [ "/MTd" ]
662 } else {
663 cflags += [ "/MT" ]
664 }
665 }
666 }
667
668 if (is_win) {
669 defines += [
670 "__STD_C",
671 "_CRT_RAND_S",
672 "_CRT_SECURE_NO_DEPRECATE",
673 "_HAS_EXCEPTIONS=0",
674 "_SCL_SECURE_NO_DEPRECATE",
675 ]
676 }
677
678 # Android standard library setup.
679 if (is_android) {
680 if (is_clang) {
681 # Work around incompatibilities between bionic and clang headers.
682 defines += [
683 "__compiler_offsetof=__builtin_offsetof",
684 "nan=__builtin_nan",
685 ]
686 }
687
688 defines += [ "__GNU_SOURCE=1" ] # Necessary for clone().
689
690 # TODO(jdduke) Re-enable on mips after resolving linking
691 # issues with libc++ (crbug.com/456380).
692 if (current_cpu != "mipsel" && current_cpu != "mips64el") {
693 ldflags += [ "-Wl,--warn-shared-textrel" ]
694 }
695 ldflags += [ "-nostdlib" ]
696
697 # NOTE: The libc++ header include paths below are specified in cflags
698 # rather than include_dirs because they need to come after include_dirs.
699 # Think of them like system headers, but don't use '-isystem' because the
700 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit
701 # strange errors. The include ordering here is important; change with
702 # caution.
703 cflags += [
704 "-isystem" +
705 rebase_path("$android_libcpp_root/libcxx/include", root_build_dir),
706 "-isystem" + rebase_path(
707 "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/includ e",
708 root_build_dir),
709 "-isystem" +
710 rebase_path("$android_ndk_root/sources/android/support/include",
711 root_build_dir),
712 ]
713
714 lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ]
715 libs += [ "$android_libcpp_library" ]
716
717 if (current_cpu == "mipsel") {
718 libs += [
719 # ld linker is used for mips Android, and ld does not accept library
720 # absolute path prefixed by "-l"; Since libgcc does not exist in mips
721 # sysroot the proper library will be linked.
722 # TODO(gordanac): Remove once gold linker is used for mips Android.
723 "gcc",
724 ]
725 } else {
726 libs += [
727 # Manually link the libgcc.a that the cross compiler uses. This is
728 # absolute because the linker will look inside the sysroot if it's not.
729 rebase_path(android_libgcc_file),
730 ]
731 }
732
733 libs += [
734 "c",
735 "dl",
736 "m",
737 ]
738
739 # Clang with libc++ does not require an explicit atomic library reference.
740 if (!is_clang) {
741 libs += [ "atomic" ]
742 }
743 } 589 }
744 } 590 }
745 591
746 # default_warning_flags collects all warning flags that are used by default. 592 # default_warning_flags collects all warning flags that are used by default.
747 # This is in a variable instead of a config so that it can be used in 593 # This is in a variable instead of a config so that it can be used in
748 # both chromium_code and no_chromium_code. This way these flags are guaranteed 594 # both chromium_code and no_chromium_code. This way these flags are guaranteed
749 # to appear on the compile command line after -Wall. 595 # to appear on the compile command line after -Wall.
750 596
751 default_warning_flags = [] 597 default_warning_flags = []
752 default_warning_flags_cc = [] 598 default_warning_flags_cc = []
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 # 849 #
1004 # Non-chromium code is not guaranteed to compile cleanly with 850 # Non-chromium code is not guaranteed to compile cleanly with
1005 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are 851 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
1006 # disabled, so only do that for Release build. 852 # disabled, so only do that for Release build.
1007 defines += [ "_FORTIFY_SOURCE=2" ] 853 defines += [ "_FORTIFY_SOURCE=2" ]
1008 } 854 }
1009 } 855 }
1010 cflags += default_warning_flags 856 cflags += default_warning_flags
1011 cflags_cc = default_warning_flags_cc 857 cflags_cc = default_warning_flags_cc
1012 } 858 }
859
1013 config("no_chromium_code") { 860 config("no_chromium_code") {
1014 cflags = [] 861 cflags = []
1015 cflags_cc = [] 862 cflags_cc = []
1016 defines = [] 863 defines = []
1017 864
1018 if (is_win) { 865 if (is_win) {
1019 cflags += [ 866 cflags += [
1020 "/W3", # Warning level 3. 867 "/W3", # Warning level 3.
1021 "/wd4800", # Disable warning when forcing value to bool. 868 "/wd4800", # Disable warning when forcing value to bool.
1022 "/wd4267", # TODO(jschuh): size_t to int. 869 "/wd4267", # TODO(jschuh): size_t to int.
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 if (symbol_level == 0) { 1221 if (symbol_level == 0) {
1375 configs = [ ":no_symbols" ] 1222 configs = [ ":no_symbols" ]
1376 } else if (symbol_level == 1) { 1223 } else if (symbol_level == 1) {
1377 configs = [ ":minimal_symbols" ] 1224 configs = [ ":minimal_symbols" ]
1378 } else if (symbol_level == 2) { 1225 } else if (symbol_level == 2) {
1379 configs = [ ":symbols" ] 1226 configs = [ ":symbols" ]
1380 } else { 1227 } else {
1381 assert(false) 1228 assert(false)
1382 } 1229 }
1383 } 1230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698