Compilar un archivo de objeto a partir de un archivo intermedio de gcc

Mediante el uso de la -fdump-tree-* flag , one can dump some intermediate format file during compilation of a source code file. My question is if one can use that intermediate file as an input to gcc to get the final object file.

I'm asking this because I want to add some code to the intermediate file of the gimple (obtained by using the flag -fdump-tree-gimple) format. Sure I can use hooks and add my own pass, but I don't want to get to that level of complexity yet. I just want to give gcc my modified intermediate file, so it can start its compilation from there and give me the final object file. Any ideas how to achieve this?

preguntado el 01 de febrero de 12 a las 22:02

(+1) No answer either, but, want to achieve the same. -

¿Ha visto usted este? -

2 Respuestas

GIMPLE was a binary internal format which is hard to dump fully and reload back correctly. Comparing with LLVM, LLVM IR was diseñado to be dumpable and reloadable into usual file (text and binary format of such files are fully-convertible from each to other). You can run Clang fronted to emit LLVMIR, then start opt program with some optimizations, then with other, and there will be LLVM IR bitcode files between phases. And then you can start codegeneration from IR bitcode into native code (even, in theory, into not the same platform, see PNaCl project).

There are some projects of dumping/reloading internal representation of GCC. I know such project was created to integrate gcc with commercial compiler tool. The author can't just link commercial code with gcc, because gcc is VIRAL (it will infect any linked code with anti-commercial GPL). So, author wrote a GPL dumper/loader of GIMPLE to some external (xml) format; the proprietary tool was able to read and translate this XML into other XML of the same format and then it was reloaded back with GPL tool.

In newer gcc you have an option of writing a plugin, which is VIRAL (23.2.1) in terms of GPL. Plugin will operate on in-memory representation of program and there will be no problem of dumping/reloading GIMPLE via external file. There are some plugins which may be configured/may use user-supplied program, e.g MELT (Lisp) and GCC Python (Python). Some list of gcc plugins esta ahí

Respondido 03 Feb 12, 03:02

I know such project for gcc which is named gcc-xil and which is infected with GPL (free to download). // I ll delete this comment a bit later. - osgx

So in short, you are saying LLVM is much easier to work with? - Sacerdote Metálico

There's no built-in facility to translate the text GIMPLE representation back to original GIMPLE internal representation.

You'll need to use custom front-end (such as suggested GIMPLE FE) to make sense of dumped GIMPLE.

Respondido 02 Feb 12, 16:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.