How to get the preprocessor output as part of the compilation process?

Konstantin Andreev andreev at swemel.ru
Mon Dec 9 05:10:11 EST 2019


Hi, Frank.

The universal approach that always works in this and many similar cases is just to replace the instrumented binary by your interception shell script.

E.g. rename gcc to gcc.hide (generally, moving into another location may not work) and setup 'gcc' script that does what you want: replaces `-c' with the `-E', replaces `-o' argument, etc ..., calls gcc.hide to preprocess source then calls gcc.hide with original non-modified command line.

This is cumbersome process, you can break some things, there may be a handful try and fix iterations, but the advantage is that you have a full control on what is happening, and you do not need support from the tool, build process and product maintainers.

The interception like this is used by static code analysis tools.

Regards, Konstantin

Frank A. Cancio Bello, 08 Dec 2019 MSK:
>
> Hi, I know that with gcc -E you can get the output of the preprocessor, but what I have to do to get that output for every source code file in the Linux Lernel as part of the compilation process?



More information about the Kernelnewbies mailing list