Set the default ASan options for executables built with ASan on Linux.

This is a copy of https://codereview.chromium.org/201153007 and https://codereview.chromium.org/213113002
updated to the current trunk with more descriptive comments in sanitizer_options.cc and the additional
legacy_pthread_cond=1 option for the Linux Official builds (legacy_pthread_cond is to be deprecated,
thus we don't enable it on the bots).

This CL introduces a module, base/debug/sanitizer_options.cc, which will override
the defaults for various dynamic tools (only ASan at this moment). For every executable
built with a dynamic tool this module will be linked into that executable, providing
weak functions to be called by the tool.

The existing declaration of __asan_default_options() in chrome/app/chrome_exe_main_gtk.cc
has been moved into sanitizer_options.cc (now every binary built with GOOGLE_CHROME_BUILD=1
will have the same options as google-chrome-asan.
The existing declaration of __asan_default_options() in chrome/nacl/nacl_helper_linux.cc
has been kept as is, but we had to remove -Wl,-u_sanitizer_options_link_helper to avoid picking sanitizer_options.cc.

The default options target is deliberately disabled on 32-bit Chromium OS builds,
where one of the host binaries (mksnapshot.ia32) is 32-bit despite host_arch==x86_64.

GYP changes for OSX and iOS will be committed separately.

TBR=thakis@chromium.org,mseaborn@chromium.org
BUG=302040

Review URL: https://codereview.chromium.org/238123003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263941 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 05b59c9d55924996b24f13785d2f15276078bb94
diff --git a/base/base.gyp b/base/base.gyp
index 0663b27..0e3e265 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -986,6 +986,32 @@
         }],
       ],
     },
+    {
+      'target_name': 'sanitizer_options',
+      'type': 'static_library',
+      'toolsets': ['host', 'target'],
+      'variables': {
+         # Every target is going to depend on sanitizer_options, so allow
+         # this one to depend on itself.
+         'prune_self_dependency': 1,
+         # Do not let 'none' targets depend on this one, they don't need to.
+         'link_dependency': 1,
+       },
+      'sources': [
+        'debug/sanitizer_options.cc',
+      ],
+      'include_dirs': [
+        '..',
+      ],
+      'cflags!': [
+        '-fsanitize=address',
+      ],
+      'direct_dependent_settings': {
+        'ldflags': [
+          '-Wl,-u_sanitizer_options_link_helper',
+        ],
+      },
+    },
   ],
   'conditions': [
     ['OS!="ios"', {