Introduce and apply pdfium_strict_config.

Turn on more compiler warnings in this new config:
-Wexit-time-destructors and -Wglobal-constructors.

Use the new config everywhere except in:

1) Test targets, where tests generate global constructors, and exit time
   destructors are used for convenience. These will not be fixed.
2) Production targets that currently do not pass. These will be fixed in
   a follow-up CL.

Change-Id: Icbc1b8c2ff80638e035a9e25db0762547a44d192
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79870
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 5acd071..bf0994a 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -116,6 +116,14 @@
   }
 }
 
+config("pdfium_strict_config") {
+  configs = [
+    ":pdfium_core_config",
+    "//build/config/compiler:wexit_time_destructors",
+    "//build/config/compiler:wglobal_constructors",
+  ]
+}
+
 source_set("pdfium_public_headers_impl") {
   sources = [
     "public/cpp/fpdf_deleters.h",
@@ -154,7 +162,7 @@
 
 component("pdfium") {
   libs = []
-  configs += [ ":pdfium_core_config" ]
+  configs += [ ":pdfium_strict_config" ]
   public_configs = [ ":pdfium_public_config" ]
 
   deps = [
@@ -354,7 +362,7 @@
     "testing/image_diff",
     "//build/win:default_exe_manifest",
   ]
-  configs += [ ":pdfium_core_config" ]
+  configs += [ ":pdfium_strict_config" ]
 }
 
 if (pdf_is_standalone) {
diff --git a/core/fdrm/BUILD.gn b/core/fdrm/BUILD.gn
index 888bb92..8e79c14 100644
--- a/core/fdrm/BUILD.gn
+++ b/core/fdrm/BUILD.gn
@@ -12,7 +12,7 @@
     "fx_crypt_aes.cpp",
     "fx_crypt_sha.cpp",
   ]
-  configs += [ "../../:pdfium_core_config" ]
+  configs += [ "../../:pdfium_strict_config" ]
   deps = [ "../fxcrt" ]
   visibility = [ "../../*" ]
 }
diff --git a/core/fpdfapi/cmaps/BUILD.gn b/core/fpdfapi/cmaps/BUILD.gn
index e7fddbf..9a64298 100644
--- a/core/fpdfapi/cmaps/BUILD.gn
+++ b/core/fpdfapi/cmaps/BUILD.gn
@@ -70,7 +70,7 @@
     "fpdf_cmaps.cpp",
     "fpdf_cmaps.h",
   ]
-  configs += [ "../../../:pdfium_core_config" ]
+  configs += [ "../../../:pdfium_strict_config" ]
   deps = [ "../../fxcrt" ]
   visibility = [ "../../../*" ]
 }
diff --git a/core/fpdfapi/edit/BUILD.gn b/core/fpdfapi/edit/BUILD.gn
index cda86e63..8ce8be9 100644
--- a/core/fpdfapi/edit/BUILD.gn
+++ b/core/fpdfapi/edit/BUILD.gn
@@ -18,7 +18,7 @@
     "cpdf_stringarchivestream.cpp",
     "cpdf_stringarchivestream.h",
   ]
-  configs += [ "../../../:pdfium_core_config" ]
+  configs += [ "../../../:pdfium_strict_config" ]
   deps = [
     "../../../constants",
     "../../../third_party:skia_shared",
diff --git a/core/fpdfapi/font/BUILD.gn b/core/fpdfapi/font/BUILD.gn
index 11f4ece..7d8317f 100644
--- a/core/fpdfapi/font/BUILD.gn
+++ b/core/fpdfapi/font/BUILD.gn
@@ -40,7 +40,7 @@
     "cpdf_type3font.cpp",
     "cpdf_type3font.h",
   ]
-  configs += [ "../../../:pdfium_core_config" ]
+  configs += [ "../../../:pdfium_strict_config" ]
   deps = [
     "../../fxcrt",
     "../../fxge",
diff --git a/core/fpdfapi/parser/BUILD.gn b/core/fpdfapi/parser/BUILD.gn
index ad8a783..21a341a 100644
--- a/core/fpdfapi/parser/BUILD.gn
+++ b/core/fpdfapi/parser/BUILD.gn
@@ -74,7 +74,7 @@
     "fpdf_parser_utility.cpp",
     "fpdf_parser_utility.h",
   ]
-  configs += [ "../../../:pdfium_core_config" ]
+  configs += [ "../../../:pdfium_strict_config" ]
   deps = [
     "../../../constants",
     "../../fdrm",
diff --git a/core/fpdfapi/render/BUILD.gn b/core/fpdfapi/render/BUILD.gn
index 515d300..33b800b 100644
--- a/core/fpdfapi/render/BUILD.gn
+++ b/core/fpdfapi/render/BUILD.gn
@@ -44,7 +44,7 @@
     "cpdf_type3glyphmap.cpp",
     "cpdf_type3glyphmap.h",
   ]
-  configs += [ "../../../:pdfium_core_config" ]
+  configs += [ "../../../:pdfium_strict_config" ]
   deps = [
     "../../../constants",
     "../../fxcodec",
diff --git a/core/fpdfdoc/BUILD.gn b/core/fpdfdoc/BUILD.gn
index 5e62af9..bb5c421 100644
--- a/core/fpdfdoc/BUILD.gn
+++ b/core/fpdfdoc/BUILD.gn
@@ -77,7 +77,7 @@
     "cpvt_wordrange.h",
     "ipvt_fontmap.h",
   ]
-  configs += [ "../../:pdfium_core_config" ]
+  configs += [ "../../:pdfium_strict_config" ]
   deps = [
     "../../constants",
     "../fpdfapi/font",
diff --git a/core/fpdftext/BUILD.gn b/core/fpdftext/BUILD.gn
index f48a96d..13b2796 100644
--- a/core/fpdftext/BUILD.gn
+++ b/core/fpdftext/BUILD.gn
@@ -16,7 +16,7 @@
     "unicodenormalizationdata.cpp",
     "unicodenormalizationdata.h",
   ]
-  configs += [ "../../:pdfium_core_config" ]
+  configs += [ "../../:pdfium_strict_config" ]
   deps = [
     "../fpdfapi/font",
     "../fpdfapi/page",
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn
index f53f6e0..842695c 100644
--- a/core/fxcodec/BUILD.gn
+++ b/core/fxcodec/BUILD.gn
@@ -69,7 +69,7 @@
     "scanlinedecoder.cpp",
     "scanlinedecoder.h",
   ]
-  configs += [ "../../:pdfium_core_config" ]
+  configs += [ "../../:pdfium_strict_config" ]
   include_dirs = []
   deps = [
     "../../third_party:lcms2",
diff --git a/core/fxcrt/css/BUILD.gn b/core/fxcrt/css/BUILD.gn
index e412140..2e01b46 100644
--- a/core/fxcrt/css/BUILD.gn
+++ b/core/fxcrt/css/BUILD.gn
@@ -55,7 +55,7 @@
     "../",
     "../../fxge",
   ]
-  configs += [ "../../../:pdfium_core_config" ]
+  configs += [ "../../../:pdfium_strict_config" ]
   visibility = [ "../../../*" ]
 }
 
diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn
index 0ec54f3..af6a1cd 100644
--- a/core/fxge/BUILD.gn
+++ b/core/fxge/BUILD.gn
@@ -115,7 +115,7 @@
 
   configs += [
     ":fxge_warnings",
-    "../../:pdfium_core_config",
+    "../../:pdfium_strict_config",
   ]
 
   deps = [ "../fxcrt" ]
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index 20a925a..dc8012a 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -72,7 +72,7 @@
     "ipdfsdk_annothandler.h",
   ]
 
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   deps = [
     "../:pdfium_public_headers",
     "../constants",
diff --git a/fpdfsdk/formfiller/BUILD.gn b/fpdfsdk/formfiller/BUILD.gn
index c038961..10d5e74 100644
--- a/fpdfsdk/formfiller/BUILD.gn
+++ b/fpdfsdk/formfiller/BUILD.gn
@@ -29,7 +29,7 @@
     "cffl_textobject.cpp",
     "cffl_textobject.h",
   ]
-  configs += [ "../../:pdfium_core_config" ]
+  configs += [ "../../:pdfium_strict_config" ]
   deps = [
     "../../:pdfium_public_headers",
     "../../constants",
diff --git a/fpdfsdk/fpdfxfa/BUILD.gn b/fpdfsdk/fpdfxfa/BUILD.gn
index 92ac9f7..8ddfd55 100644
--- a/fpdfsdk/fpdfxfa/BUILD.gn
+++ b/fpdfsdk/fpdfxfa/BUILD.gn
@@ -35,7 +35,7 @@
     "../../xfa/fxfa",
     "../../xfa/fxfa/parser",
   ]
-  configs += [ "../../:pdfium_core_config" ]
+  configs += [ "../../:pdfium_strict_config" ]
   visibility = [ "../../*" ]
 }
 
diff --git a/fpdfsdk/pwl/BUILD.gn b/fpdfsdk/pwl/BUILD.gn
index 112aef9..f8bae0f 100644
--- a/fpdfsdk/pwl/BUILD.gn
+++ b/fpdfsdk/pwl/BUILD.gn
@@ -36,7 +36,7 @@
     "ipwl_fillernotify.h",
     "ipwl_systemhandler.h",
   ]
-  configs += [ "../../:pdfium_core_config" ]
+  configs += [ "../../:pdfium_strict_config" ]
   deps = [
     "../../:pdfium_public_headers",
     "../../constants",
diff --git a/fxbarcode/BUILD.gn b/fxbarcode/BUILD.gn
index 2b10e95..af3eeaf 100644
--- a/fxbarcode/BUILD.gn
+++ b/fxbarcode/BUILD.gn
@@ -138,7 +138,7 @@
     "../core/fxge",
     "../third_party:bigint",
   ]
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   visibility = [ "../*" ]
 }
 
diff --git a/fxjs/BUILD.gn b/fxjs/BUILD.gn
index 585d7da..0d9dc05 100644
--- a/fxjs/BUILD.gn
+++ b/fxjs/BUILD.gn
@@ -225,7 +225,7 @@
         "gc/heap.cpp",
         "gc/heap.h",
       ]
-      configs += [ "../:pdfium_core_config" ]
+      configs += [ "../:pdfium_strict_config" ]
       deps = [
         "../core/fxcrt",
         "//v8:v8_libplatform",
diff --git a/testing/BUILD.gn b/testing/BUILD.gn
index 39c12a8..7843628 100644
--- a/testing/BUILD.gn
+++ b/testing/BUILD.gn
@@ -35,7 +35,7 @@
     "../core/fxge",
     "image_diff",
   ]
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   visibility = [ "../*" ]
   if (pdf_enable_v8) {
     sources += [
@@ -57,7 +57,7 @@
     "utils/path_service.h",
   ]
   deps = [ "../core/fxcrt" ]
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   visibility = [ "../*" ]
 }
 
@@ -73,7 +73,7 @@
     "../core/fxge",
     "//testing/gtest",
   ]
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   if (pdf_enable_v8) {
     sources += [
       "v8_test_environment.cpp",
@@ -102,7 +102,7 @@
   testonly = true
   sources = []
   deps = []
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   public_deps = [
     ":test_environments",
     ":test_support",
@@ -158,7 +158,7 @@
     ":test_environments",
     ":test_support",
   ]
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   visibility = [ "../*" ]
   if (pdf_enable_v8) {
     sources += [
diff --git a/testing/fuzzers/BUILD.gn b/testing/fuzzers/BUILD.gn
index 5b2e337..2eeb807 100644
--- a/testing/fuzzers/BUILD.gn
+++ b/testing/fuzzers/BUILD.gn
@@ -5,7 +5,7 @@
 import("../../pdfium.gni")
 
 config("fuzzer_config") {
-  configs = [ "../..:pdfium_core_config" ]
+  configs = [ "../..:pdfium_strict_config" ]
 
   defines = [
     "PNG_PREFIX",
diff --git a/testing/image_diff/BUILD.gn b/testing/image_diff/BUILD.gn
index 141769b..1d0ef4b 100644
--- a/testing/image_diff/BUILD.gn
+++ b/testing/image_diff/BUILD.gn
@@ -10,7 +10,7 @@
     "image_diff_png.cpp",
     "image_diff_png.h",
   ]
-  configs += [ "../../:pdfium_core_config" ]
+  configs += [ "../../:pdfium_strict_config" ]
   deps = [
     "../../third_party:pdfium_base",
     "../../third_party:png",
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index a8b8835..f2c5999 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -638,7 +638,7 @@
 
 source_set("pdfium_base_test_support") {
   testonly = true
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   sources = []
   deps = []
 
@@ -652,7 +652,7 @@
 }
 
 source_set("skia_shared") {
-  configs += [ "../:pdfium_core_config" ]
+  configs += [ "../:pdfium_strict_config" ]
   sources = [
     "skia_shared/SkFloatToDecimal.cpp",
     "skia_shared/SkFloatToDecimal.h",
diff --git a/xfa/fde/BUILD.gn b/xfa/fde/BUILD.gn
index 75802cf..1c6b6b4 100644
--- a/xfa/fde/BUILD.gn
+++ b/xfa/fde/BUILD.gn
@@ -24,7 +24,7 @@
     "../fgas/layout",
   ]
   configs += [
-    "../../:pdfium_core_config",
+    "../../:pdfium_strict_config",
     "../:xfa_warnings",
   ]
   visibility = [ "../../*" ]
diff --git a/xfa/fgas/crt/BUILD.gn b/xfa/fgas/crt/BUILD.gn
index 33f2630..4a57e1c 100644
--- a/xfa/fgas/crt/BUILD.gn
+++ b/xfa/fgas/crt/BUILD.gn
@@ -21,7 +21,7 @@
     "../../../core/fxcrt",
   ]
   configs += [
-    "../../../:pdfium_core_config",
+    "../../../:pdfium_strict_config",
     "../../:xfa_warnings",
   ]
   visibility = [ "../../../*" ]
diff --git a/xfa/fgas/font/BUILD.gn b/xfa/fgas/font/BUILD.gn
index 2df95cd..82abd28 100644
--- a/xfa/fgas/font/BUILD.gn
+++ b/xfa/fgas/font/BUILD.gn
@@ -30,7 +30,7 @@
     "../../../core/fxge",
   ]
   configs += [
-    "../../../:pdfium_core_config",
+    "../../../:pdfium_strict_config",
     "../../:xfa_warnings",
   ]
   visibility = [ "../../../*" ]
diff --git a/xfa/fgas/graphics/BUILD.gn b/xfa/fgas/graphics/BUILD.gn
index 5dbe3ce..e9c46b5 100644
--- a/xfa/fgas/graphics/BUILD.gn
+++ b/xfa/fgas/graphics/BUILD.gn
@@ -20,7 +20,7 @@
     "cfgas_geshading.h",
   ]
   configs += [
-    "../../../:pdfium_core_config",
+    "../../../:pdfium_strict_config",
     "../../:xfa_warnings",
   ]
   deps = [
diff --git a/xfa/fgas/layout/BUILD.gn b/xfa/fgas/layout/BUILD.gn
index e9e30a1..1be1a62 100644
--- a/xfa/fgas/layout/BUILD.gn
+++ b/xfa/fgas/layout/BUILD.gn
@@ -39,7 +39,7 @@
     "../font",
   ]
   configs += [
-    "../../../:pdfium_core_config",
+    "../../../:pdfium_strict_config",
     "../../:xfa_warnings",
   ]
   visibility = [ "../../../*" ]
diff --git a/xfa/fwl/BUILD.gn b/xfa/fwl/BUILD.gn
index dead643..511a29c 100644
--- a/xfa/fwl/BUILD.gn
+++ b/xfa/fwl/BUILD.gn
@@ -117,7 +117,7 @@
     "../fgas/graphics",
   ]
   configs += [
-    "../../:pdfium_core_config",
+    "../../:pdfium_strict_config",
     "../:xfa_warnings",
   ]
   visibility = [ "../../*" ]
diff --git a/xfa/fxfa/BUILD.gn b/xfa/fxfa/BUILD.gn
index be7839c..17ce296 100644
--- a/xfa/fxfa/BUILD.gn
+++ b/xfa/fxfa/BUILD.gn
@@ -108,7 +108,7 @@
     "parser",
   ]
   configs += [
-    "../../:pdfium_core_config",
+    "../../:pdfium_strict_config",
     "../:xfa_warnings",
   ]
   visibility = [ "../../*" ]
diff --git a/xfa/fxfa/fm2js/BUILD.gn b/xfa/fxfa/fm2js/BUILD.gn
index a5855a3..30d2b0f 100644
--- a/xfa/fxfa/fm2js/BUILD.gn
+++ b/xfa/fxfa/fm2js/BUILD.gn
@@ -23,7 +23,7 @@
     "../../../fxjs:gc",
   ]
   configs += [
-    "../../../:pdfium_core_config",
+    "../../../:pdfium_strict_config",
     "../../:xfa_warnings",
   ]
   visibility = [ "../../../*" ]
diff --git a/xfa/fxfa/layout/BUILD.gn b/xfa/fxfa/layout/BUILD.gn
index c41693a..8c12c03 100644
--- a/xfa/fxfa/layout/BUILD.gn
+++ b/xfa/fxfa/layout/BUILD.gn
@@ -31,7 +31,7 @@
   ]
   allow_circular_includes_from = [ "../../../fxjs" ]
   configs += [
-    "../../../:pdfium_core_config",
+    "../../../:pdfium_strict_config",
     "../../:xfa_warnings",
   ]
   visibility = [ "../../../*" ]
diff --git a/xfa/fxfa/parser/BUILD.gn b/xfa/fxfa/parser/BUILD.gn
index b0f85a8..9091e1b 100644
--- a/xfa/fxfa/parser/BUILD.gn
+++ b/xfa/fxfa/parser/BUILD.gn
@@ -689,7 +689,7 @@
   ]
   allow_circular_includes_from = [ "../../../fxjs" ]
   configs += [
-    "../../../:pdfium_core_config",
+    "../../../:pdfium_strict_config",
     "../../:xfa_warnings",
   ]
   visibility = [ "../../../*" ]