summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertise.dev>2020-12-14 13:09:36 -0300
committerFelipe Magno de Almeida <felipe@expertise.dev>2020-12-14 13:27:53 -0300
commit2368d2708965e77e39b3e8ae9def9a1d43a5a685 (patch)
treefd830431f3f2625569fa538a4e18844728fde9ce
parent300686e153ac516dfb31b3800201528e6660a138 (diff)
downloadefl-2368d2708965e77e39b3e8ae9def9a1d43a5a685.tar.gz
eina: Use EXPORTAPI for macro EINA_MODINFO
The EINA_MODINFO must export the symbols in the current module, and it is not used for importing symbols so we can use EXPORTAPI to export without needing to know what is being built. Patch from a series of patches to rename EAPI symbols to specific library DSOs. = The Rationale = This patch is from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass `__attribute__ ((visibility ("default")))` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as `__atttribute__((visibility("default")))`. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why LIBAPI is the only solution that works for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
-rw-r--r--src/lib/eina/eina_inline_modinfo.x2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/eina/eina_inline_modinfo.x b/src/lib/eina/eina_inline_modinfo.x
index a53de0a4a8..e3b5066301 100644
--- a/src/lib/eina/eina_inline_modinfo.x
+++ b/src/lib/eina/eina_inline_modinfo.x
@@ -24,7 +24,7 @@
#define __EINA_MODULE_UNIQUE_ID(id) _EINA_MODINFO_CONCAT(__EINA_MODULE_UNIQUE_ID_, id)
#define _EINA_MODINFO(name, info) \
- EAPI const char __EINA_MODULE_UNIQUE_ID(name)[] \
+EXPORTAPI const char __EINA_MODULE_UNIQUE_ID(name)[] \
__attribute__((__used__)) __attribute__((unused, aligned(1))) = info;
#define EINA_MODINFO(tag, info) _EINA_MODINFO(tag, info)