[fpc-devel] RTL make shared

Sven Barth pascaldragon at googlemail.com
Tue Oct 29 20:09:26 CET 2024


Adriaan van Os via fpc-devel <fpc-devel at lists.freepascal.org> schrieb am
Di., 29. Okt. 2024, 15:47:

> Sven Barth via fpc-devel wrote:
> > Adriaan van Os via fpc-devel <fpc-devel at lists.freepascal.org
> > <mailto:fpc-devel at lists.freepascal.org>> schrieb am Di., 29. Okt. 2024,
> > 11:29:
> >
> >     Trying to build the FPC RTL as a dynamic library on MacOS (with make
> >     shared), I run into several
> >     problems
> >
> >
> > I don't know when that was tested last in any platform...
>
> Thanks for the reply.
>
> Isn't this related to library packages ?
>

No, not really. This is essentially forcefully moving code into a library
and this only works on *nix platforms. With dynamic packages much more
metadata is involved, because the runtime can then check whether packages
are compatible.


> >
> >
> >     2. When I do the linking pass by hand, ld complains about unknown
> >     symbols
> >
> >     ld: Undefined symbols:
> >        FPC_RESLOCATION, referenced from:
> >            _TC_$SYSINIT_$$_SYSINITENTRYINFORMATION in sysinit.o
> >        FPC_RESOURCESTRINGTABLES, referenced from:
> >            _TC_$SYSINIT_$$_SYSINITENTRYINFORMATION in sysinit.o
> >        FPC_RESSTRINITTABLES, referenced from:
> >            _TC_$SYSINIT_$$_SYSINITENTRYINFORMATION in sysinit.o
> >        FPC_THREADVARTABLES, referenced from:
> >            _TC_$SYSINIT_$$_SYSINITENTRYINFORMATION in sysinit.o
> >        INITFINAL, referenced from:
> >            _TC_$SYSINIT_$$_SYSINITENTRYINFORMATION in sysinit.o
> >        _PASCALMAIN, referenced from:
> >            _TC_$SYSINIT_$$_SYSINITENTRYINFORMATION in sysinit.o
> >        __stklen, referenced from:
> >            _SYSINIT_$$_FPC_SYSTEMMAIN$LONGINT$PPANSICHAR$PPANSICHAR in
> >     sysinit.o
> >
> >
> > sysinit should be part of the program, not the library.
>
> The idea of building the RTL in a dynamic ibrary is to have one copy of
> the RTL threadvars, notably
> one copy of the _ExceptObjectStack threadvar. Will this still be true if a
> main program and a
> dynamic library both include sysinit.o ?
>

The sysinit unit contains the entrypoint and directly references symbols
provided by the main program, not the RTL, to pass them into the RTL. It
simply can't be inside a library. The exception handling is inside the
System and SysUtils units, so no conflict there.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20241029/0cf7dc67/attachment.htm>


More information about the fpc-devel mailing list