| View previous topic :: View next topic |
| Author |
Message |
aCOSwt Advocate


Joined: 19 Oct 2007 Posts: 2075 Location: Between the keyboard and the chair
|
Posted: Thu Jan 31, 2013 11:39 am Post subject: Using kernel headers |
|
|
Considering a userspace application with source files including <linux/whatever.h>
What is best practice regarding the makefile ?
1/ Nothing special ! => The application *must* be built against installed linux-headers and responsibility for getting appropriate linux-headers *must* be left to who builds the application.
2/ Provide a glibc-like --with-headers configuration switch enabling who builds to set it to whatever kernel-headers path ?
In case of 2/ :
What is best practice regarding a gentoo ebuild for such a package ?
3/ hardcode --with-headers=/usr/src/linux/include ?
4/ Make the use of the kernel-headers vs linux-headers depend on some use flag setting ? _________________ In theory there are no differences between theory and practice. In practice, there are.
Don't try to understand my posts. Immanuel Kant never did, he thinks that only music and laughter do not have to mean anything.
Last edited by aCOSwt on Fri Feb 15, 2013 9:18 am; edited 3 times in total |
|
| Back to top |
|
 |
Genone Retired Dev


Joined: 14 Mar 2003 Posts: 8869 Location: beyond the rim
|
Posted: Thu Jan 31, 2013 11:46 am Post subject: |
|
|
Option 1), unless the application really needs headers that match the running kernel (because it interfaces with specific kernel modules or whatever).
Experts can always override/fool the build system to pickup different kernel headers. |
|
| Back to top |
|
 |
aCOSwt Advocate


Joined: 19 Oct 2007 Posts: 2075 Location: Between the keyboard and the chair
|
Posted: Thu Jan 31, 2013 12:03 pm Post subject: |
|
|
| Genone wrote: | Option 1), unless the application really needs headers that match the running kernel (because it interfaces with specific kernel modules or whatever).
Experts can always override/fool the build system to pickup different kernel headers. |
The application does not really need headers that match the running kernel.
However,
Considering that there are an appreciable number of kernel patches that actually patch kernel-headers (vg : /usr/src/linux/include/*) in one way or another (including many I cannot even imagine...), the difference (and degree of incompatibility) with the linux-headers (vg : /usr/include/linux/*) can be so important that I was wondering if it is not systematically safer to build against actual kernel-headers.
(BTW, I thought it was what glibc advised, but I cannot any longer find this recommendation. Could be I am getting too old.) _________________ In theory there are no differences between theory and practice. In practice, there are.
Don't try to understand my posts. Immanuel Kant never did, he thinks that only music and laughter do not have to mean anything. |
|
| Back to top |
|
 |
Genone Retired Dev


Joined: 14 Mar 2003 Posts: 8869 Location: beyond the rim
|
Posted: Thu Jan 31, 2013 1:55 pm Post subject: |
|
|
| Userspace applications should always use the distro supplied, sanitized kernel headers in /usr/include/linux, as that is what glibc and others use. Building against the running kernel headers would therefore cause the compability issues you mention. See http://linuxmafia.com/faq/Kernel/usr-src-linux-symlink.html why using "live" headers is bad. |
|
| Back to top |
|
 |
aCOSwt Advocate


Joined: 19 Oct 2007 Posts: 2075 Location: Between the keyboard and the chair
|
Posted: Fri Feb 01, 2013 6:35 am Post subject: |
|
|
| http://linuxmafia.com/faq/Kernel/usr-src-linux-symlink.html wrote: | | Boom! Do you see the disconnect? |
Bham ! Yes I do !
Thank you Genone. _________________ In theory there are no differences between theory and practice. In practice, there are.
Don't try to understand my posts. Immanuel Kant never did, he thinks that only music and laughter do not have to mean anything. |
|
| Back to top |
|
 |
aCOSwt Advocate


Joined: 19 Oct 2007 Posts: 2075 Location: Between the keyboard and the chair
|
Posted: Fri Feb 15, 2013 9:27 am Post subject: |
|
|
| Genone wrote: | | Userspace applications should always use the distro supplied, sanitized kernel headers in /usr/include/linux, as that is what glibc and others use. |
Hmmm... not that much solved and I am getting even more confused :
As a matter of fact, the glibc comes with its own headers that slightly differ from the kernel headers.
As an example is /usr/include/sched.h (glibc's) differing from /usr/include/linux/sched.h (kernel-headers')
If, for example, I want to use the libc's subroutine sched_setscheduler, should I include <sched.h> or <linux/sched.h> ?
BTW, man says <sched.h> !
Man's solution not being very convenient, I admit, because I am forced to read the header to understand that, in reality, I should :
#define __USE_GNU
#include <sched.h> _________________ In theory there are no differences between theory and practice. In practice, there are.
Don't try to understand my posts. Immanuel Kant never did, he thinks that only music and laughter do not have to mean anything. |
|
| Back to top |
|
 |
Genone Retired Dev


Joined: 14 Mar 2003 Posts: 8869 Location: beyond the rim
|
Posted: Fri Feb 15, 2013 12:50 pm Post subject: |
|
|
| aCOSwt wrote: | | Genone wrote: | | Userspace applications should always use the distro supplied, sanitized kernel headers in /usr/include/linux, as that is what glibc and others use. |
Hmmm... not that much solved and I am getting even more confused :
As a matter of fact, the glibc comes with its own headers that slightly differ from the kernel headers.
As an example is /usr/include/sched.h (glibc's) differing from /usr/include/linux/sched.h (kernel-headers') |
If glibc installs its own header then of course userspace applications should use that one. My statement was only referring to /usr/include/linux vs. /usr/src/linux/include/linux |
|
| Back to top |
|
 |
|