* How to get the preprocessor output as part of the compilation process? @ 2019-12-08 19:05 Frank A. Cancio Bello 2019-12-08 21:53 ` Valdis Klētnieks ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Frank A. Cancio Bello @ 2019-12-08 19:05 UTC (permalink / raw) To: kernelnewbies 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. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to get the preprocessor output as part of the compilation process? 2019-12-08 19:05 How to get the preprocessor output as part of the compilation process? Frank A. Cancio Bello @ 2019-12-08 21:53 ` Valdis Klētnieks 2019-12-09 10:10 ` Konstantin Andreev 2019-12-12 3:14 ` Aruna Hewapathirane 2 siblings, 0 replies; 6+ messages in thread From: Valdis Klētnieks @ 2019-12-08 21:53 UTC (permalink / raw) To: Frank A. Cancio Bello; +Cc: kernelnewbies [-- Attachment #1.1: Type: text/plain, Size: 377 bytes --] On Sun, 08 Dec 2019 14:05:06 -0500, "Frank A. Cancio Bello" said: > 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? What problem are you trying to solve by doing that? There's probably a better and more efficient approach.... [-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --] [-- Attachment #2: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to get the preprocessor output as part of the compilation process? 2019-12-08 19:05 How to get the preprocessor output as part of the compilation process? Frank A. Cancio Bello 2019-12-08 21:53 ` Valdis Klētnieks @ 2019-12-09 10:10 ` Konstantin Andreev 2019-12-10 3:17 ` Valdis Klētnieks 2019-12-12 3:14 ` Aruna Hewapathirane 2 siblings, 1 reply; 6+ messages in thread From: Konstantin Andreev @ 2019-12-09 10:10 UTC (permalink / raw) To: Frank A. Cancio Bello, kernelnewbies 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? _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to get the preprocessor output as part of the compilation process? 2019-12-09 10:10 ` Konstantin Andreev @ 2019-12-10 3:17 ` Valdis Klētnieks 2019-12-10 13:35 ` Konstantin Andreev 0 siblings, 1 reply; 6+ messages in thread From: Valdis Klētnieks @ 2019-12-10 3:17 UTC (permalink / raw) To: Konstantin Andreev; +Cc: Frank A. Cancio Bello, kernelnewbies [-- Attachment #1.1: Type: text/plain, Size: 1203 bytes --] On Mon, 09 Dec 2019 13:10:11 +0300, Konstantin Andreev said: > 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, And in fact, what you may want to do is have your script invoke gcc *twice*, once with -E, and then a second time with -c, because otherwise the build will die the first time it tries to link together two or more non-existent .o files. Using 'make -k' *might* also work, but will leave the build log output littered with a *lot* of error messages. Or explain why you're doing this - there may be a simpler way to achieve your goal. For instance, if you're trying to build a cross-reference of what .c files include what .h directly or indirectly, there's already specialized tools for doing that sort of thing, such as 'cxref'. [-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --] [-- Attachment #2: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to get the preprocessor output as part of the compilation process? 2019-12-10 3:17 ` Valdis Klētnieks @ 2019-12-10 13:35 ` Konstantin Andreev 0 siblings, 0 replies; 6+ messages in thread From: Konstantin Andreev @ 2019-12-10 13:35 UTC (permalink / raw) Cc: kernelnewbies Hi, Valdis. It wasn't me who asked the question, so I can't comment on the Frank's goal. > And in fact, what you may want to do is have your script invoke gcc twice, once with -E, and then a second time with -c, ... Certainly. That is exactly what I have proposed. Nothing wrong with this. Regards, Konstantin Valdis Klētnieks, 10 Dec 2019 06:17 MSK: > > And in fact, what you may want to do is have your script invoke gcc twice, once with -E, and then a second time with -c, because otherwise the build will die the first time it tries to link together two or more non-existent .o files. > > Using 'make -k' might also work, but will leave the build log output littered with a lot of error messages. > > Or explain why you're doing this - there may be a simpler way to achieve your goal. For instance, if you're trying to build a cross-reference of what .c files include what .h directly or indirectly, there's already specialized tools for doing that sort of thing, such as 'cxref'. Konstantin Andreev, 09 Dec 2019 13:10 MSK: > > 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, ... _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to get the preprocessor output as part of the compilation process? 2019-12-08 19:05 How to get the preprocessor output as part of the compilation process? Frank A. Cancio Bello 2019-12-08 21:53 ` Valdis Klētnieks 2019-12-09 10:10 ` Konstantin Andreev @ 2019-12-12 3:14 ` Aruna Hewapathirane 2 siblings, 0 replies; 6+ messages in thread From: Aruna Hewapathirane @ 2019-12-12 3:14 UTC (permalink / raw) To: Frank A. Cancio Bello; +Cc: kernelnewbies [-- Attachment #1.1: Type: text/plain, Size: 1116 bytes --] >> On Sun, Dec 8, 2019 at 2:06 PM Frank A. Cancio Bello < frank@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 ? :) [-- Attachment #1.2: Type: text/html, Size: 2353 bytes --] [-- Attachment #2: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-12-12 3:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-12-08 19:05 How to get the preprocessor output as part of the compilation process? Frank A. Cancio Bello 2019-12-08 21:53 ` Valdis Klētnieks 2019-12-09 10:10 ` Konstantin Andreev 2019-12-10 3:17 ` Valdis Klētnieks 2019-12-10 13:35 ` Konstantin Andreev 2019-12-12 3:14 ` Aruna Hewapathirane
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).