-
-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use an in-tree header for symbol export information #453
base: master
Are you sure you want to change the base?
Conversation
Found via mesonbuild/wrapdb#719 |
@nwellnhof what do you think? |
CMake handles a few more compilers besides gcc and I don't see why visibility should be set for static libraries. CMake doesn't seem to support Solaris, though. The more important point is that using GenerateExportHeader makes it impossible to use other build systems, so +1 to the change. The
|
I think we still support building both static and shared libraries, so the following check seems wrong:
This should probably be |
@nwellnhof I'll defer to your judgment on this. Do you want to suggest a specific change to this PR, or a new PR on top of it? |
What does "support" mean? What compilers are you referring to? CMake only supports two styles, that being GCC style and MSVC style, and it checks for some compilers that are too old or shouldn't support it before skipping a compiler test to see if the compiler supports it. For context, here's what GenerateExportHeader does, and here's what my PR does:
The implementation of these steps is a bit different:
... I am not positive but I think the
Yes, visibility should ideally be set for static libraries if the platform supports it. It allows the compiler to generate optimized code, and there are cases where you think you're building a static library but the user is, for example, planning to merge those static archives together into a fat library for some custom deployment (using link_whole).
The idea behind this check was originally that:
So I think that the check is correct as is, although the comments below apply to it.
Of course, indeed this whole block of code isn't needed. Other projects simply need to have static_define passed whenever linking to the static library, and this can be provided via pkg-config or *-config.cmake If you'd prefer that I can make that change. |
Yup, my bad, dumb typo when merging code across repos. Will fix it as soon as I'm sure of the best way to incorporate the other feedback. |
Fair enough.
Right, if By the way, if you really want to support Solaris' C compiler, you'll probably have to set a compiler option equivalent to |
Relying on CMake's GenerateExportHeader produces a file that is longer than the one being added here, which for all that is just mostly defining macros not used here. And after all that, it only contains macros specific to a single compiler, while failing to consistently handle GNUC (that always supports symbol visibility even for static libraries). Replace this with a more targeted header that is easy to read or include into external build systems, and which is also more robust than the one that only exists inside CMake.
cb2ed66
to
d384a5b
Compare
Relying on CMake's GenerateExportHeader produces a file that is longer than the one being added here, which for all that is just mostly defining macros not used here. And after all that, it only contains macros specific to a single compiler, while failing to consistently handle GNUC (that always supports symbol visibility even for static libraries).
Replace this with a more targeted header that is easy to read or include into external build systems, and which is also more robust than the one that only exists inside CMake.