where is headers_install in KBUILD
Hello, Now i want to compile kernel and test userspace program fastly and i find a good guide link: https://vincent.bernat.ch/en/blog/2014-eudyptula-boot In the article, author compile kernel with KBUILD(custom install vmlinux...) 1. export KBUILD_OPTPUT=$HOME/src/kernel-build Is this generate a copy of linux kernel source, right? 2. edit .config and make 3. sudo make modules_install install {INSTALL_MOD_PATH,INSTALL_PATH}=$HOME/src/kernel-dev Ok, I did it and booted a VM with qemu, it is cool. But, my "question" is: when i test some program which needs kernel headers, where to install those headers file? In Documention/kbuild/headers_install.rst, i learn it : make headers_install INSTALL_HDR_PATH=/usr In my case, Is it ok to do that?I do not think it will work. May i: make headers_install INSTALL_HDR_PATH=$HOME/src/kernel-headers is it Ok? Thank you very much! Bo
On Mon, 25 Feb 2019 06:43:39 -0500, YU Bo said:
But, my "question" is: when i test some program which needs kernel headers, where to install those headers file? In Documention/kbuild/headers_install.rst, i learn it : make headers_install INSTALL_HDR_PATH=/usr In my case, Is it ok to do that?I do not think it will work.
You need to put the headers into a directory that will be accessible to your "program that needs kernel headers" at build time. Hint: gcc has a "-I" option for a reason, and CFLAGS is an actual thing for a reason.... Note that in general, most programs *won't* need the new kernel headers, because glibc (or musl, or whatever your libc is) will be insulating you from the actual syscall interface anyhow. Also, dropping the headers into /usr/include is dangerous, as the next time you apply software updates, they could overlay your version of the headers with the distro's version, which will cause lots of debugging fun the next time you rebuild your program and it builds against old headers. If you're lucky, the build will fail. If you're unlucky, the program will build but fail in subtle ways at runtime....
On Tue, Feb 26, 2019 at 1:54 AM <valdis.kletnieks@vt.edu> wrote:
On Mon, 25 Feb 2019 06:43:39 -0500, YU Bo said:
But, my "question" is: when i test some program which needs kernel headers, where to install those headers file? In Documention/kbuild/headers_install.rst, i learn it : make headers_install INSTALL_HDR_PATH=/usr In my case, Is it ok to do that?I do not think it will work.
You need to put the headers into a directory that will be accessible to your "program that needs kernel headers" at build time. Hint: gcc has a "-I" option for a reason, and CFLAGS is an actual thing for a reason....
Note that in general, most programs *won't* need the new kernel headers, because glibc (or musl, or whatever your libc is) will be insulating you from the actual syscall interface anyhow.
Also, dropping the headers into /usr/include is dangerous, as the next time you apply software updates, they could overlay your version of the headers with the distro's version, which will cause lots of debugging fun the next time you rebuild your program and it builds against old headers. If you're lucky, the build will fail. If you're unlucky, the program will build but fail in subtle ways at runtime....
Thank you for reply.I do not kow to explain the way,but i tried it. In my case, ```bash # cd ~/src/kernel-dev/lib/modules/5.0.0-rc8/build make headers_install ``` I think the way, which can effect VM(i logged in). Thank you :)
participants (3)
-
Bo YU -
valdis.kletnieks@vt.edu -
YU Bo