Statically compiling libraries and Lua modules #80
Comments
|
I started a new LuaDist/lua@new_dist_structure with some significant modification to The use case when static and shared libraries are defined it is not directly supported in CMake and I do not want to complicate things too much. So I prefer to look into this later, hopefully CMake will support it to make it easier. Statically linking lua modules would be great and your suggested approaches sound good. I don't see a problem to add support to the new I leave this open as long as there are modules with hardcoded SHARED libraries. |
|
Looks ok. I pushed some minor changes. I think tests (with |
|
Yes, CDash is a bonus. For now I made a simple Wiki Status page that I abuse as sort-of CDash. As for tests ... they seem to be disabled in the |
|
I tried the approach @davidm mentioned and modified the lua.cmake macro to support a LUA_STATIC_MODULE option. With this option on, lua modules will be compiled statically and placed in the same location as dynamic modules. However I have also modified Lua (branch static) to search for these modules and link them in. The process automatically generates all |
|
Hi @drahosp |
|
This feature requires some additional infrastructure, while I have implemented almost everything that is needed for this to go live. I still need to make a tool that uses 'luadist-git' to generate CMake builds that use 'external_project_add'. This would basically generate a CMake super project that would link every modules statically. It is possible to link binded libraries in also but that is limited by their respective licenses. Sorry, there is currently no documentation on this feature as it still requires significant work in order to make it usable with simple instructions. |
|
Thanks for the detailed info and keep up the great work! Is the static branch of the lua5.1 repo in a usable state? Ie does it build a lua.a and static lua executables? |
|
No it is not, it is an old WIP branch that I used to transfer changes to be tested on multiple machines/architectures. I will remove it so it does not cause further confusion. |
|
The automated static build feature sounds great. It can save a lot of time when one tries to create a static build of lua+some set of packages. |
|
@drahosp |
|
Sadly due to my time constraints, this feature never managed to end up in the project. There is no development on the LuaDist project for more than 3 years now. Sorry. |
STATIC/SHARED/MODULE in add_library override BUILD_SHARED_LIBS, which in turn seems to default to false. Therefore I think it may be a bad idea to hardcode
add_library(... SHARED ...)in CMakeLists.txt files in general. We may want to instead use some wrapper function in dist.cmake that will select either shared or static based on a global user preference. Sometimes both are even wanted, which sometimes complicates things.Also note that some toolchains (e.g. sdcc -- sdcc.sourceforge.net) don't support building shared libraries, so it will force STATIC regardless, as this cmake warning shows: "ADD_LIBRARY for library foo is used with the SHARED option, but the target platform supports only STATIC libraries. Building it STATIC instead. This may lead to problems."
The above concerns C libraries in general. Statically linking modules for any language we support (e.g. Lua) is a separate question. Probably we would want some mechanism to package.preload them in linit.c (note: the 5.2 version handles this more correctly). I'm thinking the compilation order would be this: (1) build a vanilla interpreter without modules, (2) build static libraries of modules, and (3) build another interpreter using #2. Step #3 can be repeated any number of times (as different variants) for various combinations of #2, and you may iterate back-and-forth between #2 and #3. Related possibilities include compiling source modules to C libraries via bin2c for linking in #3 as a single file, like various bundling utilities have done, so this overlaps those efforts. Anyway, I don't see obstacles here provided each static library publishes the package names of its modules and the symbol names of its registration functions in some standard way (actually you can probably infer the latter from the former, and the former are already in the CMakeLists.txt).
The text was updated successfully, but these errors were encountered: