From 4e4b42ec036b1bda45879c1c4141b56106546373 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Thu, 7 Apr 2016 14:40:10 +0900 Subject: [PATCH] Efl: Add internal strong symbol to fix build on GCC < 5.3 This fixes a crash in ecore_init, calling a weak function from libefl that was resolved to NULL. So, here's a fun thing happening with GCC < 5.3. Since a1a506e13e2 all EOAPI and EO class_get() functions are weak symbols. This means that all APIs inside libefl.so are weak. As a result, gcc linker with --as-needed skipped linking to libefl since not a single strong symbol from libefl was required by libecore. This is actually a bug in gcc linker since we do in fact use symbols from libefl, just weak ones. GCC 5.3 seems to be fixed, so people with GCC 5.3+ will not experience any build/runtime issue. The current patch is a workaround that bug, by artifically creating a strong symbol required by ecore. Other libraries than ecore might also need to call __efl_internal_init, if they end up not being linked to libefl. --- src/lib/ecore/ecore.c | 3 +++ src/lib/efl/Efl.h | 3 +++ src/lib/efl/interfaces/efl_interfaces_main.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index d7eead345d..6c326a7f3c 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -210,6 +210,9 @@ ecore_init(void) if (++_ecore_init_count != 1) return _ecore_init_count; + /* make sure libecore is linked to libefl - workaround gcc bug */ + __efl_internal_init(); + setlocale(LC_CTYPE, ""); /* if (strcmp(nl_langinfo(CODESET), "UTF-8")) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 2002ebc7e8..4cc909aa5c 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -119,6 +119,9 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; #endif +/* work-around bug in gcc --as-needed link optimization */ +EAPI void __efl_internal_init(void); + #if defined ( __cplusplus ) } #endif diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 908e2287df..68ff6f315c 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -37,3 +37,9 @@ EAPI const Eo_Event_Description _EFL_GFX_PATH_CHANGED = #include "interfaces/efl_animator.eo.c" #include "interfaces/efl_orientation.eo.c" #include "interfaces/efl_flip.eo.c" + +EAPI void +__efl_internal_init(void) +{ + /* nothing to do, the symbol only is required for link to work */ +}