Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it necessary to clean the Linux kernel source tree after each bisection step?

When bisecting the Linux kernel source tree between two relatively distant commits, the first few bisection steps usually change a great deal of the kernel source, so whether make distclean is run or not, won't make a big difference. However, as the bisection scope gets narrower, fewer source files are changed at each step, so cleaning the source tree will remove a lot of *.o files that don't need to be rebuilt.

Since make infers the object files that need to be rebuilt by comparing their last modification time to that of their associated source files, I would assume that it is not necessary to clean the tree after each bisection step, but I do it anyway as a precaution after I ran into a situation where a lengthy bisection process got me eventually into a "bad" commit that has nothing to do with the bug in question.

To make it concrete, here are the steps I used in the first bisection attempt (which got me into the wrong commit):

cp /boot/config-`uname -r` .config
make oldconfig
make && sudo make modules_install && sudo make install
# reboot
# Then I repeat the following steps until the bisection ends.
# test the kernel
git bisect {good,bad}
make && sudo make modules_install && sudo make install
# reboot

I bisected again using the following procedure, and was able to successfully reach the faulty commit:

make distclean
cp /boot/config-`uname -r` .config
make oldconfig
make && sudo make modules_install && sudo make install
# reboot
# test the kernel
git bisect {good,bad}
# Then I repeat the steps above until the bisection ends.

Since I'm not very knowledgable of the internals of the kenrel build system, it would be great if someone could point me at some way by which I could avoid cleaning and rebuilding the entire kernel after each bisection step, since that would save me a lot of build time, and will shorten the bisection process considerably.

like image 509
Marwan Tanager Avatar asked May 12 '13 03:05

Marwan Tanager


People also ask

How do you bisect a kernel?

The first step in the bisect process is to find the last "Good" kernel version, followed consecutively in version by the first "Bad" one. That is done by downloading, installing and testing kernels from here. Once this is done, the next step is commit bisecting upstream kernel versions.

Where is Linux kernel clone?

Initial set up. If you haven't already done so, first clone a copy of the mainline Linux Git repository: $ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git # or: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Cloning into 'linux'... ...


1 Answers

From the man

The make program uses the makefile data base and the last-modification times of the files to decide which of the files need to be updated.

and a quick experiment

$ stat -c%y bar.txt
2013-05-11 22:58:46.499826200 -0500

$ git checkout HEAD~1
HEAD is now at e7b9f1c... first

$ stat -c%y bar.txt
2013-05-11 22:58:52.583836900 -0500

As you can see, performing a checkout changes the modification time of the file, and in turn would force it to be recompiled with make. So the answer is no, it is not necessary to clean the tree because the necessary file will be recompiled.

like image 120
Zombo Avatar answered Sep 17 '22 11:09

Zombo