From 3332be3b65b57fe6e48412a6b7f187fd5c625d17 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 29 Jul 2022 12:21:17 -0400 Subject: [PATCH] Change the 'libcef_static' target type from static_library to source_set Using a source_set here keeps the linker on Windows from discarding exported compilation units that are not directly called from inside libcef_static. This may also fix linker errors on Linux due to CEF's use of an intermediate static library (see https://crbug.com/1319006#c2). --- BUILD.gn | 2 +- libcef/common/alloy/alloy_main_delegate.cc | 9 --------- libcef/common/base_impl.cc | 13 ------------- libcef/common/time_impl.cc | 13 ------------- 4 files changed, 1 insertion(+), 36 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 4b17a4b92..62c28322a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -406,7 +406,7 @@ test("libcef_static_unittests") { ] } -static_library("libcef_static") { +source_set("libcef_static") { sources = includes_common + gypi_paths.autogen_cpp_includes + [ "libcef/browser/alloy/alloy_browser_context.cc", diff --git a/libcef/common/alloy/alloy_main_delegate.cc b/libcef/common/alloy/alloy_main_delegate.cc index 5e7c599b1..ad379664b 100644 --- a/libcef/common/alloy/alloy_main_delegate.cc +++ b/libcef/common/alloy/alloy_main_delegate.cc @@ -73,15 +73,6 @@ AlloyMainDelegate::AlloyMainDelegate(CefMainRunnerHandler* runner, CefSettings* settings, CefRefPtr application) : runner_(runner), settings_(settings), application_(application) { - // Necessary so that exported functions from base_impl.cc will be included - // in the binary. - extern void base_impl_stub(); - base_impl_stub(); - // Necessary so that exported functions from time_impl.cc will be included - // in the binary. - extern void time_impl_stub(); - time_impl_stub(); - #if BUILDFLAG(IS_LINUX) resource_util::OverrideAssetPath(); #endif diff --git a/libcef/common/base_impl.cc b/libcef/common/base_impl.cc index d0508704f..6853046cc 100644 --- a/libcef/common/base_impl.cc +++ b/libcef/common/base_impl.cc @@ -22,19 +22,6 @@ constexpr const char kCategory[] = "cef.client"; } // namespace -// The contents of this file are a compilation unit that is not called by other -// functions in the the library. Consiquently MSVS will exclude it during the -// linker stage if we don't call a stub function. -#if defined(COMPILER_MSVC) -#pragma optimize("", off) -#endif - -void base_impl_stub() {} - -#if defined(COMPILER_MSVC) -#pragma optimize("", on) -#endif - CEF_EXPORT void cef_trace_event_instant(const char* /* category */, const char* name, const char* arg1_name, diff --git a/libcef/common/time_impl.cc b/libcef/common/time_impl.cc index e41e92a80..af3d914ce 100644 --- a/libcef/common/time_impl.cc +++ b/libcef/common/time_impl.cc @@ -9,19 +9,6 @@ #include #include -// The contents of this file are a compilation unit that is not called by other -// functions in the the library. Consiquently MSVS will exclude it during the -// linker stage if we don't call a stub function. -#if defined(COMPILER_MSVC) -#pragma optimize("", off) -#endif - -void time_impl_stub() {} - -#if defined(COMPILER_MSVC) -#pragma optimize("", on) -#endif - #if BUILDFLAG(IS_WIN) namespace {