This article uses CodeViz, which downloads gcc 4.6.2 to compile the kernel while extracting code information. Other posts explore other techniques.
Making codeviz and gcc
The makefile calls the script “compilers/install_gcc-4.6.2.sh” to compile the patched gcc. There might be a few changes to that script in order to get everything working. Thanks to Stephan Friedl’s post, which gave the final fix for the gcc compilation.
Get a VM to compile gcc
This technique for setting up the system involves making many changes to /usr/lib and /usr/include, which could break the system in the future. I installed Ubuntu 14.04 desktop amd64 with 16GB of hard-disk on VirtualBox (also tested QEMU, but the VM was slow).
sudo apt-get build-dep gcc-4.6-base cd /usr/include sudo ln -s x86_64-linux-gnu/* . cd /usr/lib sudo ln -s x86_64-linux-gnu/crt* .
Make sure you can fetch the sources
It uses ncftpget to fetch gcc source code, so if you don’t have it installed, now might be a good time (or change the script to another utility such as wget)
sudo apt-get install ncftp
Modify configuration and make file in the script
# Configure and compile ../gcc-4.6.2/configure --prefix=$INSTALL_PATH --enable-shared --enable-languages=c,c++ --disable-multilib || exit make bootstrap MAKEINFO="true" -j12
This adds –disable-multilib to configure (which I’m not sure is necessary, but many troubleshooting discussions had), and for make, disables MAKEINFO and runs multiple threads to compile.
Compiling the Linux kernel with codeviz
I like to use the linux-stable git repo:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Now, to compile using the codeviz-recommended line:
make O=~/linux-build CC=/usr/local/gccgraph/bin/gcc bzImage