Statically linking C code into ECL

Daniel Kochmański daniel at turtleware.eu
Mon Dec 26 10:02:57 UTC 2016


Faré writes:

> What's the official way to link a C file into ECL?

What do you mean by 'linking C file'? If you want to compile independent
C file with ECL, then you are out of luck, because there is no official
support for that in ECL's builder. It may work by passing file as one of
lisp-files to builder, because ECL uses C files *internally*, but it's
far from encouraged or official.

As a side note, I see you use there c::builder, which is also
internal. Exported interfaces are build-fasl, build-program,
build-static-library and build-shared-library (it doesn't make a
difference right now, but in the future builder interface may change,
while the mentioned functions wont).
>
> I'm adding a :c-file type to cffi-toolchain, and it works great on
> sbcl and clisp,
> or on ECL when loading the file as a .so, but when I try to link the
> file into an executable,
> the .o failed to be included in the executable: the .o was
> successfully grouped with
> other .o's from the same system in a .a, but ecl fails to use
> -Wl,--whole-archive,
> so the .o is not preserved.
> Is there a way to tell ECL to use -Wl,--whole-archive and/or (on
> Darwin) -force_load before every .a?

builder (and all interfaces built on top of it) support ld-flags key
argument. Additionally if you want to influence how ECL compiles files
dynamically you may shadow *user-cc-flags* and *user-ld-flags*.
>
> The question is in the context of my cffi branch (that I'm hoping to
> upstream asap, pending merge of the sbcl patch it depends on):
> https://github.com/fare/cffi
>
> —♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org
> A president worth voting for wouldn't run for office.

If this remarks aren't helpful, please tell me exactly what do you want
to achieve with some minimal example (i.e I'm doing that and that,
expecting this and this, but it doesn't work failing in this way),
because I don't quite understand your problem.

I'm adding ecl-devel to CC, because someone may be more competent to
answer your question.

Regards,
Daniel

-- 
Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland
TurtleWare - Daniel Kochmański      | www.turtleware.eu

"Be the change that you wish to see in the world." - Mahatma Gandhi



More information about the ecl-devel mailing list