LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Recompile standard kernel - loads of errors (https://www.linuxquestions.org/questions/linux-newbie-8/recompile-standard-kernel-loads-of-errors-454985/)

ColonelPanic 06-15-2006 05:37 AM

Recompile standard kernel - loads of errors
 
Hi there,

I'm still in the learning process with compiling and driver install so I thought it would be a good idea to practice with a recompile of the standard kernel without changing any settings. I followed all instructions for kernel recompile to the T but then at 'make modules' I see lots and lots of errors, often error 2, sometimes error 1.
BTW I started the process with --ignore-erros just to get through the run and see what it did.

How is it possible for a kernel to run properly with THAT many errors? I didn't modify anything, I just installed the source from the Mandriva DVD and did xconfig etc. without changing any parametre.

:confused:

The reason why I ask is that I need to install a driver update for my TV card which was not supported up to 01/2006. I'm just wondering if any attempt to do so will become a total disaster since even the boxed kernel source is so full of errors.

any hint appreciated
cheers

prozac 06-15-2006 05:50 AM

when i encountered those kind of errors, I simply went back to 'make menuconfig' and unchecked the modules causing the error. Most of the time, I was simply tryin to compile old and unneeded modules in my kernel. Since then I have learnt to compile only those modules that were specifically needed by my system and nothing else. I have found this results in a compact kernel and the mem used when i just boot is also very low compared to the default ones also the machine I feel responds faster.

ColonelPanic 06-15-2006 06:07 AM

Nice one prozac! I'll try that :)

Just a remark: I'm not a developer (I'm actually coming from SAP) and I know ABAP/4 (SAP language) well enough to know that things like 'undeclared arguments' are quite serious errors. - Actually ABAP won't even let you activate (release) the source code for compiling unless you have corrected all syntax and plausibility errors from dependent objects like includes, function modules etc. That's why it really baffles me that an OS :!: lets you release buggy source code into a compile run.

Anyway I'll try again.

cheers

prozac 06-15-2006 06:16 AM

you know what i too have been thinking the same. 'unused variables', 'defined but not used' messages are really creepy. I am thinking then, the developers who wrote the drivers must have got lazy and decided not to correct those (after all they are just warnings!). It has got nothing to do with the kernel developers-they just include those drivers in the kernels. maybe somebody could explain more clearly.

prozac 06-15-2006 06:18 AM

also try the output of 'lspci' and 'lsmod'. I have found them quite helpful in determining my exact devices and the modules they use.

ColonelPanic 06-15-2006 08:25 AM

cheers prozac, much appreciated

tkedwards 06-15-2006 12:49 PM

Quote:

you know what i too have been thinking the same. 'unused variables', 'defined but not used' messages are really creepy
If you think about it though these aren't really a problem. All it means is that the programmer has defined a variable and then not used it. This kind of stuff probably happens all the time because of the rapid pace of development in the kernel and the use of #ifdef preprocessor statements to cope with all the different possible environments under which the software could run.

As for compiling your kernel try getting the kernel SRPM, not the kernel-source RPM. Goto any of the http or ftp mirrors listed for the main repo at easyurpmi.zarb.org and go up a few levels to find the SRPMS folder for main. In there you'll find the kernel SRPM, just download it, install it, make your changes and rebuild. http://qa.mandriva.com/twiki/bin/vie...ing_source_RPM

You could also just download the vanilla kernel source from kernel.org and at the make xconfig stage make sure to load the current config from the Mandriva kernel that you're using (look in /boot). If you do this do a make rpm instead of just make so that at the end it spits out a nice RPM that you can easily install.

prozac 06-15-2006 11:11 PM

Quote:

Originally Posted by tkedwards
If you think about it though these aren't really a problem. All it means is that the programmer has defined a variable and then not used it. This kind of stuff probably happens all the time because of the rapid pace of development in the kernel and the use of #ifdef preprocessor statements to cope with all the different possible environments under which the software could run.

Doesn't it waste memory like that? When you declare a variable, the system allocates memory the size of the variable, and when you don't use it, it lies there unused, wasted. What about freeing them afterwards, NO garbage collection, i suppose at that level.
Quote:

Originally Posted by tkedwards
As for compiling your kernel try getting the kernel SRPM, not the kernel-source RPM.

RPM? I have never downloaded kernel in RPMs. I am all the fine with using just the sources and I am not using Red Hat. I am a big source fan, I don't like packages.

tkedwards 06-15-2006 11:38 PM

Quote:

Doesn't it waste memory like that? When you declare a variable, the system allocates memory the size of the variable, and when you don't use it, it lies there unused, wasted. What about freeing them afterwards, NO garbage collection, i suppose at that level.
I think you're jumping to conclusions a bit. Garbage collection happens automatically when variables go out of scope, even in C/C++. The only way that you can cause memory to not be Garbage Collected and cause a memory leak is to assign a variable to point to a dynamically created object/variable and forget to free it before that variable goes out of scope. In other words in C/C++ you use new or malloc or whatever without a corresponding free call.

Therefore its impossible to have an unused variable that isn't Garbage Collected - you have to assign a variable to something (a new'ed/malloc'ed block of memory) first before you can cause a memory leak. As annoying and bad looking as those unused variables are all they really amount to is 32-bits (4 bytes) or so of wasted memory each. Even if there's say 1000 of them in your kernel that's only 4KB of wasted memory.

Of course I'm writing this off the top of my head so I could be wrong :) but I highly doubt that the kernel maintainers leave dozens or hundreds of memory leaks in their code that are visible as simple compiler warnings.

Quote:

RPM? I have never downloaded kernel in RPMs. I am all the fine with using just the sources and I am not using Red Hat. I am a big source fan, I don't like packages.
Maybe but I suggested the SRPM way as its the easiest, quickest and probably most failsafe way to get a kernel to recompile if you're not really sure what you're doing. I also suggested he try downloading he kernel from kernel.org and building it himself.

prozac 06-15-2006 11:53 PM

Quote:

Originally Posted by tkedwards
I think you're jumping to conclusions a bit.

I am sorry I am a little risky sometimes.

Quote:

Originally Posted by tkedwards
Garbage collection happens automatically when variables go out of scope, even in C/C++. The only way that you can cause memory to not be Garbage Collected and cause a memory leak is to assign a variable to point to a dynamically created object/variable and forget to free it before that variable goes out of scope. In other words in C/C++ you use new or malloc or whatever without a corresponding free call.

Therefore its impossible to have an unused variable that isn't Garbage Collected - you have to assign a variable to something (a new'ed/malloc'ed block of memory) first before you can cause a memory leak. As annoying and bad looking as those unused variables are all they really amount to is 32-bits (4 bytes) or so of wasted memory each. Even if there's say 1000 of them in your kernel that's only 4KB of wasted memory.

For static created variable its what you said and I don't think they would create problems. But what you are telling me about dynamically created ones are the issue I am thinking about now. 4Kb of wasted memory and you say its no probs! using malloc/calloc and then not freeing leads to mem leaks and is unforgivable in my concern. ofcourse, i don't know everything about programming yet but AFAIK its serious. In whatever programs i have written so far, I have tried my best to avoid this kind of mistakes. Memory bugs can make apps/oses crash. I've heard JAVA is so elegant because it automatically handles the garbage collection and hence reduces the chance of mem leaks (also abt the error handling but right now lets only talk abt garbage collections).
tkedwards, I am sorry but i am not convinced.

tkedwards 06-16-2006 07:24 AM

Quote:

using malloc/calloc and then not freeing leads to mem leaks and is unforgivable in my concern. ofcourse, i don't know everything about programming yet but AFAIK its serious. In whatever programs i have written so far, I have tried my best to avoid this kind of mistakes. Memory bugs can make apps/oses crash. I've heard JAVA is so elegant because it automatically handles the garbage collection and hence reduces the chance of mem leaks
I'm pointing out that its impossible to have an *unassigned* variable create a memory leak because to create a memory leak you first have to assign the variable to something. These 'unassigned' warnings are not memory leaks - the kernel developers go to great lengths to try and weed out memory leaks by auditing their code and using all sorts of tricky compiler options and debug programs to try and catch them. They would have long ago squashed any that showed up as simple compiler warnings.

Quote:

4Kb of wasted memory and you say its no probs!
4 bytes per variable is the default on 32-bit machines. That means if you have 1000 of these compiler warnings its still only 4KB, not 4KB per variable. 4KB is insignificant even when compared to the memory usage of the kernel, let alone the memory in your whole machine. I doubt you'd even have 1000 of these warnings but I gave that number to be safe and to show that it still is an insignificant amount of memory.

prozac 06-16-2006 10:35 AM

Quote:

Originally Posted by tkedwards
I'm pointing out that its impossible to have an *unassigned* variable create a memory leak because to create a memory leak you first have to assign the variable to something. These 'unassigned' warnings are not memory leaks -

I am not understanding. Its created and his its own address in the memory, Its not assigned to any value and yet its not a memory leak. can you explain a little bit more.

tkedwards 06-16-2006 12:44 PM

Excuse my very rusty C:
Code:

afunction {
  int j;
  int i = 0;
  while(i < 50)
  {
      /*do something*/
      i++;
  }
} /* both i and j go out of scope here and are properly 'garbage collected'*/

So each time this function runs it creates an unsed variable j, which as an int is 32 bits (4 bytes) on most machines.

Code:

averybadfunction {
  int j;
  j = malloc(1000);
  int i = 0;
  while(i < 50)
  {
      /*do something*/
      i++;
  }
} /* both i and j go out of scope here and are properly 'garbage collected'.
However the block of dynamically allocated memory that was assigned to j is not freed and therefore becomes 'lost', ie. a memory leak.
Note that since j is assigned a value the compiler will not throw an unassigned variable warning.*/

Each time this code runs it leaks memory but it does not leave any variables unassigned.

In other words its impossible to have an unassigned variable leak memory because as soon as you use malloc/calloc/new your variable is assigned a value:
Code:

j = malloc(1000);
All an unassigned variable will do is waste a very small amount of memory while that particular function that the variable is declared in is running, ie. when the variable is in scope. A memory leak is where you lose track of a dynamically allocated block of memory, ie. by doing a malloc() without a corresponding free() in C.

adilturbo 06-16-2006 02:23 PM

all what u have said was right,i want just to add an idea:
when using the new operator or whatever(dynamic allocation)then not using
the delete operator(freeing memory operators)the moment u quit the program
the O.S then freeing automatically the ammount of memory allocated.

i think u forgot somethings in ur code:

Code:

int* j;//j should be pointer
j =(int*) malloc(1000);//casting from void* to int*

thank u.

prozac 06-18-2006 02:18 AM

Quote:

Originally Posted by tkedwards
A memory leak is where you lose track of a dynamically allocated block of memory, ie. by doing a malloc() without a corresponding free() in C.

I get it this is not the case with those compiler errors. The compiler won't catch these kind of errors right. These are created on run-time and any error hence forth relating to these abandoned variable ought to be catched by the os (if the program doesn't specifically handles it using free()). and the kernel does a good job of catching and freeing such hence its no probs actually.


All times are GMT -5. The time now is 08:32 PM.