Of course, I can write a patch for gp to add this feature. Any suggestions for the switch to use ?
Certainly a long name as there are already so many short names, and we should allow for future additions in the backend (as far as they'll make sense with gp). Perhaps something like `--create-shared-library=foo.so.1.2.3'. But that's really the least problem.
An option --create-shared-library would be nice, of course, but I understand that it can be a problem, at least across platforms. So, I were really only thinking of sending in a patch that implements a --compile-and-link option that overrules the automatic -c option for units, that's all (a five minute hack).
Given that option, It is no problem to create a dynamic library on Mac OS X with Darwin specific compiler options, like -dynamiclib (see <http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Darwin- Options.html#Darwin-Options>). I checked this morning that gpc can actually create a dynamic library with one call (!). Through the specs, gpc invokes libtool and it creates the dynamic library (there was indeed a problem left but that's another issue that I still have to look at).
With gp, this is currently impossible, because of the automatic -c for units (which I agree is a good thing to have as default).
The included patch adds --compile-and-link to gp. I hope it's acceptable. It nicely creates a dynamic library on Mac OS X from a unit (while passing some extra needed options of course). Even better, the problem that I encountered this morning while trying this with gpc (.o files of compiled units weren't linked in) doesn't occur with gp !
Waldek Hebisch wrote:
As far as I know, the opposite switch is not available, namely to compile *and link* a unit. This is useful when compiling a unit into a shared library, while still using the specs file instead of a separate ld run (which could be less compatible).
Why do not you link shared library as a program (using `-fgpc-main=' option)? At first glance this should avoid most problems with shared libraries.
At first sight, that looks somewhat strange (conceptually), because a library is a collection of routines, like a unit, not a program. Still, I will experiment with it, thanks for the hint.
Regards,
Adriaan van Os