All of lore.kernel.org
 help / color / mirror / Atom feed
* HELP: Count Lines of Code in Custom Compiled Kernel
@ 2018-08-10  7:30 Faisal Mehmood
  2018-08-10 16:43 ` Randy Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Faisal Mehmood @ 2018-08-10  7:30 UTC (permalink / raw)
  To: linux-kbuild

So I compiled a custom minimal Linux Kernel. I want to list all the
source files used for this particular .config file. I also want to
count the lines of code against that .config file compilation.

I tried using 'make  > logfile', but that only lists the generated
object files. Source files are not listed.
'find . -type f -name *.[ch]' includes all the source files, while I
only need those that are being used by my .config file.

Regards.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: HELP: Count Lines of Code in Custom Compiled Kernel
  2018-08-10  7:30 HELP: Count Lines of Code in Custom Compiled Kernel Faisal Mehmood
@ 2018-08-10 16:43 ` Randy Dunlap
  2018-08-10 17:54   ` Randy Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2018-08-10 16:43 UTC (permalink / raw)
  To: Faisal Mehmood, linux-kbuild

On 08/10/2018 12:30 AM, Faisal Mehmood wrote:
> So I compiled a custom minimal Linux Kernel. I want to list all the
> source files used for this particular .config file. I also want to
> count the lines of code against that .config file compilation.

Hi,

We have a tradition of not doing people's homework for them.  :)

> I tried using 'make  > logfile', but that only lists the generated
> object files. Source files are not listed.

Did you try other build options?

E.g., using "make V=1 ... " will give you verbose output.  It might give
you a list of source files that are compiled.  OTOH, it's probably too verbose.

Or did you look at "make C=1 ..." to invoke the "CHECK" tool on each source
file that is built?

That should be enough of a hint to get you going...

> 'find . -type f -name *.[ch]' includes all the source files, while I
> only need those that are being used by my .config file.


BTW, it would be helpful if one could override "CHECKFLAGS" on the
'make' command line.
As is, CHECKFLAGS is (too) sparse-specific.

-- 
~Randy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: HELP: Count Lines of Code in Custom Compiled Kernel
  2018-08-10 16:43 ` Randy Dunlap
@ 2018-08-10 17:54   ` Randy Dunlap
  2018-08-10 19:53     ` Randy Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2018-08-10 17:54 UTC (permalink / raw)
  To: Faisal Mehmood, linux-kbuild

On 08/10/2018 09:43 AM, Randy Dunlap wrote:
> On 08/10/2018 12:30 AM, Faisal Mehmood wrote:
>> So I compiled a custom minimal Linux Kernel. I want to list all the
>> source files used for this particular .config file. I also want to
>> count the lines of code against that .config file compilation.
> 
> Hi,
> 
> We have a tradition of not doing people's homework for them.  :)
> 
>> I tried using 'make  > logfile', but that only lists the generated
>> object files. Source files are not listed.
> 
> Did you try other build options?
> 
> E.g., using "make V=1 ... " will give you verbose output.  It might give
> you a list of source files that are compiled.  OTOH, it's probably too verbose.
> 
> Or did you look at "make C=1 ..." to invoke the "CHECK" tool on each source
> file that is built?
> 
> That should be enough of a hint to get you going...
> 
>> 'find . -type f -name *.[ch]' includes all the source files, while I
>> only need those that are being used by my .config file.
> 
> 
> BTW, it would be helpful if one could override "CHECKFLAGS" on the
> 'make' command line.
> As is, CHECKFLAGS is (too) sparse-specific.

Aha, it is c_flags that gets in the way.
CHECKFLAGS=   does work to override its value.

So Faisal, I had to use a patch like this and then using CHECK=<some script file>
and CHECKFLAGS=      works to count each source file that is built.


---
 scripts/Makefile.build |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-next-20180810.orig/scripts/Makefile.build
+++ linux-next-20180810/scripts/Makefile.build
@@ -86,10 +86,10 @@ __build: $(if $(KBUILD_BUILTIN),$(builti
 ifneq ($(KBUILD_CHECKSRC),0)
   ifeq ($(KBUILD_CHECKSRC),2)
     quiet_cmd_force_checksrc = CHECK   $<
-          cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
+          cmd_force_checksrc = $(CHECK) $(CHECKFLAGS)  $< ;
   else
       quiet_cmd_checksrc     = CHECK   $<
-            cmd_checksrc     = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
+            cmd_checksrc     = $(CHECK) $(CHECKFLAGS)  $< ;
   endif
 endif
 




-- 
~Randy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: HELP: Count Lines of Code in Custom Compiled Kernel
  2018-08-10 17:54   ` Randy Dunlap
@ 2018-08-10 19:53     ` Randy Dunlap
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2018-08-10 19:53 UTC (permalink / raw)
  To: Faisal Mehmood, linux-kbuild

On 08/10/2018 10:54 AM, Randy Dunlap wrote:
> On 08/10/2018 09:43 AM, Randy Dunlap wrote:
>> On 08/10/2018 12:30 AM, Faisal Mehmood wrote:
>>> So I compiled a custom minimal Linux Kernel. I want to list all the
>>> source files used for this particular .config file. I also want to
>>> count the lines of code against that .config file compilation.
>>
>> Hi,
>>
>> We have a tradition of not doing people's homework for them.  :)
>>
>>> I tried using 'make  > logfile', but that only lists the generated
>>> object files. Source files are not listed.
>>
>> Did you try other build options?
>>
>> E.g., using "make V=1 ... " will give you verbose output.  It might give
>> you a list of source files that are compiled.  OTOH, it's probably too verbose.
>>
>> Or did you look at "make C=1 ..." to invoke the "CHECK" tool on each source
>> file that is built?
>>
>> That should be enough of a hint to get you going...
>>
>>> 'find . -type f -name *.[ch]' includes all the source files, while I
>>> only need those that are being used by my .config file.
>>
>>
>> BTW, it would be helpful if one could override "CHECKFLAGS" on the
>> 'make' command line.
>> As is, CHECKFLAGS is (too) sparse-specific.
> 
> Aha, it is c_flags that gets in the way.
> CHECKFLAGS=   does work to override its value.
> 
> So Faisal, I had to use a patch like this and then using CHECK=<some script file>
> and CHECKFLAGS=      works to count each source file that is built.

OK, that patch isn't needed if the line-counting script is modified to
accept any number of c_flags with the source file name as the last parameter.
Just ignore all of the c_flags.


The complete build output will contain lots of lines that are not
"interesting," but you can grep that output for lines that begin with
numbers and get something like this:

202 ../lib/sha1.c
52 ../lib/show_mem.c
551 ../lib/siphash.c
1054 ../lib/string.c
113 ../lib/timerqueue.c
3203 ../lib/vsprintf.c
99 ../lib/win_minmax.c
1870 ../lib/xarray.c
165 ../arch/x86/boot/a20.c
158 ../arch/x86/boot/cmdline.c
101 ../arch/x86/boot/cpu.c
129 ../arch/x86/boot/cpuflags.c
229 ../arch/x86/boot/cpucheck.c
75 ../arch/x86/boot/compressed/string.c
154 ../arch/x86/boot/early_serial_console.c
182 ../arch/x86/boot/edd.c
182 ../arch/x86/boot/main.c


and then add them up.  QED.

-- 
~Randy

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-10 22:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-10  7:30 HELP: Count Lines of Code in Custom Compiled Kernel Faisal Mehmood
2018-08-10 16:43 ` Randy Dunlap
2018-08-10 17:54   ` Randy Dunlap
2018-08-10 19:53     ` Randy Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.