about header file parsing

Marc Nieper-Wißkirchen marc.nieper@gmail.com
Tue Jan 1 00:00:00 GMT 2019


Am 08.01.19 um 22:45 schrieb Basile Starynkevitch:
> Hello all
> 
> Sorry, I have sent a private message to Marc which was meant to be on 
> this jit@gcc.gnu.org list. Here is it for all
> 
> 
> 
> On 1/8/19 10:30 PM, Marc Nieper-Wißkirchen wrote:
>> What would you do with macros defined in the header file that form 
>> part of the API? They won't be visible after compiling (already after 
>> preprocessing). 
> 
> That is one of the problems. Notice that libgccjit don't know about 
> macros, and there is no way to use a macro from libgccjit.
> For example, libgccjit does not know that EOF is -1 on my system.

This seems to be less of a problem if you are able to include the header 
file defining, say, EOF, in your C program that calls the libgccjit 
functions.

> Another problem is inlined functions appearing in headers. They won't be 
> inlined from LIBGCCJIT generated code, unless you use LTO.
> 
> LIBGCCJIT code can only call C-like functions - without inlining them 
> (even when GCC would).
> 
> Perhaps you are only interested in using nice C headers that don't 
> define any inlined functions and have only very few macro constants.
> For the macro constants (like EOF) you would handle them by hand (e.g. 
> expanding the EOF of your Scheme dialect into -1 before using libgccjit).

Ah, yes, this is what I meant above. :)

> 
> BTW, CLASP (see https://github.com/clasp-developers/clasp ...) might be 
> inspirational for you, but doing the equivalent in your case is a lot of 
> work
> because what DrMeister did in CLASP is a lot of work; see also 
> https://drmeister.wordpress.com/ and 
> @Inproceedings{Schafmeister:2015:CLASP,
> author = {Schafmeister, Christian E.},
> booktitle = {Proceedings of the 8\textsuperscript{th} European
> Lisp Symposium on European Lisp Symposium},
> series = {ELS2015},
> year = 2015,
> title = {{CLASP} - A {Common Lisp} that Interoperates with
> {C++} and Uses the {LLVM} Backend}
> }
> 
> 
> I don't understand if you want to handle a specific set of a few header 
> files in your Scheme using libgccjit, or if you want a generic solution.

I am not the original author of the question. I just wanted to remark 
that parsing header files is even more involved.

> If you only want to interace a specific library to your Scheme above 
> LibGccJit, you could use the GCC plugin technique (then hand-tune the few
> problematic areas). If you want a generic solution, it probably won't be 
> enough.
> 
> Cheers.
> 



More information about the Jit mailing list