Why is `main.o` installed?
LiberalArtist opened this issue · 3 comments
I noticed that main.o
is installed, e.g. as /usr/lib/csv9.5.8/ta6le/main.o
. I see that this was done intentionally in fd7812d, but it's not clear to me why or what it is useful for. Grepping the repository only turned up the changelog entry and the code in bintar.zuo
and install.zuo
that installs it.
I think the idea is to let user build a scheme executable with extra C functions linked to libkernel.a and main.o, without the need to distribute the user extended C functions as a separate dynamic library file.
I think the idea is to let user build a scheme executable with extra C functions linked to libkernel.a and main.o, without the need to distribute the user extended C functions as a separate dynamic library file.
Interesting! I can see how that would work, though I wouldn't have thought of that approach.
Does anyone know of other software that distributes something similar to this main.o
file?
So (on macOS)
cc libz.a liblz4.a libkernel.a main.o -o foo -liconv -lncurses
would produce an executable works identical to petite
or scheme
, without need to access the source code. I think this design was settle down long before when Chez was still closed source and the distribution of main.o
is only for completeness, and to create binary executable if any of the linked shared libraries, for example ncurses, on the target system changes, without need to request a new binary from software vendor.
Also it is worth mention the version 7 user guide already mentioned the kernel can be a shared library. The program might have been distributed for some now obscure UNIX variants so it is very likely the case why object files are included when sources aren't available since while the object file format can be compatible the system shared libraries might not be the same.
https://www.scheme.com/csug7/use.html#./use:h7
My other conjecture about making additional C code was probably never be applied in reality since it still requires some hack to hook additional code into the main function to register C functions to the runtime to make them available to Scheme.