aboutsummaryrefslogtreecommitdiff
path: root/www/iridium/files/patch-build_config_compiler_BUILD.gn
blob: d9028d25faba21bc0e9105255206a7cb2806b534 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
--- build/config/compiler/BUILD.gn.orig	2023-08-28 20:17:35 UTC
+++ build/config/compiler/BUILD.gn
@@ -249,13 +249,16 @@ config("default_include_dirs") {
 # Compiler instrumentation can introduce dependencies in DSOs to symbols in
 # the executable they are loaded into, so they are unresolved at link-time.
 config("no_unresolved_symbols") {
-  if (!using_sanitizer &&
+  if (!using_sanitizer && !is_bsd &&
       (is_linux || is_chromeos || is_android || is_fuchsia)) {
     ldflags = [
       "-Wl,-z,defs",
       "-Wl,--as-needed",
     ]
   }
+  if (current_cpu == "x86" && is_openbsd) {
+    ldflags = [ "-Wl,-z,notext" ]
+  }
 }
 
 # compiler ---------------------------------------------------------------------
@@ -303,7 +306,9 @@ config("compiler") {
 
   configs += [
     # See the definitions below.
+    ":clang_revision",
     ":rustc_revision",
+    ":compiler_cpu_abi",
     ":compiler_codegen",
     ":compiler_deterministic",
   ]
@@ -498,6 +503,10 @@ config("compiler") {
     }
   }
 
+  if (is_openbsd) {
+    ldflags += [ "-Wl,-z,wxneeded" ]
+  }
+
   # Linux-specific compiler flags setup.
   # ------------------------------------
   if (use_gold) {
@@ -825,7 +834,7 @@ config("compiler") {
   # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode
   #   lldb doesn't have the needed changes yet.
   # TODO(crbug.com/1379070): Remove if the upstream default ever changes.
-  if (is_clang && !is_nacl && !is_win && !is_apple) {
+  if (is_clang && !is_nacl && !is_win && !is_apple && !is_bsd) {
     cflags_cc += [ "-gsimple-template-names" ]
   }
 
@@ -1067,7 +1076,7 @@ config("compiler_cpu_abi") {
         ]
       }
     } else if (current_cpu == "arm") {
-      if (is_clang && !is_android && !is_nacl &&
+      if (is_clang && !is_android && !is_nacl && !is_bsd &&
           !(is_chromeos_lacros && is_chromeos_device)) {
         cflags += [ "--target=arm-linux-gnueabihf" ]
         ldflags += [ "--target=arm-linux-gnueabihf" ]
@@ -1082,7 +1091,7 @@ config("compiler_cpu_abi") {
         cflags += [ "-mtune=$arm_tune" ]
       }
     } else if (current_cpu == "arm64") {
-      if (is_clang && !is_android && !is_nacl && !is_fuchsia &&
+      if (is_clang && !is_android && !is_nacl && !is_fuchsia && !is_bsd &&
           !(is_chromeos_lacros && is_chromeos_device)) {
         cflags += [ "--target=aarch64-linux-gnu" ]
         ldflags += [ "--target=aarch64-linux-gnu" ]
@@ -1428,6 +1437,27 @@ config("compiler_deterministic") {
   }
 }
 
+config("clang_revision") {
+  if (is_clang && !is_bsd && clang_base_path == default_clang_base_path) {
+    update_args = [
+      "--print-revision",
+      "--verify-version=$clang_version",
+    ]
+    if (llvm_force_head_revision) {
+      update_args += [ "--llvm-force-head-revision" ]
+    }
+    clang_revision = exec_script("//tools/clang/scripts/update.py",
+                                 update_args,
+                                 "trim string")
+
+    # This is here so that all files get recompiled after a clang roll and
+    # when turning clang on or off. (defines are passed via the command line,
+    # and build system rebuild things when their commandline changes). Nothing
+    # should ever read this define.
+    defines = [ "CR_CLANG_REVISION=\"$clang_revision\"" ]
+  }
+}
+
 config("rustc_revision") {
   if (rustc_revision != "") {
     # Similar to the above config, this is here so that all files get recompiled
@@ -1656,7 +1686,7 @@ config("default_warnings") {
         "-Wno-ignored-pragma-optimize",
       ]
 
-      if (!is_nacl) {
+      if (!is_nacl && !is_bsd) {
         cflags += [
           # TODO(crbug.com/1343975) Evaluate and possibly enable.
           "-Wno-deprecated-builtins",
@@ -1845,7 +1875,7 @@ config("no_chromium_code") {
       # third-party libraries.
       "-Wno-c++11-narrowing",
     ]
-    if (!is_nacl) {
+    if (!is_nacl && !is_freebsd) {
       cflags += [
         # Disabled for similar reasons as -Wunused-variable.
         "-Wno-unused-but-set-variable",
@@ -2129,8 +2159,7 @@ config("default_stack_frames") {
 }
 
 # Default "optimization on" config.
-config("optimize") { }
-config("xoptimize") {
+config("optimize") {
   if (is_win) {
     if (chrome_pgo_phase != 2) {
       # Favor size over speed, /O1 must be before the common flags.
@@ -2189,8 +2218,7 @@ config("xoptimize") {
 }
 
 # Turn off optimizations.
-config("no_optimize") { }
-config("xno_optimize") {
+config("no_optimize") {
   if (is_win) {
     cflags = [
       "/Od",  # Disable optimization.
@@ -2230,8 +2258,7 @@ config("xno_optimize") {
 # Turns up the optimization level. On Windows, this implies whole program
 # optimization and link-time code generation which is very expensive and should
 # be used sparingly.
-config("optimize_max") { }
-config("xoptimize_max") {
+config("optimize_max") {
   if (is_nacl && is_nacl_irt) {
     # The NaCl IRT is a special case and always wants its own config.
     # Various components do:
@@ -2264,8 +2291,7 @@ config("xoptimize_max") {
 #
 # TODO(crbug.com/621335) - rework how all of these configs are related
 # so that we don't need this disclaimer.
-config("optimize_speed") { }
-config("xoptimize_speed") {
+config("optimize_speed") {
   if (is_nacl && is_nacl_irt) {
     # The NaCl IRT is a special case and always wants its own config.
     # Various components do:
@@ -2291,8 +2317,7 @@ config("xoptimize_speed") {
   }
 }
 
-config("optimize_fuzzing") { }
-config("xoptimize_fuzzing") {
+config("optimize_fuzzing") {
   cflags = [ "-O1" ] + common_optimize_on_cflags
   rustflags = [ "-Copt-level=1" ]
   ldflags = common_optimize_on_ldflags
@@ -2360,7 +2385,7 @@ config("afdo_optimize_size") {
 # There are some targeted places that AFDO regresses, so we provide a separate
 # config to allow AFDO to be disabled per-target.
 config("afdo") {
-  if (is_clang) {
+  if (is_clang && !is_bsd) {
     cflags = []
     if (clang_emit_debug_info_for_profiling) {
       # Add the following flags to generate debug info for profiling.
@@ -2379,7 +2404,7 @@ config("afdo") {
       }
       inputs = [ _clang_sample_profile ]
     }
-  } else if (auto_profile_path != "" && is_a_target_toolchain) {
+  } else if (auto_profile_path != "" && is_a_target_toolchain && !is_bsd) {
     cflags = [ "-fauto-profile=${auto_profile_path}" ]
     inputs = [ auto_profile_path ]
   }
@@ -2417,8 +2442,7 @@ config("win_pdbaltpath") {
 }
 
 # Full symbols.
-config("symbols") { }
-config("xsymbols") {
+config("symbols") {
   rustflags = []
   if (is_win) {
     if (is_clang) {
@@ -2538,7 +2562,8 @@ config("xsymbols") {
     configs += [ "//build/config:compress_debug_sections" ]
   }
 
-  if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") {
+  if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos" &&
+      !is_bsd) {
     if (is_apple) {
       # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
       # Make sure we don't use constructor homing on mac.
@@ -2561,8 +2586,7 @@ config("xsymbols") {
 # Minimal symbols.
 # This config guarantees to hold symbol for stack trace which are shown to user
 # when crash happens in unittests running on buildbot.
-config("minimal_symbols") { }
-config("xminimal_symbols") {
+config("minimal_symbols") {
   rustflags = []
   if (is_win) {
     # Functions, files, and line tables only.
@@ -2647,8 +2671,7 @@ config("xminimal_symbols") {
 # This configuration contains function names only. That is, the compiler is
 # told to not generate debug information and the linker then just puts function
 # names in the final debug information.
-config("no_symbols") { }
-config("xno_symbols") {
+config("no_symbols") {
   if (is_win) {
     ldflags = [ "/DEBUG" ]