Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using kernel headers
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
aCOSwt
Moderator
Moderator


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Thu Jan 31, 2013 11:39 am    Post subject: Using kernel headers Reply with quote

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 ?
_________________


Last edited by aCOSwt on Fri Feb 15, 2013 9:18 am; edited 3 times in total
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9005
Location: beyond the rim

PostPosted: Thu Jan 31, 2013 11:46 am    Post subject: Reply with quote

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
View user's profile Send private message
aCOSwt
Moderator
Moderator


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Thu Jan 31, 2013 12:03 pm    Post subject: Reply with quote

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.)
_________________
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9005
Location: beyond the rim

PostPosted: Thu Jan 31, 2013 1:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
aCOSwt
Moderator
Moderator


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Fri Feb 01, 2013 6:35 am    Post subject: Reply with quote

http://linuxmafia.com/faq/Kernel/usr-src-linux-symlink.html wrote:
Boom! Do you see the disconnect?

8O Bham ! Yes I do !

Thank you Genone.
_________________
Back to top
View user's profile Send private message
aCOSwt
Moderator
Moderator


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Fri Feb 15, 2013 9:27 am    Post subject: Reply with quote

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>
_________________
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9005
Location: beyond the rim

PostPosted: Fri Feb 15, 2013 12:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum