On 14/12/2012, at 11:16 AM, john skaller wrote:

> "create_thread_frame"

I have fixed it so now static linkage works.
It is done by the compiler creating an extra C++ file:

~/felix>less 
build/release/cache/text/Users/johnskaller/felix/src/flx_pkgconfig/flx_pkgconfig_static_link_thunk.cppextern
 "C" void flx_pkgconfig_create_thread_frame();
extern "C" void flx_pkgconfig_flx_start();
extern "C" void (*static_create_thread_frame)() = 
flx_pkgconfig_create_thread_frame;
extern "C" void (*static_flx_start)() = flx_pkgconfig_flx_start;

and then flx compiles this when static linking and adds it
to the link step. The build system mod to do this seems to work,
not sure about flx because the build ran into a roadblock.

Support for "flx_main" is not included. If you use it you have
to export the name anyhow. Linkage for that name works
the old way: unprefixed. There's an issue here: there's a file
with a dummy flx_main that is in the library. It seems the
system relies on this: if you put one in the program the linker
will use that one. If you do not, the library one gets used instead.
It's a bit problematic, overriding a library function like this:
what if the code itself is in a library. Then it depends on search
order. Yuk.

Anyhow thats not the problem. For dynamic linkage we call

        library.link(filename)

I have to change that routine so it looks for the entrypoint:

        filename.
                basename_minus_extension.
                converted_to_C_identifier+"_"+old_entry_point

There two ways to do that: 

(a) just add a prefix parameter to the link function.
This is easiest for the library code, but then the caller
has to do the same job.

(b) make the library function do it.

Either way, I need a way to do this calculation.
The "basename minus filename" part is platform dependent.
The Felix ID to C ID part doesn't actually require a valid Felix ID,
it just takes any string and mangles it to get a valid C identifier.

Both these bits of code exist already in Ocaml, because the
flxg compiler has to do these steps already. All generated
code (except exports) gets put in

        namespace ::flxusr::mname

where mname is the module name derived from the filename
as above. There's no switch to force a particular module name
(i don't like switches like that because you have to use a consistent
switch in multiple places: better to put that info in the source file
if you have to have it).

The function "basename" is already in the Felix library.
The bit to chop off the extension could be added.
The translation of the resulting string into a valid C identifier
would have to be written by copying the Ocaml function:

        Flx_name.flxid_to_cid

However this ONLY supports method (a).
To do method (b) we'd have to do the above two functions
in C++ instead.

Method (a) looks best anyhow: it separates the filename
from the entry points.


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to