-
Notifications
You must be signed in to change notification settings - Fork 29
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
Allow the compiler to be called from any directory #16
Comments
Remainder: update readme when done. |
I don't this this is an issue for the dev version. |
Even for the dev version, being effectively restricted to only running code inside the root directory is a big limitation. It is certainly affecting how we write our benchmark and test scripts. (See #17) I agree that properly installing pallene via luarocks is the way to go. In fact, figuring out how to do so is exactly why I opened this issue in the first place :) |
I've been thinking about this problem and I think the tricky bit is going to be the Pallene runtime library. Currently we have a custom Lua interpreter and a runtime library (pallenelib). In theory we could merge one of them into the other but in any case we will need a runtime library component and that brings two problems
So what do you think about having a separate installer for the Pallene compiler and for the Pallene runtime library? The Pallene compiler can continue as a Luarocks module. Luarocks knows how to install it and also takes care of installing our Lua dependencies. For the Pallene runtime library, we would take our existing makefile and add a |
To solve this issue for good I think we will need to clean up the situation with the pallene runtime library and the custom Lua interpreter. I investigated what private Lua functions we are currently using. For the record, this is the list that I got after running
|
The runtime library could be a
This seems strange. Can't we handle everything inside Luarocks? Also, I'd rather not mix compilation and installation in the same makefile. Compilation is usually generic and unix-portable; installation isn't.
We could merge both. If I recall correctly, this is what Titan is doing. I don't think that we will have any issues. If we choose this path, I think it is important to automate the process of extracting the functions that we need from the Lua interpreter and bundling them to our runtime library. |
We would need to use package.loadlib("*") instead of require. By default, require calls dlopen with a flag that hides the non-luaopen symbols in the shared library. To do that we would also need to pass the full path to the lua library. I think you find that like this but it needs the
Luarocks is geared towards installing Lua modules and the pallenelib is not a Lua module. I think it can be done if you really want to but it is a bit unwieldy. Annyway, I'm not sure that installing pallene lib separately would be that bad. There is the precedent of those luarocks modules that are a wrapper to some other system library (ex.: expat, sqlite, etc). Usually you need to install those libraries through your system's package manager.
I think that can be a good thing. I would rather have the system-specific installation directory stuff in the makefile than inside c_compiler.lua or our generated luaopen functions. For what it is worth, the plan would be to tell the makefile to install to /usr/local hand have it be configurable with DESTDIR and the other usual
IIRC Titan always statically links a copy of liblua into the Titan-generated binaries. There is as also some sr.lua stuff to be able to generate a self-sufficient executable file instead of an ".so" library. But I don't understand that part very well. |
We could use package.searchpath to find the library, no?
I'd rather hide this from the final user. Moreover, our runtime lib isn't quite a system library, it is very specific to our compiler.
Yes, but I meant that Titan also statically links the Lua functions it needs against the generated module. We could dynamically link everything we need (runtime library and Lua functions). |
I hadn't thought about the package.searchpath. That could certainly help. We'd still need to solve the issue of the internal Lua header files but that is easier than the dynamic library problem. |
This set of commits gets rid of the separate pallenelib library. This is part of the ongoing effort to simplify the build and installation process for Pallene (see #16, #153). The pallene_core files are now going to be part of our the custom installation of Lua. Unfortunately, for some reason it is not working. When I compile the custom Lua, the `pallene_symbols` are not being exported by the custom Lua executable. We'll need to figure out what is the problem. TODO: - [] Find out why the symbols are not being exported - [] Fix compilation warnings that appeared because of -Wextra - [] Update the ".patch" file we use when updating to a new Lua version - [] Delete the "runtime" folder, and - [] Update the installation instructions in the README.
This set of commits gets rid of the separate pallenelib library. This is part of the ongoing effort to simplify the build and installation process for Pallene (see #16, #153). The pallene_core files are now going to be part of our the custom installation of Lua. Unfortunately, for some reason it is not working. When I compile the custom Lua, the `pallene_symbols` are not being exported by the custom Lua executable. We'll need to figure out what is the problem. TODO: - [] Find out why the symbols are not being exported - [] Fix compilation warnings that appeared because of -Wextra - [] Update the ".patch" file we use when updating to a new Lua version - [] Delete the "runtime" folder, and - [] Update the installation instructions in the README.
This set of commits gets rid of the separate pallenelib library. This is part of the ongoing effort to simplify the build and installation process for Pallene (see #16, #153). The pallene_core files are now going to be part of our the custom installation of Lua. Unfortunately, for some reason it is not working. When I compile the custom Lua, the `pallene_symbols` are not being exported by the custom Lua executable. We'll need to figure out what is the problem. TODO: - [] Find out why the symbols are not being exported - [] Fix compilation warnings that appeared because of -Wextra - [] Update the ".patch" file we use when updating to a new Lua version - [] Delete the "runtime" folder, and - [] Update the installation instructions in the README.
Exciting news! This commit cleans up the way we install Pallene and resolves several long-standing issues: * Closes #16 * Closes #18 * Closes #153 Now Pallene can be installed like a regular Luarocks package, using `luarocks make`. To achieve this I did two things: get rid of #include directives in the generated C code, and get rid of the custom Lua interpreter. Include directives were annoying because they meant you had to pass the right "-I" flags when you compiled the generated C code. Also, we never figured out a good place to install the headers in the first place, which was one of the reasons for #16... My approach to solve this problem was to get rid of the #include directives completely, fully expanding the header files. This required introducing a code generation step to build the Pallene library. The main thing that motivated me to get rid of the custom Lua is because a custom Lua also implies a custom Luarocks, and I wanted to make things as easy as possible to install via Luarocks. The catch, however, is that we have a requirement saying that Lua needs to be exactly 5.4.4. This is OK if you're using Fedora, which always has the latest Lua, but on most other distros you're might need to install Lua from source... To make things less magical and more compatible with Luarocks, we implemented the Pallene runtime library as a struct of function pointers, stored inside an userdata and installed in an extention module that can be required. This design, without "extern" functions, completely bypasses the C linker. We no longer need to worry about that passing the right linker flags to the compiler, and we can get rid of the "linker hack" that we had added to lapi.c. All in all, the C files we generate are now a bit more verbose, but I think it is for the better.
Currently,
pallenec
only works if the current directory is the root project directory. If we try to call it elsewhere it fails for the following reasons:require
can't find the modules in the titan-compiler subdirectory. (LUA_PATH issue)The text was updated successfully, but these errors were encountered: