All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Installing kernel headers after building Linux
@ 2019-04-25 12:35 Frank Hunleth
  2019-04-27 18:28 ` Arnout Vandecappelle
  0 siblings, 1 reply; 3+ messages in thread
From: Frank Hunleth @ 2019-04-25 12:35 UTC (permalink / raw)
  To: buildroot

Hello,

I have a setup where I?m using a non-Buildroot external toolchain, and I'm trying to add a package that requires the kernel headers from the same version of Linux that?s running. The kernel headers in the external toolchain don?t match the version of Linux that I?m using as you?d expect.

I?m wondering why the Linux build step doesn?t run `make headers_install` at the end so that the header files could be available. Would doing this for external toolchains cause an issue? Before I head too far down that path, I wanted to check.

Or is there another way of making the kernel headers available (aside from switching to an internally generated toolchain)? In case it matters, the package I?m looking at adding is `ply` so that I can run a couple eBPF traces.

Thanks!
Frank

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] Installing kernel headers after building Linux
  2019-04-25 12:35 [Buildroot] Installing kernel headers after building Linux Frank Hunleth
@ 2019-04-27 18:28 ` Arnout Vandecappelle
  2019-04-28 14:52   ` Frank Hunleth
  0 siblings, 1 reply; 3+ messages in thread
From: Arnout Vandecappelle @ 2019-04-27 18:28 UTC (permalink / raw)
  To: buildroot



On 25/04/2019 14:35, Frank Hunleth wrote:
> Hello,
> 
> I have a setup where I?m using a non-Buildroot external toolchain, and I'm trying to add a package that requires the kernel headers from the same version of Linux that?s running. The kernel headers in the external toolchain don?t match the version of Linux that I?m using as you?d expect.

 I don't see how you could ever depend on *the same* headers as the running
kernel...

 What you might get, though, is that you need some feature (typically an ioctl
definition, or netlink attribute, or something like that) which is only
available in a recent-enough kernel.

 What many packages do for such a case is to carry their own recent copy of the
relevant kernel header.

 Could that be an option for you?


> I?m wondering why the Linux build step doesn?t run `make headers_install` at the end so that the header files could be available. Would doing this for external toolchains cause an issue? Before I head too far down that path, I wanted to check.

 There are two potential problems with that.

 The first one is that you will overwrite the headers that were bundled with the
toolchain, which could lead to conflicting types being used. However, this is in
practice not an issue (I think) because of the ABI stability promise.

 The second problem is how to handle this in the Buildroot packaging. I guess
you'd need to add a conditional dependency, i.e.

ifeq ($(BR2_LINUX_KERNEL)$(BR2_KERNEL_HEADERS_AS_KERNEL),y)
FOO_DEPENDENCIES += linux
endif


> Or is there another way of making the kernel headers available (aside from switching to an internally generated toolchain)?

 I think you can do the horrible hack of setting

BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="zImage headers_install
INSTALL_HDR_PATH=$(@D)/usr"
BR2_LINUX_KERNEL_IMAGE_NAME="zImage"

 It hurts my eyes but it might work :-)

 But you're probably better off just patching linux.mk.


> In case it matters, the package I?m looking at adding is `ply` so that I can run a couple eBPF traces.

 Doesn't that require the headers to be present *on the target* as well?

 Regards,
 Arnout

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] Installing kernel headers after building Linux
  2019-04-27 18:28 ` Arnout Vandecappelle
@ 2019-04-28 14:52   ` Frank Hunleth
  0 siblings, 0 replies; 3+ messages in thread
From: Frank Hunleth @ 2019-04-28 14:52 UTC (permalink / raw)
  To: buildroot

On Sat, Apr 27, 2019 at 2:28 PM Arnout Vandecappelle <arnout@mind.be> wrote:
> On 25/04/2019 14:35, Frank Hunleth wrote:
> > Hello,
> >
> > I have a setup where I?m using a non-Buildroot external toolchain, and I'm trying to add a package that requires the kernel headers from the same version of Linux that?s running. The kernel headers in the external toolchain don?t match the version of Linux that I?m using as you?d expect.
>
>  I don't see how you could ever depend on *the same* headers as the running
> kernel...
>
>  What you might get, though, is that you need some feature (typically an ioctl
> definition, or netlink attribute, or something like that) which is only
> available in a recent-enough kernel.
>
>  What many packages do for such a case is to carry their own recent copy of the
> relevant kernel header.
>
>  Could that be an option for you?
>

One of the eBPF calls requires the kernel version to be passed in and
does an exact match.

> > I?m wondering why the Linux build step doesn?t run `make headers_install` at the end so that the header files could be available. Would doing this for external toolchains cause an issue? Before I head too far down that path, I wanted to check.
>
>  There are two potential problems with that.
>
>  The first one is that you will overwrite the headers that were bundled with the
> toolchain, which could lead to conflicting types being used. However, this is in
> practice not an issue (I think) because of the ABI stability promise.
>
>  The second problem is how to handle this in the Buildroot packaging. I guess
> you'd need to add a conditional dependency, i.e.
>
> ifeq ($(BR2_LINUX_KERNEL)$(BR2_KERNEL_HEADERS_AS_KERNEL),y)
> FOO_DEPENDENCIES += linux
> endif
>

Thanks, that's helpful.

>
> > Or is there another way of making the kernel headers available (aside from switching to an internally generated toolchain)?
>
>  I think you can do the horrible hack of setting
>
> BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="zImage headers_install
> INSTALL_HDR_PATH=$(@D)/usr"
> BR2_LINUX_KERNEL_IMAGE_NAME="zImage"
>
>  It hurts my eyes but it might work :-)

lol

>
>  But you're probably better off just patching linux.mk.
>
>
> > In case it matters, the package I?m looking at adding is `ply` so that I can run a couple eBPF traces.
>
>  Doesn't that require the headers to be present *on the target* as well?

I didn't think so and I don't see any references in the ply source to
open header files, but it's not working even with matched kernel
headers. So... Unfortunately, I gave up and solved my issue with
strace to move forward. I'll see if I can give it another try this
week. It doesn't feel far off.

Thanks again for the help!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-28 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25 12:35 [Buildroot] Installing kernel headers after building Linux Frank Hunleth
2019-04-27 18:28 ` Arnout Vandecappelle
2019-04-28 14:52   ` Frank Hunleth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.