LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-12-2020, 01:57 AM   #1
rabbull
LQ Newbie
 
Registered: May 2020
Posts: 4

Rep: Reputation: Disabled
Unhappy Failed to build Linux Kernel 4.15


I'm trying to build linux kernel 4.15 but failed, with tons of error messages. Seems not only one thing went wrong. Specific information are found below.

build platform specifications:
  • gcc: 9.3.0
  • make: 4.3
  • libelf: 0.178

build commands:
Code:
$ mkdir build
$ make O=`pwd`/build/ mrproper
$ make ARCH=x86_64 O=`pwd`/build/ x86_64_defconfig
$ make ARCH=x86_64 O=`pwd`/build/ -j`nproc`
error messages:
Code:
In file included from /usr/include/gelf.h:32,
                 from arch/x86/../../elf.h:22,
                 from arch/x86/decode.c:26:
/usr/include/libelf.h:46:4: error: unknown type name ‘Elf32_Word’
   46 |    Elf32_Word   ch_type;        /* Compression format.  */
      |    ^~~~~~~~~~
/usr/include/libelf.h:47:4: error: unknown type name ‘Elf32_Word’
   47 |    Elf32_Word   ch_size;        /* Uncompressed data size.  */
      |    ^~~~~~~~~~
/usr/include/libelf.h:48:4: error: unknown type name ‘Elf32_Word’
   48 |    Elf32_Word   ch_addralign;   /* Uncompressed data alignment.  */
      |    ^~~~~~~~~~
/usr/include/libelf.h:53:4: error: unknown type name ‘Elf64_Word’
   53 |    Elf64_Word   ch_type;        /* Compression format.  */
      |    ^~~~~~~~~~
/usr/include/libelf.h:54:4: error: unknown type name ‘Elf64_Word’
   54 |    Elf64_Word   ch_reserved;
      |    ^~~~~~~~~~
/usr/include/libelf.h:55:4: error: unknown type name ‘Elf64_Xword’
   55 |    Elf64_Xword  ch_size;        /* Uncompressed data size.  */
      |    ^~~~~~~~~~~
/usr/include/libelf.h:56:4: error: unknown type name ‘Elf64_Xword’
   56 |    Elf64_Xword  ch_addralign;   /* Uncompressed data alignment.  */
      |    ^~~~~~~~~~~
/usr/include/libelf.h:255:8: error: unknown type name ‘Elf32_Ehdr’
  255 | extern Elf32_Ehdr *elf32_getehdr (Elf *__elf);
      |        ^~~~~~~~~~
/usr/include/libelf.h:257:8: error: unknown type name ‘Elf64_Ehdr’
  257 | extern Elf64_Ehdr *elf64_getehdr (Elf *__elf);
      |        ^~~~~~~~~~
/usr/include/libelf.h:260:8: error: unknown type name ‘Elf32_Ehdr’
  260 | extern Elf32_Ehdr *elf32_newehdr (Elf *__elf);
      |        ^~~~~~~~~~
/usr/include/libelf.h:262:8: error: unknown type name ‘Elf64_Ehdr’
  262 | extern Elf64_Ehdr *elf64_newehdr (Elf *__elf);
      |        ^~~~~~~~~~
/usr/include/libelf.h:271:8: error: unknown type name ‘Elf32_Phdr’
  271 | extern Elf32_Phdr *elf32_getphdr (Elf *__elf);
      |        ^~~~~~~~~~
/usr/include/libelf.h:273:8: error: unknown type name ‘Elf64_Phdr’
  273 | extern Elf64_Phdr *elf64_getphdr (Elf *__elf);
      |        ^~~~~~~~~~
/usr/include/libelf.h:276:8: error: unknown type name ‘Elf32_Phdr’
  276 | extern Elf32_Phdr *elf32_newphdr (Elf *__elf, size_t __cnt);
      |        ^~~~~~~~~~
/usr/include/libelf.h:278:8: error: unknown type name ‘Elf64_Phdr’
  278 | extern Elf64_Phdr *elf64_newphdr (Elf *__elf, size_t __cnt);
      |        ^~~~~~~~~~
/usr/include/libelf.h:285:43: error: unknown type name ‘Elf32_Off’
  285 | extern Elf_Scn *elf32_offscn (Elf *__elf, Elf32_Off __offset);
      |                                           ^~~~~~~~~
/usr/include/libelf.h:287:43: error: unknown type name ‘Elf64_Off’
  287 | extern Elf_Scn *elf64_offscn (Elf *__elf, Elf64_Off __offset);
      |                                           ^~~~~~~~~
/usr/include/libelf.h:327:8: error: unknown type name ‘Elf32_Shdr’
  327 | extern Elf32_Shdr *elf32_getshdr (Elf_Scn *__scn);
      |        ^~~~~~~~~~
/usr/include/libelf.h:329:8: error: unknown type name ‘Elf64_Shdr’
  329 | extern Elf64_Shdr *elf64_getshdr (Elf_Scn *__scn);
      |        ^~~~~~~~~~
In file included from arch/x86/../../elf.h:22,
                 from arch/x86/decode.c:26:
/usr/include/gelf.h:44:9: error: unknown type name ‘Elf64_Half’
   44 | typedef Elf64_Half GElf_Half;
      |         ^~~~~~~~~~
/usr/include/gelf.h:47:9: error: unknown type name ‘Elf64_Word’
   47 | typedef Elf64_Word GElf_Word;
      |         ^~~~~~~~~~
/usr/include/gelf.h:48:9: error: unknown type name ‘Elf64_Sword’
   48 | typedef Elf64_Sword GElf_Sword;
      |         ^~~~~~~~~~~
/usr/include/gelf.h:51:9: error: unknown type name ‘Elf64_Xword’
   51 | typedef Elf64_Xword GElf_Xword;
      |         ^~~~~~~~~~~
/usr/include/gelf.h:52:9: error: unknown type name ‘Elf64_Sxword’
   52 | typedef Elf64_Sxword GElf_Sxword;
      |         ^~~~~~~~~~~~
/usr/include/gelf.h:55:9: error: unknown type name ‘Elf64_Addr’
   55 | typedef Elf64_Addr GElf_Addr;
      |         ^~~~~~~~~~
/usr/include/gelf.h:58:9: error: unknown type name ‘Elf64_Off’
   58 | typedef Elf64_Off GElf_Off;
      |         ^~~~~~~~~
/usr/include/gelf.h:62:9: error: unknown type name ‘Elf64_Ehdr’
   62 | typedef Elf64_Ehdr GElf_Ehdr;
      |         ^~~~~~~~~~
/usr/include/gelf.h:65:9: error: unknown type name ‘Elf64_Shdr’
   65 | typedef Elf64_Shdr GElf_Shdr;
      |         ^~~~~~~~~~
/usr/include/gelf.h:70:9: error: unknown type name ‘Elf64_Section’
   70 | typedef Elf64_Section GElf_Section;
      |         ^~~~~~~~~~~~~
/usr/include/gelf.h:73:9: error: unknown type name ‘Elf64_Sym’
   73 | typedef Elf64_Sym GElf_Sym;
      |         ^~~~~~~~~
/usr/include/gelf.h:77:9: error: unknown type name ‘Elf64_Syminfo’
   77 | typedef Elf64_Syminfo GElf_Syminfo;
      |         ^~~~~~~~~~~~~
/usr/include/gelf.h:80:9: error: unknown type name ‘Elf64_Rel’
   80 | typedef Elf64_Rel GElf_Rel;
      |         ^~~~~~~~~
/usr/include/gelf.h:83:9: error: unknown type name ‘Elf64_Rela’
   83 | typedef Elf64_Rela GElf_Rela;
      |         ^~~~~~~~~~
/usr/include/gelf.h:86:9: error: unknown type name ‘Elf64_Phdr’
   86 | typedef Elf64_Phdr GElf_Phdr;
      |         ^~~~~~~~~~
/usr/include/gelf.h:92:9: error: unknown type name ‘Elf64_Dyn’
   92 | typedef Elf64_Dyn GElf_Dyn;
      |         ^~~~~~~~~
/usr/include/gelf.h:96:9: error: unknown type name ‘Elf64_Verdef’
   96 | typedef Elf64_Verdef GElf_Verdef;
      |         ^~~~~~~~~~~~
/usr/include/gelf.h:99:9: error: unknown type name ‘Elf64_Verdaux’
   99 | typedef Elf64_Verdaux GElf_Verdaux;
      |         ^~~~~~~~~~~~~
/usr/include/gelf.h:102:9: error: unknown type name ‘Elf64_Verneed’
  102 | typedef Elf64_Verneed GElf_Verneed;
      |         ^~~~~~~~~~~~~
/usr/include/gelf.h:105:9: error: unknown type name ‘Elf64_Vernaux’
  105 | typedef Elf64_Vernaux GElf_Vernaux;
      |         ^~~~~~~~~~~~~
/usr/include/gelf.h:109:9: error: unknown type name ‘Elf64_Versym’
  109 | typedef Elf64_Versym GElf_Versym;
      |         ^~~~~~~~~~~~
/usr/include/gelf.h:113:9: error: unknown type name ‘Elf64_auxv_t’
  113 | typedef Elf64_auxv_t GElf_auxv_t;
      |         ^~~~~~~~~~~~
/usr/include/gelf.h:117:9: error: unknown type name ‘Elf64_Nhdr’
  117 | typedef Elf64_Nhdr GElf_Nhdr;
      |         ^~~~~~~~~~
/usr/include/gelf.h:121:9: error: unknown type name ‘Elf64_Move’
  121 | typedef Elf64_Move GElf_Move;
      |         ^~~~~~~~~~
/usr/include/gelf.h:125:9: error: unknown type name ‘Elf64_Lib’
  125 | typedef Elf64_Lib GElf_Lib;
      |         ^~~~~~~~~
/usr/include/gelf.h:232:8: error: unknown type name ‘Elf32_Word’; did you mean ‘GElf_Word’?
  232 |        Elf32_Word *__xshndx);
      |        ^~~~~~~~~~
      |        GElf_Word
/usr/include/gelf.h:238:6: error: unknown type name ‘Elf32_Word’; did you mean ‘GElf_Word’?
  238 |      Elf32_Word __xshndx);
      |      ^~~~~~~~~~
      |      GElf_Word
Code:
arch/x86/decode.c: In function ‘is_x86_64’:
arch/x86/decode.c:43:19: error: request for member ‘e_machine’ in something not a structure or union
   43 |  switch (elf->ehdr.e_machine) {
      |                   ^
arch/x86/decode.c:44:7: error: ‘EM_X86_64’ undeclared (first use in this function); did you mean ‘is_x86_64’?
   44 |  case EM_X86_64:
      |       ^~~~~~~~~
      |       is_x86_64
arch/x86/decode.c:44:7: note: each undeclared identifier is reported only once for each function it appears in
arch/x86/decode.c:46:7: error: ‘EM_386’ undeclared (first use in this function)
   46 |  case EM_386:
      |       ^~~~~~
In file included from arch/x86/decode.c:28:
arch/x86/decode.c:49:51: error: request for member ‘e_machine’ in something not a structure or union
   49 |   WARN("unexpected ELF machine type %d", elf->ehdr.e_machine);
      |                                                   ^
arch/x86/../../warn.h:58:14: note: in definition of macro ‘WARN’
   58 |   objname, ##__VA_ARGS__)
      |              ^~~~~~~~~~~
Code:
arch/x86/decode.c:52:1: error: control reaches end of non-void function [-Werror=return-type]
   52 | }
      | ^
Code:
pager.c: In function ‘pager_preexec’:
pager.c:36:12: error: passing argument 2 to restrict-qualified parameter aliases with argument 4 [-Werror=restrict]
   36 |  select(1, &in, NULL, &in, NULL);
      |            ^~~        ~~~
 
Old 05-13-2020, 04:02 AM   #2
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Thumbs up

Well, what I do is to start with the first error message and google it
Code:
libelf.h:46:4: error: unknown type name ‘Elf32_Word’
That came back with this:
https://mremallin.ca/2018/12/30/linu...lure-debian-9/
Which suggested this:
Code:
Turns out  it is my CPATH environment variable causing issues with the libelf header inclusion. Clearing the environment variable fixed the above compilation issue.
That's your starting point, just go through each error message like this always starting with the first one, clear the error and run the build again till no errors and you'll have a successful build!
 
1 members found this post helpful.
Old 05-13-2020, 04:57 AM   #3
rabbull
LQ Newbie
 
Registered: May 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by GPGAgent View Post
Well, what I do is to start with the first error message and google it
Code:
libelf.h:46:4: error: unknown type name ‘Elf32_Word’
That came back with this:
https://mremallin.ca/2018/12/30/linu...lure-debian-9/
Which suggested this:
Code:
Turns out  it is my CPATH environment variable causing issues with the libelf header inclusion. Clearing the environment variable fixed the above compilation issue.
That's your starting point, just go through each error message like this always starting with the first one, clear the error and run the build again till no errors and you'll have a successful build!
Your advice is really helpful. I'm now working on it. Thanks.
 
Old 05-13-2020, 07:24 AM   #4
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by rabbull View Post
I'm trying to build linux kernel 4.15 but failed, with tons of error messages.
I do wonder why you would be working on such an older (and EOL) kernel?
Kernel 4.15 had been released on 28 Jan 2018 and had its last update (4.15.18) about 3 months later on 19 Apr 2018
It was a short-term release, unlike 4.14 and 4.19, which both are still supported by the kernel team.
 
Old 05-13-2020, 11:39 AM   #5
rabbull
LQ Newbie
 
Registered: May 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ehartman View Post
I do wonder why you would be working on such an older (and EOL) kernel?
Kernel 4.15 had been released on 28 Jan 2018 and had its last update (4.15.18) about 3 months later on 19 Apr 2018
It was a short-term release, unlike 4.14 and 4.19, which both are still supported by the kernel team.
Actually I didn't mean to either.

An assignment of mine requires a linux kernel module works on Deepin 15.11, which uses a fork of Kernel 4.15 by default. I'm attempting to cross-compile the module (and test on a VM later) in order to avoid installing Deepin on my laptop or coding on a VM. It turns out that I should have kernel 4.15 compiled to manage to it.

I'd appreciate any other ideas that help me out.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Linux 4.4 seems to refuse to build IPv6 for the 64-bit build - 32-bit build works fine GameCodingNinja Linux From Scratch 2 02-07-2016 06:40 PM
SBCL build from slack builds fails to build - failed contribs sb-bsd-sockets sunlight Slackware 3 11-07-2015 04:31 PM
build doesn't stop even if one of the components failed to build 5883 Programming 1 11-12-2012 09:38 AM
[SOLVED] boost-build failed to build engine Red Hat 4.1.2 and GCC 4.1.2 Fritz_Doll Programming 2 08-10-2012 02:00 PM
LXer: Build 'em Right, Build 'em Strong, Build 'em Linux LXer Syndicated Linux News 0 10-01-2007 09:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration