> 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.

Hello.

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:

http://wiki.freepascal.org/Developing_Python_Modules_with_Pascal

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:

http://bugs.freepascal.org/view.php?id=3D15422

Anyway, the problem appears to be in this file:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/freebsd/x86_64/dllpr=
t0.as?revision=3D25737&view=3Dmarkup

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
python.

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.

Fred 


                                          
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to