I'm building the Linux Kernel with the gcc options -save-temps=obj -o in order to see exactly how all the C files get preprocessed (and, as a bonus, how the files are turned into assembly).
Here's the version details:
- Running WSL 2 on Windows 10 version 1909 (build 18363.1256)
- The distro is Ubuntu 20.04 LTS
- The installed kernel version is 4.19.128-microsoft-standard
- The kernel tree I'm using is from https://github.com/microhobby/linus-tree, a fork of the WSL kernel used for this tutorial on building the kernel.
- When presented with
[Y/n/?]flags on my first build, I (tried) to answer with the capitalized option.
I'm not interested in using or installing the built kernel for anything, just seeing how the .i and .s files look.
I added a few options to the Makefile:
KBUILD_HOSTCFLAGS := -Wall -Wno-error=deprecated-declarations -Wmissing-prototypes -Wstrict-prototypes -O2 \
-fomit-frame-pointer -save-temps=obj -o -std=gnu89 $(HOST_LFS_CFLAGS) \
$(HOSTCFLAGS)
Specifically, I added the -save-temps=obj -o -Wno-error=deprecated-declarations flags. Running this works, but only generates a small handful of .i files totalling only about 9.9 MB, which pales in comparison to the 494 MB of .c files in the kernel.
I know that only part of the kernel is built based on the architecture you're building it for, but this is quite a discrepancy. Are so few .c files really compiled by a "standard" build of the kernel? If not, how can I get all the .i and .s files generated by gcc?