aboutsummaryrefslogtreecommitdiff
path: root/www/chromium/files/patch-build_config_compiler_BUILD.gn
blob: ef52986708aae07ab0e1dcd27356c34be0dfb15e (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
--- build/config/compiler/BUILD.gn.orig	2021-06-09 22:13:52 UTC
+++ build/config/compiler/BUILD.gn
@@ -133,7 +133,7 @@ declare_args() {
   #
   # TODO(crbug.com/977230): Enabling this when 'use_xcode_clang' is true may
   # call an old clang that doesn't support auto-init.
-  init_stack_vars = !is_android && !use_xcode_clang
+  init_stack_vars = !is_android && !use_xcode_clang && !is_bsd
 
   # This argument is to control whether enabling text section splitting in the
   # final binary. When enabled, the separated text sections with prefix
@@ -333,7 +333,7 @@ config("compiler") {
     }
 
     # Linker warnings.
-    if (fatal_linker_warnings && !is_apple && current_os != "aix") {
+    if (fatal_linker_warnings && !is_apple && !is_bsd && current_os != "aix") {
       ldflags += [ "-Wl,--fatal-warnings" ]
     }
     if (fatal_linker_warnings && is_apple) {
@@ -428,7 +428,7 @@ config("compiler") {
 
     # Compiler instrumentation can introduce dependencies in DSOs to symbols in
     # the executable they are loaded into, so they are unresolved at link-time.
-    if (!using_sanitizer) {
+    if (!using_sanitizer && !is_bsd) {
       ldflags += [
         "-Wl,-z,defs",
         "-Wl,--as-needed",
@@ -518,7 +518,7 @@ config("compiler") {
     ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
   }
 
-  if (is_clang && !is_nacl && !use_xcode_clang) {
+  if (is_clang && !is_nacl && !use_xcode_clang && !is_bsd) {
     cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
 
     # TODO(hans): Remove this once Clang generates better optimized debug info
@@ -661,7 +661,12 @@ config("compiler") {
       # and let it use all cores.
       # TODO(thakis): Check if '=0' (that is, number of cores, instead
       # of "all" which means number of hardware threads) is faster.
-      ldflags += [ "-Wl,--thinlto-jobs=all" ]
+      if (is_bsd) {
+        # FreeBSD < 13 uses LLVM 10, which doesn't support --thinlto-jobs=all
+        ldflags += [ "-Wl,--thinlto-jobs=2" ]
+      } else {
+        ldflags += [ "-Wl,--thinlto-jobs=all" ]
+      }
 
       ldflags += [
         "-Wl,--thinlto-cache-dir=" +
@@ -851,7 +856,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) {
         cflags += [ "--target=aarch64-linux-gnu" ]
         ldflags += [ "--target=aarch64-linux-gnu" ]
       }
@@ -1201,7 +1206,7 @@ config("compiler_deterministic") {
       "-Xclang",
       ".",
     ]
-    if (!is_win) {
+    if (!is_win && !is_bsd) {
       # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
       asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
     }
@@ -1584,7 +1589,7 @@ config("default_warnings") {
         cflags += [ "-Wno-nonportable-include-path" ]
       }
 
-      if (current_toolchain == host_toolchain || !use_xcode_clang) {
+      if ((current_toolchain == host_toolchain || !use_xcode_clang) && !is_bsd) {
         # Flags NaCl (Clang 3.7) and Xcode 9.2 (Clang clang-900.0.39.2) do not
         # recognize.
         cflags += [
@@ -1625,6 +1630,18 @@ config("default_warnings") {
           cflags += [ "-Wno-max-tokens" ]
         }
       }
+
+      if (is_clang && is_bsd) {
+        cflags += [
+          "-Wno-ignored-pragma-optimize",
+          "-Wno-implicit-int-float-conversion",
+          "-Wno-final-dtor-non-final-class",
+          "-Wno-builtin-assume-aligned-alignment",
+          "-Wno-deprecated-copy",
+          "-Wno-thread-safety-analysis",
+          "-Wno-thread-safety-attributes",
+        ]
+      }
     }
   }
 }
@@ -1754,7 +1771,7 @@ config("no_chromium_code") {
       # suppressing them individually, we just blanket suppress them here.
       "-Wno-unused-variable",
     ]
-    if (!is_nacl && (current_toolchain == host_toolchain || !use_xcode_clang)) {
+    if (!is_nacl && (current_toolchain == host_toolchain || !use_xcode_clang) && !is_bsd) {
       cflags += [
         # TODO(https://crbug.com/1031169): Clean up and enable.
         "-Wno-misleading-indentation",
@@ -1832,7 +1849,7 @@ config("export_dynamic") {
 config("thin_archive") {
   # The macOS and iOS default linker ld64 does not support reading thin
   # archives.
-  if ((is_posix && !is_nacl && (!is_apple || use_lld)) || is_fuchsia) {
+  if ((is_posix && !is_nacl && (!is_apple || use_lld) && !is_bsd) || is_fuchsia) {
     arflags = [ "-T" ]
   } else if (is_win && use_lld) {
     arflags = [ "/llvmlibthin" ]
@@ -2373,7 +2390,7 @@ config("symbols") {
     # flag, so we can use use -g1 for pnacl and nacl-clang compiles.
     # gcc nacl is is_nacl && !is_clang, pnacl and nacl-clang are && is_clang.
     if (!is_nacl || is_clang) {
-      cflags += [ "-g2" ]
+      cflags += [ "-g0" ]
     }
 
     # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
@@ -2406,7 +2423,7 @@ config("symbols") {
     # DWARF info may be corrupt; offsets in a range list entry are in different
     # sections" there.  Maybe just a bug in nacl_switch_32.S.
     if (!is_apple && !is_nacl && current_cpu != "x86" &&
-        (use_gold || use_lld)) {
+        (use_gold || use_lld) && !is_bsd) {
       if (is_clang) {
         # This flag enables the GNU-format pubnames and pubtypes sections,
         # which lld needs in order to generate a correct GDB index.