Perl removal patch for 2.6.26.
A patch in 2.6.25 added perl as a build requirement for the Linux kernel, by making the file kernel/timeconst.h generated by a perl script.
Oddly, the perl script in question tested whether or not you had _enough_ perl installed, and if you didn't have an optional bignum package out of cpan it checked if the HZ value you wanted to generate #defines for matched one of 15 cached values it had precomputed numbers for. (This cached information took up half the perl file).
These values are in fact all the ones currently used by the Linux kernel. Every HZ value for every platform is set by a kconfig choice menu, so the only way to add a new HZ value is modify the kernel source. After 17 years, with hundreds of target boards, there are currently 15 only values in use.
This patch moves the cache out of the perl program and instead pregenerates a kernel/timeconst.h file, which it checks in. The start of that file is:
Quoted 3 lines
/* Conversion constants for HZ */
/* DO NOT EDIT! Automatically generated by:kernel/timeconst.pl 24 32 48 64 100 122 128 200 250 256 300 512 1000 1024
1200
Quoted 1 line
*/
I.E. it gives you the command line to run to regenerate the file. If you need to add another value, cut and paste that command line to generate a new timeconst.h file, and submit the diff. (Note that the perl script records the command line it was run with automatically, that will be part of the diff.)
This patch:
1) Removes half the perl script (all the conditional cached stuff). The result is a much smaller and simpler perl script.
2) Changes the perl script to generate a single include file with 15 #ifdefs rather than generating an #include file with the one HZ value currently selected by kconfig. (The last #else case #errors out with the existing error message about an unknown HZ value.)
3) Removes all mention of kernel/timeconst.h from the makefiles. They don't need to know anymore.
The only other potential change (which I didn't make) is to move kernel/timeconst.pl into scripts/timeconst.pl, since it's now in the same class with the python script bloat-o-meter; something developers can run but which is not required to simply compile an unmodified kernel tarball.
Comments welcome.
Rob
Signature · 2 lines
"One of my most productive days was throwing away 1000 lines of code." - Ken Thompson.
kernel/Makefile +0 -5
@@ -95,8 +95,3 @@ $(obj)/time.o: $(obj)/timeconst.h -quiet_cmd_timeconst = TIMEC $@ - cmd_timeconst = $(PERL) $< $(CONFIG_HZ) > $@ -targets += timeconst.h -$(obj)/timeconst.h: $(src)/timeconst.pl FORCE - $(call if_changed,timeconst)
kernel/timeconst.pl +28 -193
262 lines not on this page · raw message
kernel/timeconst.h new file +346 -0
346 lines not on this page · raw message