I would like to be able to build a shared library/DLL that only exports the C-API and hides everything else (either as part of LLVM/MLIR itself or as part of a larger project). I believe the relatively normal way to do this for this kind of project is something like:
- On Windows:
declspec(dllexport)to functions if building a library
declspec(dllimport)to functions if depending on a library
- On Others:
- Build the project with
There are many things and permutations that can be done if such annotations are applied correctly, and as a first step, we should decide on the macro and use it appropriately.
Libcxx has more complicated needs, but the basic structure and knobs from
libcxx/include/__config provides the right recipe. I propose adding a
_MLIR_CAPI_EXPORTED macro to a new
mlir-c/Config.h and defining it roughly like the
libcxx macro is defined (above). We can elaborate on the knobs and additional build setup to fully leverage it later.