-
Notifications
You must be signed in to change notification settings - Fork 94
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
Explicit Symbol Exports #2136
Comments
From LD-Version-Scripts
We should investigate if the more portable solution is possible. Otherwise, we can't build on Alpine linux, and potentially not on MacOS(?). |
It seems the portable solution is a file that lists all symbols to export. I am in favor of this solution, because it's very explicit and we have to explicitly specify when we want to export new symbols (and we don't do this very often, afaik). |
With a growing and unstable API, we might do it a little more frequently than is convenient, but as long as there's a relatively easy way to get the symbol names I don't think it should be a huge issue (at the moment all I can think of is grepping There's also the And another interesting option I just saw is extracting the object files from the static libraries (see https://stackoverflow.com/a/2251477) and adding them directly, which will make them be affected by |
Interesting. I wonder how easy the last thing is to integrate into cmake. |
Updates from today:
As for the mentioned issue about building precompiled headers & library in CMake, I don't see anything easy to do that, though we could integrate our existing script into a Tasks:
|
I think for the existing API tests we'll probably want to more or less re-write the DBTest class to use only public APIs (or otherwise re-write the API tests to simplify them). There are too many private APIs being used, and they are too closely related to the public ones. E.g. if it was just stuff like StringUtils, we could create a separate static StringUtils library, which is relatively unrelated to the APIs used in the API tests and shouldn't give any linking issues or false positives for API coverage, but the test runner, for example, uses |
Sounds good to me. It'd be good to have someone look at that class (I think it's been a while since anyone has). I'm going to prepare a PR for stripping symbols and using CMake install. |
This was causing ASAN failures on macOS (see #2204). |
What?? How? Can we find a solution that's better than "disable explicit exports"? |
I don't really understand why it's occurring, so I'm not really sure what we can do beyond disabling it on macOS at the moment. Interestingly, linking against the shared library is also meaning that spdlog is not producing output in the API tests (when the calls are from within the kuzu code in the shared library; using spdlog in the test code works as expected). |
Exception information necessary for properly catching exceptions, seems to not be exported on Mac unless we export the exception, which seems to be different from Linux & Windows. In additional, Mac issues a warning when building the Python module (which itself builds as a shared library). The issue is that the python module links with our static library, and the static library does not export symbols (since it doesn't do anything for static libraries). However, this mismatch in visibility causes a warning. Technically, we shouldn't build a shared library with a static library since the static library isn't position-independent code, but we don't really have other options unless we embed all of the object files? My current solution is to keep the visibility annotations in the static library, which seems to work fine and avoids the warning. However, we should probably find some other solution. Embedding all of the object files isn't super appealing from a design perspective but seems the easiest. It'd be great to embed the shared library.. but that would require some changes to how we package for python, and I haven't looked into it. Ref #2136.
Exception information necessary for properly catching exceptions, seems to not be exported on Mac unless we export the exception, which seems to be different from Linux & Windows. In additional, Mac issues a warning when building the Python module (which itself builds as a shared library). The issue is that the python module links with our static library, and the static library does not export symbols (since it doesn't do anything for static libraries). However, this mismatch in visibility causes a warning. Technically, we shouldn't build a shared library with a static library since the static library isn't position-independent code, but we don't really have other options unless we embed all of the object files? We should probably link the python library against `libkuzu.so` and ship it alongside the python bindings. However, this will be delayed until after the release. Ref #2136.
Exception information necessary for properly catching exceptions, seems to not be exported on Mac unless we export the exception, which seems to be different from Linux & Windows. In additional, Mac issues a warning when building the Python module (which itself builds as a shared library). The issue is that the python module links with our static library, and the static library does not export symbols (since it doesn't do anything for static libraries). However, this mismatch in visibility causes a warning. Technically, we shouldn't build a shared library with a static library since the static library isn't position-independent code, but we don't really have other options unless we embed all of the object files? We should probably link the python library against `libkuzu.so` and ship it alongside the python bindings. However, this will be delayed until after the release. Ref #2136.
Exception information necessary for properly catching exceptions, seems to not be exported on Mac unless we export the exception, which seems to be different from Linux & Windows. In additional, Mac issues a warning when building the Python module (which itself builds as a shared library). The issue is that the python module links with our static library, and the static library does not export symbols (since it doesn't do anything for static libraries). However, this mismatch in visibility causes a warning. Technically, we shouldn't build a shared library with a static library since the static library isn't position-independent code, but we don't really have other options unless we embed all of the object files? We should probably link the python library against `libkuzu.so` and ship it alongside the python bindings. However, this will be delayed until after the release. Ref #2136.
It should be feasible to remove We'd also discussed at one point renaming |
I think overall it would be better to be more diligent about what our API actually is instead of hacking it into our C++ codebase. Our C++ API should, ideally, be more similar to our C API instead. This should be much more stable and lightweight. |
That's true, but on the other hand, kuzu.hpp is already ~6000 lines of code. Even if we were to hand-write it and omit as much internal stuff as possible, it's still probably going to be much larger than the C API header (~1000 lines of code), so we might still want to have a way to collect the files together. And there are also headers which can probably be shared between internal code and the API, like a lot of the stuff in |
I agree that a lot of code should be shared. The current generation is opaque. When a symbol is missed, there isnt a clear way to solve it, and it's easy to forget to include symbols, as we saw. We also have a lot of inline code that is in the header and exported that really need not be. It's just not a good design. |
Closing as this has been more or less finished. |
In #2118 we switched from exporting all symbols on Windows to explicit export of symbols to avoid hitting the limit in a single windows dll. This change would have a number of benefits on other platforms too (smaller dynamic libraries, faster library loading, no accidental use of private APIs), and needs to be more rigorously tested.
TODO:
kuzu*
to filter everything not in the kuzu namespace (or C functions prefixed withkuzu_
).The text was updated successfully, but these errors were encountered: