# Can't build a kernel that works.

## augury

I have build over two dozen kernels that refuse to load.

They seem to extract and then nothing.  (sometimes it asked for the vga mode, said it would scan, but no)

I think I re-emerged gcc 4.5.1-r2 w/USE="lto" after building kernel I am using now (vanilla-sources-2.6.36.2, which also does not build now).  

Is there some faulty logic in this?  Or what?  I am using an essentially 100% fresh, 2 week old system that has very little slop.  Headers are cleaned, etc.

EDIT:

my kernel was built with my current gcc it seems

```
Linux kaiser 2.6.36.2 #5 SMP PREEMPT Tue Dec 28 17:35:48 Local time zone must be set-- i686 Intel(R) Xeon(TM) CPU 3.20GHz GenuineIntel GNU/Linux
```

/usr/lib/gcc/4.5.1 is all from Dec 27.Last edited by augury on Fri Jan 07, 2011 10:19 pm; edited 2 times in total

----------

## kernelOfTruth

*subscribes*

I saw something related:

started experimenting with flto and fwhole-program flags and some others and lvm2 wouldn't recognize my partition (cryptsetup -> lvm -> ext4)

the only solution so far was to play back a backup - I tried reverting to previous flags and re-emerging the packages related but

still no change

hopefully someone can come up with a solution in the long-term

so that people won't be stuck ...

----------

## augury

Using gcc-4.5.2 (the one with lto and enable-gold) I'm getting

```
drivers/built-in.o: In function `e1000e_phy_force_speed_duplex_igp':

(.text+0x1a306d): undefined reference to `__bad_udelay'

drivers/built-in.o: In function `e1000e_phy_force_speed_duplex_igp':

(.text+0x1a30c3): undefined reference to `__bad_udelay'

drivers/built-in.o: In function `e1000e_phy_force_speed_duplex_m88':

(.text+0x1a3303): undefined reference to `__bad_udelay'

drivers/built-in.o: In function `e1000e_phy_force_speed_duplex_m88':

(.text+0x1a3379): undefined reference to `__bad_udelay'

drivers/built-in.o: In function `e1000_phy_force_speed_duplex_ife':

(.text+0x1a3515): undefined reference to `__bad_udelay'

drivers/built-in.o:(.text+0x1a356b): more undefined references to `__bad_udelay' follow
```

Just one of several header skewing errors that seem to occur for no real reason going from 4.5.1-r2 to 4.5.2.

I could go down to 4.5 or less but this 4.5.1-r2 is a compiler I've built a decent kernel with already.......I just seem to be building carpy ones now.    :Crying or Very sad: 

nope 4.5.1-r2 will do it to!Last edited by augury on Sat Jan 08, 2011 4:10 am; edited 3 times in total

----------

## kernelOfTruth

try this patch and setting CFLAGS manually to -O2 -march=native -pipe in the kernel-config

```
diff -Nrupad linux-2.6.37-rc1_plus//init/Kconfig linux-2.6.37-rc1_plus_custom-flags//init/Kconfig

--- linux-2.6.37-rc1_plus//init/Kconfig   2010-11-05 17:06:42.089199955 +0100

+++ linux-2.6.37-rc1_plus_custom-flags//init/Kconfig   2010-11-05 17:35:55.460199956 +0100

@@ -811,6 +811,32 @@ config CC_OPTIMIZE_FOR_SIZE

 

      If unsure, say Y.

 

+menu "Custom Build Flags"

+

+config CUSTOM_CFLAGS

+    string "Custom CFLAGS for kernel"

+    default ""

+    help

+        You can use this to easily set custom gcc CFLAGS to be used for the

+        entire kernel (including modules).

+

+   No warning for you, i can't fix stupidity.

+

+        If unsure, leave blank.

+

+config CUSTOM_MAKEFLAGS

+    string "Custom MAKEFLAGS for kernel"

+    default ""

+    help

+        You can use this to easily set custom MAKEFLAGS to be used for building

+        the entire kernel.

+

+   (Or just use the options when you run make?)

+

+        If unsure, leave blank.

+

+endmenu

+

 config SYSCTL

    bool

 

diff -Nrupad linux-2.6.37-rc1_plus//Makefile linux-2.6.37-rc1_plus_custom-flags//Makefile

--- linux-2.6.37-rc1_plus//Makefile   2010-11-05 17:08:06.057199956 +0100

+++ linux-2.6.37-rc1_plus_custom-flags//Makefile   2010-11-05 17:36:39.574199957 +0100

@@ -334,10 +334,10 @@ CHECK      = sparse

 

 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \

         -Wbitwise -Wno-return-void $(CF)

-CFLAGS_MODULE   =

-AFLAGS_MODULE   =

+CFLAGS_MODULE   = $(MODFLAGS) $(CUSTOM_CFLAGS)

+AFLAGS_MODULE   = $(MODFLAGS)

 LDFLAGS_MODULE  =

-CFLAGS_KERNEL   =

+CFLAGS_KERNEL   = $(CUSTOM_CFLAGS)

 AFLAGS_KERNEL   =

 CFLAGS_GCOV   = -fprofile-arcs -ftest-coverage

 

@@ -350,6 +350,9 @@ LINUXINCLUDE    := -I$(srctree)/arch/$(h

 

 KBUILD_CPPFLAGS := -D__KERNEL__

 

+# Apply custom flags

+KBUILD_CFLAGS    += $(CUSTOM_CFLAGS)

+

 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \

          -fno-strict-aliasing -fno-common \

          -Werror-implicit-function-declaration \
```

----------

## augury

I'm unpacking another fresh source now.

----------

## augury

This could be a section mismatch problem

```
Kernel: arch/x86/boot/bzImage is ready  (#1)

  MODPOST 406 modules

WARNING: modpost: Found 16 section mismatch(es).

To see full details build your kernel with:

'make CONFIG_DEBUG_SECTION_MISMATCH=y'

```

hmm

----------

## augury

```
'make -j6 CONFIG_DEBUG_SECTION_MISMATCH=y' 
```

That built a working kernel, while "make -j6" did not.  Fortunately in under 15 minutes.  The variable is a pity.

It seems to call the flag -fno-inline-functions-called-once.   I'm glad I don't run that sort of kernel, though.

I'm building again with just the flag to see if this THE fix I need.

----------

## augury

Done.  wish bios wasn't a snooze.

----------

## augury

I got another __bad_udelay.  

```
-Werror-implicit-function-declaration
```

 What is this?  now I have no unswitching or peel.

----------

## augury

I booted something without an -mpreferred ~ 2.

-g0 seems to be the fail.  Not very verbose, is it?  I still have a tg3 for my net driver though.

not one module was installed somehow but I have modules I've never seen before loaded in my lsmod.  hmm.  and aic94xx firmware in the binary.

----------

## augury

My rank 4 memory modules are 70 and 67 degrees C. too hot, too hot     :Surprised:    GPU is 38C.  

My CPU is -48C.

----------

