Fix TracingCategory::kNavigation GOLD linking problems.
Patch ae49e297, "Add tracing to ClassifyNavigation to make debugging easier." introduced the following code: struct TracingCategory { static constexpr const char kNavigation[] = "navigation"; }; This looks fine at first glance, but has one subtle problem that the author of the code might not have been aware of. In C++14 (which is currently used by chomium) a static constexpr member variable (unlike other global constexpr variables) has an external linkage. This is not really intuitive and is probably why it was fixed in C++17, where such static constexpr member is inline. The interesting part is this subtle difference in linking semantics breaks component builds when using GOLD linker instead of LLD. obj/content/browser/browser/navigation_controller_impl.o(.debug_addr+0x858): error: undefined reference to 'content::TracingCategory::kNavigation' To fix this lets just convert TracingCategory from struct into a namespace. This way it should be inlined no matter which version of the C++ standard the compiler is instructed to adhere to. Ref: https://en.cppreference.com/w/cpp/language/constexpr Change-Id: Ibf0471eaf20805cc7af8236386aa7c5318d26f4c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436824 Commit-Queue: Nasko Oskov <nasko@chromium.org> Reviewed-by:Nasko Oskov <nasko@chromium.org> Reviewed-by:
Alexander Timin <altimin@chromium.org> Cr-Commit-Position: refs/heads/master@{#812257}
Showing
Please register or sign in to comment