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

Aruna Hewapathirane aruna.hewapathirane at gmail.com
Wed Dec 11 22:14:21 EST 2019


>> On Sun, Dec 8, 2019 at 2:06 PM Frank A. Cancio Bello <
frank at generalsoftwareinc.com> wrote:
>> 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?
>>
>> thanks
>> frank a.

Hi Frank,

There are two options you can use with gcc to get the processor output as
part of the kernel compilation process.
  -save-temps
  -save-temps=<arg>

1 - Open the top level Makefile in your favorite text editor.
2 - Search for KBUILD_CFLAGS
    My Makefile which is at /home/aruna/linux-5.4.2/Makefile shows me at
line 458
    KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes
-Wno-trigraphs

3 - Now plugin   -save-temps=<arg> but replace <arg> with obj like shown
below:
   KBUILD_CFLAGS   := -Wall  -save-temps=obj  -Wundef
-Werror=strict-prototypes -Wno-trigraphs

4 - Save the Makefile.
5 - Run make and we are done !

Each directory will have the preprocessor output in *.i and *.s files.

Good luck - Aruna ( I keep asking myself 'why' are you doing this though ?
:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20191211/d82581ca/attachment.html>


More information about the Kernelnewbies mailing list