Enable -Wexit-time-destructors and -Wglobal-constructors.

This CL enables -Wexit-time-destructors and -Wglobal-constructors on
rtc_static_library and rtc_source_set build targets.

It also adds the possibility to suppress these warnings because
they trigger in a few places.

The long term goal is to avoid regressions on this and remove all the
suppressions.

Bug: webrtc:9693
Change-Id: I4c1ecc137ef9e87ec5e66981ce95d96fb082727c
Reviewed-on: https://webrtc-review.googlesource.com/98380
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24604}
diff --git a/BUILD.gn b/BUILD.gn
index 0fd2a2a..418408b 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -166,6 +166,32 @@
   }
 }
 
+# TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning
+# as soon as WebRTC compiles without it.
+config("no_exit_time_destructors") {
+  if (is_clang) {
+    cflags = [ "-Wno-exit-time-destructors" ]
+  }
+}
+
+# TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning
+# as soon as WebRTC compiles without it.
+config("no_global_constructors") {
+  if (is_clang) {
+    cflags = [ "-Wno-global-constructors" ]
+  }
+}
+
+config("rtc_prod_config") {
+  # Ideally, WebRTC production code (but not test code) should have these flags.
+  if (is_clang) {
+    cflags = [
+      "-Wexit-time-destructors",
+      "-Wglobal-constructors",
+    ]
+  }
+}
+
 config("common_config") {
   cflags = []
   cflags_c = []