diff mbox series

kernel.bbclass: Use strip utility used for kernel build in do_package

Message ID 20231024220735.3011192-1-raj.khem@gmail.com
State Accepted, archived
Commit 77497dbdca92ab4d6386a071bc281c42a7e8a14b
Headers show
Series kernel.bbclass: Use strip utility used for kernel build in do_package | expand

Commit Message

Khem Raj Oct. 24, 2023, 10:07 p.m. UTC
os.environ does not pass this down to runstrip() function and in
strip_execs() its using STRIP bitbake variable to find the strip utility
to use. Since there might be a trailing whitespace in KERNEL_STRIP
remove that otherwise python is not able to launch it.
e.g.

FileNotFoundError: [Errno 2] No such file or directory: 'riscv64-yoe-linux-strip '

This is more evident when STRIP and KERNEL_STRIP are different utilities
e.g. when using clang as default toolchain but using gcc+binutils only for
kernel build.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
---
 meta/classes-recipe/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bruce Ashfield Oct. 24, 2023, 11:17 p.m. UTC | #1
On Tue, Oct 24, 2023 at 6:07 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> os.environ does not pass this down to runstrip() function and in
> strip_execs() its using STRIP bitbake variable to find the strip utility
> to use. Since there might be a trailing whitespace in KERNEL_STRIP
> remove that otherwise python is not able to launch it.
> e.g.
>
> FileNotFoundError: [Errno 2] No such file or directory: 'riscv64-yoe-linux-strip '
>
> This is more evident when STRIP and KERNEL_STRIP are different utilities
> e.g. when using clang as default toolchain but using gcc+binutils only for
> kernel build.
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
> ---
>  meta/classes-recipe/kernel.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
> index 2ec9ea2091e..16b85dbca48 100644
> --- a/meta/classes-recipe/kernel.bbclass
> +++ b/meta/classes-recipe/kernel.bbclass
> @@ -336,7 +336,7 @@ kernel_do_transform_bundled_initramfs() {
>  do_transform_bundled_initramfs[dirs] = "${B}"
>
>  python do_package:prepend () {
> -    os.environ['STRIP'] = d.getVar('KERNEL_STRIP')
> +    d.setVar('STRIP',  d.getVar('KERNEL_STRIP').strip())

Looks fine to me.

I can't say that I know the mechanics if every setVar'd variable makes it into
the environment to be available for the build process .. but since it is working
for you, I assume it does :)

Bruce

>  }
>
>  python do_devshell:prepend () {
> --
> 2.42.0
>
Richard Purdie Oct. 25, 2023, 9:05 p.m. UTC | #2
On Tue, 2023-10-24 at 19:17 -0400, Bruce Ashfield wrote:
> On Tue, Oct 24, 2023 at 6:07 PM Khem Raj <raj.khem@gmail.com> wrote:
> > 
> > os.environ does not pass this down to runstrip() function and in
> > strip_execs() its using STRIP bitbake variable to find the strip utility
> > to use. Since there might be a trailing whitespace in KERNEL_STRIP
> > remove that otherwise python is not able to launch it.
> > e.g.
> > 
> > FileNotFoundError: [Errno 2] No such file or directory: 'riscv64-yoe-linux-strip '
> > 
> > This is more evident when STRIP and KERNEL_STRIP are different utilities
> > e.g. when using clang as default toolchain but using gcc+binutils only for
> > kernel build.
> > 
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
> > ---
> >  meta/classes-recipe/kernel.bbclass | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
> > index 2ec9ea2091e..16b85dbca48 100644
> > --- a/meta/classes-recipe/kernel.bbclass
> > +++ b/meta/classes-recipe/kernel.bbclass
> > @@ -336,7 +336,7 @@ kernel_do_transform_bundled_initramfs() {
> >  do_transform_bundled_initramfs[dirs] = "${B}"
> > 
> >  python do_package:prepend () {
> > -    os.environ['STRIP'] = d.getVar('KERNEL_STRIP')
> > +    d.setVar('STRIP',  d.getVar('KERNEL_STRIP').strip())
> 
> Looks fine to me.
> 
> I can't say that I know the mechanics if every setVar'd variable makes it into
> the environment to be available for the build process .. but since it is working
> for you, I assume it does :)

FWIW, only variables that have their export flag set or which exported
at some point, which STRIP presumably does or is.

Cheers,

Richard
Martin Jansa Oct. 30, 2023, 8:40 p.m. UTC | #3
This doesn't work well with ccache.bbclass when KERNEL_STRIP is prefixed
with ccache as:
KERNEL_STRIP="ccache aarch64-oe-linux-strip "

do_package then fails with:
ERROR: Fatal errors occurred in subprocesses:
[Errno 2] No such file or directory: 'ccache x86_64-oe-linux-strip':
Traceback (most recent call last):
  File "TOPDIR/oe-core/meta/lib/oe/utils.py", line 288, in run
    ret = self._target(*self._args, **self._kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "TOPDIR/oe-core/meta/lib/oe/package.py", line 66, in runstrip
    output = subprocess.check_output(stripcmd, stderr=subprocess.STDOUT)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ccache
x86_64-oe-linux-strip'

On Wed, Oct 25, 2023 at 12:07 AM Khem Raj <raj.khem@gmail.com> wrote:

> os.environ does not pass this down to runstrip() function and in
> strip_execs() its using STRIP bitbake variable to find the strip utility
> to use. Since there might be a trailing whitespace in KERNEL_STRIP
> remove that otherwise python is not able to launch it.
> e.g.
>
> FileNotFoundError: [Errno 2] No such file or directory:
> 'riscv64-yoe-linux-strip '
>
> This is more evident when STRIP and KERNEL_STRIP are different utilities
> e.g. when using clang as default toolchain but using gcc+binutils only for
> kernel build.
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
> ---
>  meta/classes-recipe/kernel.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes-recipe/kernel.bbclass
> b/meta/classes-recipe/kernel.bbclass
> index 2ec9ea2091e..16b85dbca48 100644
> --- a/meta/classes-recipe/kernel.bbclass
> +++ b/meta/classes-recipe/kernel.bbclass
> @@ -336,7 +336,7 @@ kernel_do_transform_bundled_initramfs() {
>  do_transform_bundled_initramfs[dirs] = "${B}"
>
>  python do_package:prepend () {
> -    os.environ['STRIP'] = d.getVar('KERNEL_STRIP')
> +    d.setVar('STRIP',  d.getVar('KERNEL_STRIP').strip())
>  }
>
>  python do_devshell:prepend () {
> --
> 2.42.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#189658):
> https://lists.openembedded.org/g/openembedded-core/message/189658
> Mute This Topic: https://lists.openembedded.org/mt/102167569/3617156
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> martin.jansa@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index 2ec9ea2091e..16b85dbca48 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -336,7 +336,7 @@  kernel_do_transform_bundled_initramfs() {
 do_transform_bundled_initramfs[dirs] = "${B}"
 
 python do_package:prepend () {
-    os.environ['STRIP'] = d.getVar('KERNEL_STRIP')
+    d.setVar('STRIP',  d.getVar('KERNEL_STRIP').strip())
 }
 
 python do_devshell:prepend () {