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

Side by Side Diff: build/config/compiler/BUILD.gn

Issue 682843002: Adds ability to build for asan with gn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 6 years, 1 month 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
« no previous file with comments | « build/config/allocator.gni ('k') | build/config/sanitizers/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (cpu_arch == "arm") { 6 if (cpu_arch == "arm") {
7 import("//build/config/arm.gni") 7 import("//build/config/arm.gni")
8 } 8 }
9 if (is_posix) { 9 if (is_posix) {
10 import("//build/config/gcc/gcc_version.gni") 10 import("//build/config/gcc/gcc_version.gni")
(...skipping 27 matching lines...) Expand all
38 # This is a separate config so that third_party code (which would not use the 38 # This is a separate config so that third_party code (which would not use the
39 # source root and might have conflicting versions of some headers) can remove 39 # source root and might have conflicting versions of some headers) can remove
40 # this and specify their own include paths. 40 # this and specify their own include paths.
41 config("default_include_dirs") { 41 config("default_include_dirs") {
42 include_dirs = [ 42 include_dirs = [
43 "//", 43 "//",
44 root_gen_dir, 44 root_gen_dir,
45 ] 45 ]
46 } 46 }
47 47
48 # TODO(GYP): is_ubsan, is_ubsan_vptr
49 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan
50
48 # compiler --------------------------------------------------------------------- 51 # compiler ---------------------------------------------------------------------
49 # 52 #
50 # Base compiler configuration. 53 # Base compiler configuration.
51 # 54 #
52 # See also "runtime_library" below for related stuff and a discusison about 55 # See also "runtime_library" below for related stuff and a discusison about
53 # where stuff should go. Put warning related stuff in the "warnings" config. 56 # where stuff should go. Put warning related stuff in the "warnings" config.
54 57
55 config("compiler") { 58 config("compiler") {
56 cflags = [] 59 cflags = []
57 cflags_c = [] 60 cflags_c = []
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 cflags += [ "-fstack-protector-all" ] 99 cflags += [ "-fstack-protector-all" ]
97 } else if (is_linux) { 100 } else if (is_linux) {
98 cflags += [ "-fstack-protector", "--param=ssp-buffer-size=4" ] 101 cflags += [ "-fstack-protector", "--param=ssp-buffer-size=4" ]
99 } 102 }
100 103
101 # Linker warnings. 104 # Linker warnings.
102 if (!(is_chromeos && cpu_arch == "arm") && !is_mac) { 105 if (!(is_chromeos && cpu_arch == "arm") && !is_mac) {
103 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 106 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580
104 ldflags += [ "-Wl,--fatal-warnings" ] 107 ldflags += [ "-Wl,--fatal-warnings" ]
105 } 108 }
109
110 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and
111 # MemorySanitizer
112 if (using_sanitizer) {
113 cflags += [
114 "-fno-omit-frame-pointer",
115 "-gline-tables-only",
116 ]
117 }
118 if (is_asan) {
119 cflags += [ "-fsanitize=address" ]
120 if (is_mac) {
121 cflags += [ "-mllvm -asan-globals=0" ] # http://crbug.com/352073
122 # TODO(GYP): deal with mac_bundles.
123 }
124 }
106 } 125 }
107 126
108 if (is_clang && is_debug) { 127 if (is_clang && is_debug) {
109 # Allow comparing the address of references and 'this' against 0 128 # Allow comparing the address of references and 'this' against 0
110 # in debug builds. Technically, these can never be null in 129 # in debug builds. Technically, these can never be null in
111 # well-defined C/C++ and Clang can optimize such checks away in 130 # well-defined C/C++ and Clang can optimize such checks away in
112 # release builds, but they may be used in asserts in debug builds. 131 # release builds, but they may be used in asserts in debug builds.
113 cflags_cc += [ 132 cflags_cc += [
114 "-Wno-undefined-bool-conversion", 133 "-Wno-undefined-bool-conversion",
115 "-Wno-tautological-undefined-compare", 134 "-Wno-tautological-undefined-compare",
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 # .comment section taking up binary size. 826 # .comment section taking up binary size.
808 "-fno-ident", 827 "-fno-ident",
809 # Put data and code in their own sections, so that unused symbols 828 # Put data and code in their own sections, so that unused symbols
810 # can be removed at link time with --gc-sections. 829 # can be removed at link time with --gc-sections.
811 "-fdata-sections", 830 "-fdata-sections",
812 "-ffunction-sections", 831 "-ffunction-sections",
813 ] 832 ]
814 common_optimize_on_ldflags = [] 833 common_optimize_on_ldflags = []
815 834
816 if (is_android) { 835 if (is_android) {
817 common_optimize_on_cflags += [ 836 if (!using_sanitizer) {
818 "-fomit-frame-pointer", 837 common_optimize_on_cflags += [ "-fomit-frame-pointer" ]
819 ] 838 }
820 common_optimize_on_ldflags += [ 839 common_optimize_on_ldflags += [
821 # Warn in case of text relocations. 840 # Warn in case of text relocations.
822 "-Wl,--warn-shared-textrel", 841 "-Wl,--warn-shared-textrel",
823 ] 842 ]
824 } 843 }
825 844
826 if (is_mac) { 845 if (is_mac) {
827 if (symbol_level == 2) { 846 if (symbol_level == 2) {
828 # Mac dead code stripping requires symbols. 847 # Mac dead code stripping requires symbols.
829 common_optimize_on_ldflags += [ 848 common_optimize_on_ldflags += [
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 cflags = [ 886 cflags = [
868 "/Od", # Disable optimization. 887 "/Od", # Disable optimization.
869 "/Ob0", # Disable all inlining (on by default). 888 "/Ob0", # Disable all inlining (on by default).
870 "/RTC1", # Runtime checks for stack frame and uninitialized variables. 889 "/RTC1", # Runtime checks for stack frame and uninitialized variables.
871 ] 890 ]
872 } else if (is_android && !android_full_debug) { 891 } else if (is_android && !android_full_debug) {
873 # On Android we kind of optimize some things that don't affect debugging 892 # On Android we kind of optimize some things that don't affect debugging
874 # much even when optimization is disabled to get the binary size down. 893 # much even when optimization is disabled to get the binary size down.
875 cflags = [ 894 cflags = [
876 "-Os", 895 "-Os",
877 "-fomit-frame-pointer",
878 "-fdata-sections", 896 "-fdata-sections",
879 "-ffunction-sections", 897 "-ffunction-sections",
880 ] 898 ]
899 if (!using_sanitizer) {
900 cflags += [ "-fomit-frame-pointer" ]
901 }
881 ldflags = common_optimize_on_ldflags 902 ldflags = common_optimize_on_ldflags
882 } else { 903 } else {
883 cflags = [ "-O0" ] 904 cflags = [ "-O0" ]
884 } 905 }
885 } 906 }
886 907
887 # Turns up the optimization level. On Windows, this implies whole program 908 # Turns up the optimization level. On Windows, this implies whole program
888 # optimization and link-time code generation which is very expensive and should 909 # optimization and link-time code generation which is very expensive and should
889 # be used sparingly. 910 # be used sparingly.
890 config("optimize_max") { 911 config("optimize_max") {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 cflags += [ "-gsplit-dwarf" ] 952 cflags += [ "-gsplit-dwarf" ]
932 } 953 }
933 } 954 }
934 } 955 }
935 956
936 config("no_symbols") { 957 config("no_symbols") {
937 if (!is_win) { 958 if (!is_win) {
938 cflags = [ "-g0" ] 959 cflags = [ "-g0" ]
939 } 960 }
940 } 961 }
OLDNEW
« no previous file with comments | « build/config/allocator.gni ('k') | build/config/sanitizers/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698