Export fontconfig symbols when using instrumented libraries
This fixes an issue where Chrome would launch in msan with gLinux, but the first
time the user types anything into the omnibox, Chrome would hang for several
minutes. The hang was happening because the fontconfig caches were getting
regenerated for an older version of fontconfig. See the detailed explanation
added in BUILD.gn.
BUG=1017974
R=thakis
Change-Id: I50f4c757a3fc66250f348129c03990eba9546a42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880587
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709992}
diff --git a/third_party/fontconfig/BUILD.gn b/third_party/fontconfig/BUILD.gn
index 3175758..2f93387 100644
--- a/third_party/fontconfig/BUILD.gn
+++ b/third_party/fontconfig/BUILD.gn
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/sanitizers/sanitizers.gni")
import("//third_party/fontconfig/fontconfig.gni")
assert(is_linux)
@@ -58,8 +59,25 @@
]
# Fontconfig symbols should not be exported from chrome, nacl_helper, or
- # anything else.
- if (!is_component_build) {
+ # anything else. However, if using the instrumented libraries, we do want to
+ # export fontconfig symbols: in this configuration, there are 3 different
+ # fontconfigs: this one, the one from instrumented_libraries, and the one
+ # from the system. Only the first two get loaded: this one from Chrome, and
+ # the one in instrumented_libraries indirectly through eg. gtk -> cairo ->
+ # fontconfig. The latter is a different version of fontconfig with a
+ # different cache file format. Therefore, the caches would have to get
+ # regenerated every time Chrome runs for this other version. Depending on
+ # how many fonts the user has installed, this could take several minutes,
+ # especially for msan builds. Exporting the newer fontconfig symbols here
+ # will ensure that cairo uses this fontconfig, and so avoids the caching
+ # issue. In non-instrumented builds, it is ok that the real system
+ # fontconfig is used by cairo instead of chromium's because caches for that
+ # are warm. We don't *always* export fontconfig because in a rare case, it's
+ # possible for the system fontconfig to be newer and have some Foo() that's
+ # not in ours. Then eg. cairo would call init functions from our fontconfig
+ # and then Foo() from the system fontconfig and crash.
+ if (!is_component_build && !(use_prebuilt_instrumented_libraries ||
+ use_locally_built_instrumented_libraries)) {
defines += [
"FC_ATTRIBUTE_VISIBILITY_HIDDEN=__attribute((visibility(\"hidden\")))",
"FC_ATTRIBUTE_VISIBILITY_EXPORT=__attribute((visibility(\"hidden\")))",