$OpenBSD: patch-src_3rdparty_chromium_build_config_compiler_BUILD_gn,v 1.2 2021/01/19 06:16:33 rsadowski Exp $

Index: src/3rdparty/chromium/build/config/compiler/BUILD.gn
--- src/3rdparty/chromium/build/config/compiler/BUILD.gn.orig
+++ src/3rdparty/chromium/build/config/compiler/BUILD.gn
@@ -69,7 +69,7 @@ declare_args() {
 
   # Enable fatal linker warnings. Building Chromium with certain versions
   # of binutils can cause linker warning.
-  fatal_linker_warnings = true
+  fatal_linker_warnings = false
 
   # Build with C++ RTTI enabled. Chromium builds without RTTI by default,
   # but some sanitizers are known to require it, like CFI diagnostics
@@ -409,6 +409,7 @@ config("compiler") {
     }
 
     ldflags += [
+      "-Wl,-z,wxneeded",
       "-Wl,-z,noexecstack",
       "-Wl,-z,relro",
     ]
@@ -417,13 +418,8 @@ config("compiler") {
       ldflags += [ "-Wl,-z,now" ]
     }
 
-    # 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) {
-      ldflags += [
-        "-Wl,-z,defs",
-        "-Wl,--as-needed",
-      ]
+    if (current_cpu == "x86" && is_openbsd) {
+      ldflags += [ "-Wl,-z,notext" ]
     }
   }
 
@@ -518,7 +514,7 @@ config("compiler") {
     ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
   }
 
-  if (is_clang && !is_nacl && !use_xcode_clang && !use_qt) {
+  if (is_clang && !is_nacl && !use_xcode_clang && !use_qt && !is_openbsd) {
     cflags += [ "-fcrash-diagnostics-dir=" +
                 rebase_path("//tools/clang/crashreports", root_build_dir) ]
 
@@ -775,7 +771,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_openbsd) {
         cflags += [ "--target=arm-linux-gnueabihf" ]
         ldflags += [ "--target=arm-linux-gnueabihf" ]
       }
@@ -789,7 +785,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_openbsd) {
         cflags += [ "--target=aarch64-linux-gnu" ]
         ldflags += [ "--target=aarch64-linux-gnu" ]
       }
@@ -1548,24 +1544,6 @@ config("default_warnings") {
           # Ignore warnings about MSVC optimization pragmas.
           # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
           "-Wno-ignored-pragma-optimize",
-
-          # TODO(https://crbug.com/989932): Evaluate and possibly enable.
-          "-Wno-implicit-int-float-conversion",
-
-          # TODO(https://crbug.com/999886): Clean up, enable.
-          "-Wno-final-dtor-non-final-class",
-
-          # TODO(https://crbug.com/1016945) Clean up, enable.
-          "-Wno-builtin-assume-aligned-alignment",
-
-          # TODO(https://crbug.com/1028110): Evaluate and possible enable.
-          "-Wno-deprecated-copy",
-
-          # TODO(https://crbug.com/1050281): Clean up, enable.
-          "-Wno-non-c-typedef-for-linkage",
-
-          # TODO(https://crbug.com/1059231): Clean up, enable.
-          "-Wno-pointer-to-int-cast",
         ]
 
         if (is_android) {
@@ -1713,7 +1691,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_openbsd) {
       cflags += [
         # TODO(https://crbug.com/1031169): Clean up and enable.
         "-Wno-misleading-indentation",
@@ -1791,7 +1769,7 @@ config("thin_archive") {
   # Mac and iOS use the mac-specific "libtool" command, not ar, which doesn't
   # have a "thin archive" mode (it does accept -T, but it means truncating
   # archive names to 16 characters, which is not what we want).
-  if ((is_posix && !is_nacl && !is_mac && !is_ios) || is_fuchsia) {
+  if ((is_posix && !is_nacl && !is_mac && !is_ios && !is_openbsd) || is_fuchsia) {
     arflags = [ "-T" ]
   } else if (is_win && use_lld) {
     arflags = [ "/llvmlibthin" ]
@@ -2212,7 +2190,7 @@ config("afdo_optimize_size") {
 # between //base/allocator:tcmalloc and AFDO on GCC), so we provide a separate
 # config to allow AFDO to be disabled per-target.
 config("afdo") {
-  if (is_clang) {
+  if (is_clang && !is_openbsd) {
     cflags = []
     if (clang_emit_debug_info_for_profiling) {
       # Add the following flags to generate debug info for profiling.
@@ -2227,7 +2205,7 @@ config("afdo") {
       cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
       inputs = [ _clang_sample_profile ]
     }
-  } else if (auto_profile_path != "" && is_a_target_toolchain) {
+  } else if (auto_profile_path != "" && is_a_target_toolchain && !is_openbsd) {
     cflags = [ "-fauto-profile=${auto_profile_path}" ]
     inputs = [ auto_profile_path ]
   }
@@ -2323,10 +2301,10 @@ 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 += [ "${DEBUGFLAG}" ]
     }
 
-    if (is_clang && !is_nacl && !use_xcode_clang && !use_qt) {
+    if (is_clang && !is_nacl && !use_xcode_clang && !use_qt && !is_openbsd) {
       cflags += [
         "-Xclang",
         "-debug-info-kind=constructor",
