[cfe-dev] [PATCH] Libc++ Windows fixes

Howard Hinnant hhinnant at apple.com
Sun Sep 25 10:50:18 PDT 2011


On Sep 25, 2011, at 1:24 PM, Ruben Van Boxem wrote:

> There is still an unanswered (by Howard or anyone else that feels like he can make high-impact decisions): How will the Windows DLL exports be marked in libc++? The simplest would be something like this:
> #if defined _LIBCPP_DLL
> #ifdef _BUILDING_LIBCPP
> #define _LIBCPP_API __declspec(dllexport)
> #else
> #define _LIBCPP_API __declspec(dllimport)
> #endif
> #else
> #define _LIBCPP_API
> #endif
> 
> and *every* symbol/class marked with these macros. The problem with this is that _LIBCPP_DLL needs to be defined when linking user programs to libc++. The alternative is creating/maintaining a .def file listing all the exports. This also allows for better ABI backwards-compatibility and is done by libstdc++. The problem with this approach is 1) getting a list of all these symbols, 2) maintaining this list when ABI changes, and 3) MSVC and MinGW/GCC/Clang mangle C++ in different ways. A third and the least refined way is using --export-all-symbols when linking the libc++ DLL. I do not know if this works though (testing it now). All this nonsense has also been resolved recently in LLVM/Clang, and perhaps libc++ can copy their approach, if such a user-library approach makes sense for a runtime library like libc++.

See:

http://gcc.gnu.org/wiki/Visibility

I'd like to try and use the above approach.  libc++ has different spellings for the macros than indicated in the above link:

_LIBCPP_HIDDEN  / DLL_LOCAL
_LIBCPP_VISIBLE / DLL_PUBLIC

Also relevant is:

_LIBCPP_EXCEPTION_ABI
_LIBCPP_ALWAYS_INLINE
_LIBCPP_INLINE_VISIBILITY

The last two are nothing but mistaken duplicates of each other.  On my to-do list is to turn these last two macros into one.

Howard




More information about the cfe-dev mailing list