Let me several questions about kernel compilation?

22 Antworten [Letzter Beitrag]
znavko
Offline
Beigetreten: 06/11/2018

Hello! I use trisquel 8.0. I have no sense how to compile kernel, I tried once it worked on 1 laptop, the other laptop stops and does not compile every time. Please, what is wrong in these actions:

# apt-get update
# apt-get upgrade

# apt-get install dpkg-dev libncurses5-dev kernel-package fakeroot bzip2 build-essential

# uname -a
Linux asus 4.4.0-119-generic #143+8.0trisquel2 SMP Thu Apr 5 16:24:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

# ls /boot
abi-4.4.0-119-generic grub retpoline-4.4.0-119-generic vmlinuz-4.4.0-119-generic
config-4.4.0-119-generic initrd.img-4.4.0-119-generic System.map-4.4.0-119-generic

# apt-cache search linux-source
linux-source-4.4.0 - Linux-libre kernel source for version 4.4.0
linux-source - Linux kernel source with Ubuntu patches
linux-source-4.13.0 - Linux-libre kernel source for version 4.13.0
linux-source-4.8.0 - Linux-libre kernel source for version 4.8.0

# apt-get source linux-source-4.13.0

# ls
linux-hwe-4.13.0 linux-hwe_4.13.0-45.50~16.04.1+8.0trisquel1.dsc linux-hwe_4.13.0-45.50~16.04.1+8.0trisquel1.tar.gz mybuild

# cd linux-hwe-4.13.0

# make O=/home/user/kernel/mybuild menuconfig

Then I loaded config from /boot/config-4.4.0-119-generic, switched off that I do not need: IRDA и Bluetooth then saved config into /home/user/kernel/mybuild/.config

# make O=/home/user/kernel/mybuild

/bin/bash /home/y/kernel/linux-hwe-4.13.0/scripts/ubuntu-retpoline-extract-one arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.o /home/y/kernel/linux-hwe-4.13.0/arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S "";
AS [M] arch/x86/crypto/sha1-mb/sha1_x8_avx2.o
/bin/bash /home/y/kernel/linux-hwe-4.13.0/scripts/ubuntu-retpoline-extract-one arch/x86/crypto/sha1-mb/sha1_x8_avx2.o /home/y/kernel/linux-hwe-4.13.0/arch/x86/crypto/sha1-mb/sha1_x8_avx2.S "";
LD [M] arch/x86/crypto/sha1-mb/sha1-mb.o
AS arch/x86/entry/entry_64.o
Segmentation fault
/home/y/kernel/linux-hwe-4.13.0/scripts/Makefile.build:419: ошибка выполнения рецепта для цели «arch/x86/entry/entry_64.o»
make[3]: *** [arch/x86/entry/entry_64.o] Ошибка 139
/home/y/kernel/linux-hwe-4.13.0/scripts/Makefile.build:589: ошибка выполнения рецепта для цели «arch/x86/entry»
make[2]: *** [arch/x86/entry] Ошибка 2
/home/y/kernel/linux-hwe-4.13.0/Makefile:1055: ошибка выполнения рецепта для цели «arch/x86»
make[1]: *** [arch/x86] Ошибка 2
make[1]: выход из каталога «/home/y/kernel/mybuild»
Makefile:145: ошибка выполнения рецепта для цели «sub-make»
make: *** [sub-make] Ошибка 2

Sorry? Why does it stop?

znavko
Offline
Beigetreten: 06/11/2018

Is it a kernel bug or my own mistake?

jxself
Offline
Beigetreten: 09/13/2010

"Segmentation fault" is an important message there. I don't know what the rests says because they're in Russian and I only speak English.

I notice you're building 4.13 but using a .config from 4.4. There will be configuration file differences that need to be accounted for. Run make oldconfig first to answer the questions. You can also use mine for 4.13 if you'd rather: https://jxself.org/git/?p=kernel-configs.git

Also, instead of 'make' try 'make bindeb-pkg' - Then you'll get .deb files that can be used with the package manager.

znavko
Offline
Beigetreten: 06/11/2018

jxself, thank you.

make menuconfig
make oldconfig
make

cause the same error: segmentation faul. Ur config for 4.13 forced me to answer several questions. I only pressed enter. So the error rests - Segmentation fault.

Megver83
Offline
Beigetreten: 12/21/2015

which GCC version are you using?

Megver83
Offline
Beigetreten: 12/21/2015

It seems that the /home/y/kernel/linux-hwe-4.13.0/scripts/ubuntu-retpoline-extract-one script does something wrong. Why don't you better fo everything manually?

znavko
Offline
Beigetreten: 06/11/2018

Thank you for reply.

# gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

manually? I am using linux-libre, cause it is free. I cannot remove everything non-free from kernel.org releases. So that script you show is default linux-libre script.

... I downloaded linux-source-4.4.0 and started `make menuconfig && make` . I did not use my current config. Just rested things as they were and also disabled bluetooth and irda. Now it is making for 20 minutes. (Making of 4.13 stopped after 4 minutes). There are warnings but it does not stop, warnings like this:

linux-4.4.0/mm/compaction.c:1398:2: warning: enumeration value ‘COMPACT_INACTIVE’ not handled in switch [-Wswitch]

I think config for 4.4 cannot work for 4.13.

Why there is no anywhere info about how to get config for upstream version ? I thought kernel has no any configuration set and I tried to use my current config.

Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

What do you mean by "it does not stop"? Compiling Linux (especially without using make's "jobs" option) takes time. And, yes, Linux's compilation rises many warnings (it is "normal").

jxself
Offline
Beigetreten: 09/13/2010

"I thought kernel has no any configuration set and I tried to use my current config."

The kernel does need to be configured: This is the time where you get to decide exactly what parts of the kernel should be built and how they should work. Like what scheduler do you want to use? https://en.wikipedia.org/wiki/Scheduling_(computing)#Since_Linux_2.6.23

And there's lots more too.

Further, that config varies from one major release to another (so a config for 4.4 will be different from 4.13 because each new release introduces new and changed features, so the config must be updated to cover the differences. This is what "make oldconfig" is for: Taking a config from an old version and updating it based on whatever version you're building.) The kernel config will also vary from one CPU architecture to another (so a config for 32-bit x86 will be different from 64-bit and will be different from ARM and MIPS and RISC-V...) Not only because they are different CPUs but also because some kernel features are only relevant on certain kinds of machines. You can explore all of the options when doing "make nconfig" but there's also lots of information online too. Configuring the kernel is a topic of much discussion.

znavko
Offline
Beigetreten: 06/11/2018

make stops with fatal error, I achieve nothing.

Please, where can I find kernel build log? I 've leaved pc on 'make' execution, after that it was switched off due to os error. I want to understand if make was finished or not

Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

What error? If it is a segmentation error, it may be a hardware issue. I would check the RAM with "memtest86+" (in Trisquel's repository, to be launched from the bootloader; let it run a whole night).

Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

Just run the 'make' command again. It will not relaunch the compilation of what has already been compiled (in particular, it will not compile anything if it has already compiled everything).

znavko
Offline
Beigetreten: 06/11/2018

Sorry. Why 1 laptop trisquel 8 has only one linux-source, but other - 4 ones.

-------1st:------
# apt-get update
Сущ:1 http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu xenial InRelease
Сущ:2 https://archive.trisquel.info/trisquel flidas InRelease
Пол:3 https://archive.trisquel.info/trisquel flidas-security InRelease [4 898 B]
Пол:4 https://archive.trisquel.info/trisquel flidas-security/main Sources [178 kB]
Пол:5 https://archive.trisquel.info/trisquel flidas-security/main amd64 Packages [684 kB]
Пол:6 https://archive.trisquel.info/trisquel flidas-security/main i386 Packages [681 kB]
Получено 1 547 kБ за 3с (449 kБ/c)
Чтение списков пакетов… Готово

# apt-cache search linux-source
linux-source-4.4.0 - Linux-libre kernel source for version 4.4.0

# lsb_release -a
No LSB modules are available.
Distributor ID: Trisquel
Description: Trisquel GNU/Linux 8.0, Flidas
Release: 8.0
Codename: flidas

--------2nd--------
# apt-get update
Сущ:1 https://archive.trisquel.info/trisquel flidas InRelease
Сущ:2 https://archive.trisquel.info/trisquel flidas-security InRelease
Сущ:3 https://archive.trisquel.info/trisquel flidas-updates InRelease
Чтение списков пакетов… Готово

# apt-cache search linux-source
linux-source-4.4.0 - Linux-libre kernel source for version 4.4.0
linux-source - Linux kernel source with Ubuntu patches
linux-source-4.13.0 - Linux-libre kernel source for version 4.13.0
linux-source-4.8.0 - Linux-libre kernel source for version 4.8.0

# lsb_release
No LSB modules are available.

# lsb_release -a
No LSB modules are available.
Distributor ID: Trisquel
Description: Trisquel GNU/Linux 8.0, Flidas
Release: 8.0
Codename: flidas

Why so different results ? Where is linux-source-4.13.0 on my first laptop??

jxself
Offline
Beigetreten: 09/13/2010

Check your sources.list. They don't seem to be identical.

znavko
Offline
Beigetreten: 06/11/2018

Hello! I tried to compile linux-source-4.4.0 without any changes, resting config as it was there.

# make menuconfig
...without any changes I saved .config
# make

it worked ok. So now I try again to make with no bluetooth and no irda.

Every time I have difficult to understand why Xen, Android, Fujitsu, Miscrosoft Hyper-V and many other stuff are there. When I switching off all I see as unnecessary the make breaks. `make` takes 10 hours for my asus x552e.

Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

Some configurations are indeed incorrect. As I already wrote, you want to use make's "jobs" (-j) option. For instance:
$ make -j 5
The more cores you have, the highest the argument can be (in it a number of source files compiled in parallel).

znavko
Offline
Beigetreten: 06/11/2018

------1st laptop--------
cat /etc/apt/sources.list
# deb cdrom:[Trisquel 8.0 _flidas_ - Release amd64 (20180417)]/ flidas main

# Trisquel repositories for supported software and updates
deb https://archive.trisquel.info/trisquel/ flidas main
deb-src https://archive.trisquel.info/trisquel/ flidas main
deb https://archive.trisquel.info/trisquel/ flidas-security main
deb-src https://archive.trisquel.info/trisquel/ flidas-security main
# deb http://mirrors.serverhost.ro/trisquel/packages flidas-backports main
# deb-src http://mirrors.serverhost.ro/trisquel/packages flidas-backports main

-----2nd laptop------

# cat /etc/apt/sources.list
# deb cdrom:[Trisquel 8.0 _flidas_ - Release amd64 (20180417)]/ flidas main

# Trisquel repositories for supported software and updates
deb https://archive.trisquel.info/trisquel/ flidas main
deb-src https://archive.trisquel.info/trisquel/ flidas main
deb https://archive.trisquel.info/trisquel/ flidas-security main
deb-src https://archive.trisquel.info/trisquel/ flidas-security main
deb https://archive.trisquel.info/trisquel/ flidas-updates main
deb-src https://archive.trisquel.info/trisquel/ flidas-updates main
# deb http://mirrors.serverhost.ro/trisquel/packages flidas-backports main
# deb-src http://mirrors.serverhost.ro/trisquel/packages flidas-backports main

jxself
Offline
Beigetreten: 09/13/2010

Well, you can see the difference right? As you compare line by line they're not identical: One has Flidas Main and Security. The other has Flidas Main, Security, and Updates.

znavko
Offline
Beigetreten: 06/11/2018

ok. I see it.

When I do not touch config `make` finishes ok. But now I switched off IrDa, Bluetooth, Xen drivers, Hyper-V, Fujitsu, all wifi manufacturers except my Atheros. And make failed with this:

LD arch/x86/boot/compressed/vmlinux
ZOFFSET arch/x86/boot/zoffset.h
OBJCOPY arch/x86/boot/vmlinux.bin
AS arch/x86/boot/header.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
BUILD arch/x86/boot/bzImage
Setup is 17372 bytes (padded to 17408 bytes).
System is 5424 kB
CRC 4a768971
Kernel: arch/x86/boot/bzImage is ready (#1)
ERROR: "hci_register_dev" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
ERROR: "hci_recv_frame" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
ERROR: "hci_unregister_dev" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
ERROR: "hci_alloc_dev" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
ERROR: "hci_free_dev" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
/home/user/kernel/linux-4.4.0/scripts/Makefile.modpost:91: Error execution operation for «__modpost»
make[2]: *** [__modpost] Error 1
/home/user/kernel/linux-4.4.0/Makefile:1153: Error execution operation for «modules»
make[1]: *** [modules] Error 2
make[1]: exiting directory «/home/user/kernel/mybuild»
Makefile:152: Error execution operation for «sub-make»
make: *** [sub-make] Error 2

# cat /home/user/kernel/mybuild/.config | nc termbin.com 9999
http://termbin.com/ef1w

Please, teach me how disable unnecessary stuff knowing definitely make will not stop.

jxself
Offline
Beigetreten: 09/13/2010

Your config mentions 4.4.128 so I first try with mainline Linux-libre:

wget https://linux-libre.fsfla.org/pub/linux-libre/releases/4.4.128-gnu/linux-libre-4.4.128-gnu.tar.xz
tar xf linux-libre-4.4.128-gnu.tar.xz
cd linux-libre-4.4.128
wget http://termbin.com/ef1w
mv ef1w .config
make oldconfig
make -j4 bindeb-pkg

And it builds.

Then I try Trisquel's modified version of Linux-libre:

apt-get source linux-source-4.4.0
cd linux-4.4.0
wget http://termbin.com/ef1w
mv ef1w .config
make oldconfig
make -j4 bindeb-pkg

And that fails:

ERROR: "hci_register_dev" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
ERROR: "hci_recv_frame" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
ERROR: "hci_unregister_dev" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
ERROR: "hci_alloc_dev" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
ERROR: "hci_free_dev" [ubuntu/rsi/ven_rsi_91x.ko] undefined!
scripts/Makefile.modpost:91: recipe for target '__modpost' failed
make[3]: *** [__modpost] Error 1
Makefile:1153: recipe for target 'modules' failed
make[2]: *** [modules] Error 2
scripts/package/Makefile:96: recipe for target 'bindeb-pkg' failed
make[1]: *** [bindeb-pkg] Error 2
Makefile:1284: recipe for target 'bindeb-pkg' failed
make: *** [bindeb-pkg] Error 2

So it's specific to Trisquel. I recommend to file a bug over it. In the meantime you can build mainline Linux-libre just fine, so there's your workaround. Although you may want to upgrade to the current version in the 4.4 series which is 4.4.138. But it's up to you of course.

znavko
Offline
Beigetreten: 06/11/2018

jxself, thanks a lot!

I have compiled last Libre-linux and successfully boot into it. I used only menuconfig and disabled bluetooth, ipv6, xen, all wifi modules except my atheros.

But the kernel boot time becomes twice bigger than I had on 4.4.0

Now I have:

$ uname -a
Linux asus 4.17.3-gnu #1 SMP Wed Jun 27 21:09:44 +03 2018 x86_64 x86_64 x86_64 GNU/Linux

$ systemd-analyze
Startup finished in 35.301s (kernel) + 1min 38.982s (userspace) = 2min 14.284s

$ cat /home/user/kernel/mybuild/.config | nc termbin.com 9999
http://termbin.com/xer0

$ dmesg
[ 23.880080] usb 5-2: new full-speed USB device number 2 using xhci_hcd
[ 23.952630] ACPI: Video Device [VGA] (multi-head: yes rom: no post: no)
[ 23.989023]
3ACPI BIOS Error (bug): Could not resolve [^^^PB2.VGA.AFN7], AE_NOT_FOUND (20180313/psargs-330)
[ 23.989054] ACPI Error: Method parse/execution failed \_SB.PCI0.VGA.LCDD._BCM, AE_NOT_FOUND (20180313/psparse-516)
[ 23.991492] ACPI Error: Evaluating _BCM failed (20180313/video-364)
[ 23.993303] input: Video Bus as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/LNXVIDEO:00/input/input9

But I had on 4.4.0 this:

$ systemd-analyze
Startup finished in 11.933s (kernel) + 5.280s (userspace) = 17.214s

$ cat /boot/config-4.4.0-128-generic | nc termbin.com 9999
http://termbin.com/rf1q

and I had bluetooth errors on boot.

----
I think boot time depends on components that are enabled in 4.17.3 kernel.
Please, let me know how to optimize kernel in my situation?

jxself
Offline
Beigetreten: 09/13/2010

"Please, let me know how to optimize kernel in my situation?"

You could try build a kernel with make localyesconfig or make localmodconfig which will only include the module currently loaded on your system (so make sure all modules you need are presently loaded or they won't be available in the new kernel.) But that will probably only help with compile time by not building stuff you don't need and with the size of the kernel since those won't be there. I don't expect it to make much of a difference in start up time.

znavko
Offline
Beigetreten: 06/11/2018

I tried completely to disable all options in linux-libre-4.17.3-gnu kernel and compile it. I installed kernel and modules and then booted to iniramfs, so my system works not proper way on it.

I need to delete safely new broken kernels. How to do this?

# dpkg -l | grep linux-image | awk '{print$2}'
linux-image-4.4.0-119-generic
linux-image-extra-4.4.0-119-generic
linux-image-generic

# ls -1 /boot
abi-4.4.0-119-generic
config-4.17.3-gnu
config-4.17.3-gnu.old
config-4.4.0-119-generic
config-4.4.15-gnu
grub
initrd.img-4.17.3-gnu
initrd.img-4.4.0-119-generic
initrd.img-4.4.15-gnu
retpoline-4.4.0-119-generic
System.map-4.17.3-gnu
System.map-4.17.3-gnu.old
System.map-4.4.0-119-generic
System.map-4.4.15-gnu
vmlinuz-4.17.3-gnu
vmlinuz-4.17.3-gnu.old
vmlinuz-4.4.0-119-generic
vmlinuz-4.4.15-gnu

# ls -1 /lib/modules/
4.17.3-gnu
4.4.0-119-generic
4.4.15-gnu

--
Please, how delete 4.17.3-gnu, vmlinuz-4.17.3-gnu.old ?? will my pc boot correctly after

# rm -rf vmlinuz-4.17* System.map-4.17* config-4.17* initrd.img-4.17.3-gnu /lib/modules/4.17.3-gnu
# update-grub
# reboot

--
Or it needs something else?

My config of unworkable kernel 4.17.3-gnu is this:

# cat /home/me/kernel/mybuild/.config | nc termbin.com 9999
http://termbin.com/f9zs

# lspci -k | nc termbin.com 9999
http://termbin.com/b8tf

# lsusb | nc termbin.com 9999
Unknown line at line 2468
http://termbin.com/p7wa3