On Windows builds, we currently require _LIBCPP_DLL to be specified in
order for dllexport/dllimport annotations to be generated. I believe
it's better to do the opposite, i.e. require a macro to be present in
order to *not* include the annotations, since building libc++ shared is
more common.
The problem with having the DLL annotations be opt-in is that any
project using the libc++ headers and linking against a libc++ DLL must
specify _LIBCPP_DLL in its build system, otherwise the libc++ headers
will not be annotated with dllimport. This lack of annotation will then
cause inefficient code generation, since the linker will generate import
thunks. No compile-time errors will be reported (except in the case of
data symbols, for which import thunks are not possible) about this
inefficient code generation.
In contrast, having the DLL annotations be opt-out means that any
project using the libc++ headers and linking against a static libc++
will fail to link with missing import table entries if the project
forgets to specify the macro to suppress DLL annotations. Link errors
seem far preferable to silent inefficient code generation.