Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCHv3] toolchain/external: allow custom toolchains to use newer headers
Date: Mon, 13 Jan 2020 17:09:59 +0100	[thread overview]
Message-ID: <20200113170959.1c7a901a@windsurf> (raw)
In-Reply-To: <20200107205429.11726-1-yann.morin.1998@free.fr>

Hello,

Thanks for this patch. I just needed it for an internal toolchain that
I'm building with Buildroot 2019.02 (which supported headers 5.0
maximum), but using Linux 5.4. So, the commit title that starts with
"toolchain/external" is a bit incorrect as your implementation, as the
commit log states, also addresses the case of internal toolchain.

Some more comments below.

On Tue,  7 Jan 2020 21:54:29 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> +	  If your kernel headers are more recent than the latest version
> +	  in the choice, then select the latest version.
> +
>  config BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_4
>  	bool "5.4.x"

We should probably change the prompt here to:

	bool "5.4.x or later"

and make it an habit of moving this "or later" statement to the most
recent kernel headers option. This is IMO clearer than just the
additional statement in the help text.


>  BUILDDIR="${1}"
>  SYSROOT="${2}"
>  # Make sure we have enough version components
>  HDR_VER="${3}.0.0"
> +CHECK="${4}"  # 'strict' or 'loose'
>  
>  HDR_M="${HDR_VER%%.*}"
>  HDR_V="${HDR_VER#*.}"
> @@ -32,16 +48,19 @@ ${HOSTCC} -imacros "${SYSROOT}/usr/include/linux/version.h" \
>  int main(int argc __attribute__((unused)),
>           char** argv __attribute__((unused)))
>  {
> -    if((LINUX_VERSION_CODE & ~0xFF)
> -        != KERNEL_VERSION(${HDR_M},${HDR_m},0))
> +    int ret = 0;
> +    int l = LINUX_VERSION_CODE & ~0xFF;
> +    int h = KERNEL_VERSION(${HDR_M},${HDR_m},0);
> +
> +    if(l != h)
>      {
>          printf("Incorrect selection of kernel headers: ");
>          printf("expected %d.%d.x, got %d.%d.x\n", ${HDR_M}, ${HDR_m},
>                 ((LINUX_VERSION_CODE>>16) & 0xFF),
>                 ((LINUX_VERSION_CODE>>8) & 0xFF));  
> -        return 1;
> +        ret = ((l >= h ) && ("${CHECK}"[0] == 'l')) ? 0 : 1;

No space before the parenthesis after "h". Also, checking just the
first letter of ${CHECK} seems like a hack. Why not:

	ret = ((l >= h) && !strcmp("${CHECK}", "loose")) ? 0 : 1;

> diff --git a/toolchain/toolchain-external/toolchain-external-custom/Config.in.options b/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
> index 665765a104..d7a40e457b 100644
> --- a/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
> +++ b/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
> @@ -109,6 +109,9 @@ choice
>  	    m = ( LINUX_VERSION_CODE >> 8  ) & 0xFF
>  	    p = ( LINUX_VERSION_CODE >> 0  ) & 0xFF
>  
> +	  If your toolchain uses headers newer than the latest version
> +	  in the choice, then select the latest version.
> +
>  config BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_4
>  	bool "5.4.x"

So here as well:

	bool "5.4.x or later"

>  	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_4

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  parent reply	other threads:[~2020-01-13 16:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 20:54 [Buildroot] [PATCHv3] toolchain/external: allow custom toolchains to use newer headers Yann E. MORIN
2020-01-09 17:33 ` Vincent Fazio
2020-01-13 16:09 ` Thomas Petazzoni [this message]
2020-01-13 17:20   ` Yann E. MORIN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200113170959.1c7a901a@windsurf \
    --to=thomas.petazzoni@bootlin.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox