[fpc-devel] fpc libraries do not work in freeBSD...

Fred van Stappen fiens at hotmail.com
Tue Aug 5 23:03:09 CEST 2014

> Because they essentially have a shared RTL in libc, yes. 
> But note that with a hypothetical shared FPC lib, the problem would be the
> same if one of the parts was not written in pascal. 
> IOW the libc case only works for C programs, and programs that build on
> that.


In a old topic, of Michael Walace :=>
>> http://lists.freepascal.org/pipermail/fpc-devel/2013-November/032950.html

Michael said :
Hey all.

I had a problem and I fixed it in the compiler, but I'm not sure
what the ramifications of my fix are for other people.

My goal was to expose some pascal code to python, as per:


This works fine for me on windows but failed on freebsd/amd64.

When I would try to load my shared library as a python module, it would
fail, saying: "Undefined Symbol: operatingsystem_parameter_envp"

This issue was reported by someone else but it was (mistakenly?) marked as
a duplicate issue and closed:


Anyway, the problem appears to be in this file:


It has the comment:

# FreeBSD RunTime dynamic loader only
# calls the functions specified by -init
# as functions without parameters
# Thus, it is not possible to retrieve argc, argv and envp
# On x86_64 CPU, using weak for the operatingsystem_parameter_XXX

# allows to bind to main program parameters,
# but this does not seem to work for i386 loader.

Then at the bottom:

/* Do not fail linkage if argc, argv and envp are not found. */
.weak operatingsystem_parameter_argc
.weak operatingsystem_parameter_argv
.weak operatingsystem_parameter_envp

My change was to comment these lines out and copy the lines from prt0.as :

.global operatingsystem_parameter_envp
.global operatingsystem_parameter_argc
.global operatingsystem_parameter_argv
.set operatingsystem_parameter_envp,operatingsystem_parameters+0
.set operatingsystem_parameter_envp,operatingsystem_parameters+0
.set operatingsystem_parameter_envp,operatingsystem_parameters+0

Then after recompiling fpc, I was able to compile a *.so file usable from

But... It seems like the original .weak version was done quite
deliberately, so I suspect that if I submit a patch, it would break
things for other people. OTOH, I'd like to get a fix for my issue
into trunk.

Could it be feasible to compile a "custom" fpc, so i could compile libraries for freeBSD 10 ?

Many thanks.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140805/8cf29af4/attachment.html>

More information about the fpc-devel mailing list