Skip to contentSkip to conversation

ref-manual: variabls: Add RECIPE_SYSROOT and RECIPE_SYSROOT_NATIVE variables

PATCH In review Talel BELHAJSALEM 2 participants 9 messages Oct 19, 2023 – Oct 20, 2023 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ref-manual: variabls: Add RECIPE_SYSROOT and RECIPE_SYSROOT_NATIVE variables

---
 documentation/ref-manual/variables.rst | 36 +++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
documentation/ref-manual/variables.rst +35 -1
index 26a5aed82..22787f3b4 100644
@@ -6971,6 +6971,36 @@ system and gives an overview of their function and contents.
       in the ":ref:`ref-manual/devtool-reference:checking on the upgrade status of a recipe`"
       section.
 
+   :term:`RECIPE_SYSROOT`
+      This variable points to the directory that holds all files populated from
+      recipes specified in :term:`DEPENDS`. As the name indicates,
+      think of this variable as a custom root ``/`` for the recipe that will be
+      used by the compiler in order to find headers and other needs to complete
+      its job.
+
+      This variable is related to :term:`STAGING_DIR_HOST` or :term:`STAGING_DIR_TARGET`
+      according to the type of the recipe and the build target.
+
+      To understand more this variable, consider the following examples:
+
+      -  For ``#include <header.h>``, ``header.h`` should be in ``"${RECIPE_SYSROOT}/usr/include"``
+
+      -  For ``-lexample``, ``libexample.so`` should be in ``"${RECIPE_SYSROOT}/lib"``
+         or other library sysroot directories.
+
+      The default value is ``"${WORKDIR}/recipe-sysroot"``.
+      Do not modify it.
+
+   :term:`RECIPE_SYSROOT_NATIVE`
+      This is similar to :term:`RECIPE_SYSROOT` but the populated files are from
+      ``-native`` recipes. This allows a recipe built for the target machine to
+      use ``native`` tools.
+
+      This variable is related to :term:`STAGING_DIR_NATIVE`.
+
+      The default value is ``"${WORKDIR}/recipe-sysroot-native"``.
+      Do not modify it.
+
    :term:`REPODIR`
       See :term:`bitbake:REPODIR` in the BitBake manual.
 
@@ -8242,7 +8272,8 @@ system and gives an overview of their function and contents.
       the component is built to run (the system that hosts the component).
       For most recipes, this sysroot is the one in which that recipe's
       :ref:`ref-tasks-populate_sysroot` task copies
-      files. Exceptions include ``-native`` recipes, where the
+      files, check :term:`RECIPE_SYSROOT`.
+      Exceptions include ``-native`` recipes, where the
       :ref:`ref-tasks-populate_sysroot` task instead uses
       :term:`STAGING_DIR_NATIVE`. Depending on
       the type of recipe and the build target, :term:`STAGING_DIR_HOST` can
@@ -8279,6 +8310,9 @@ system and gives an overview of their function and contents.
       Specifies the path to the sysroot directory used when building
       components that run on the build host itself.
 
+      The default value is ``"${RECIPE_SYSROOT_NATIVE}"``,
+      check :term:`RECIPE_SYSROOT_NATIVE`.
+
    :term:`STAGING_DIR_TARGET`
       Specifies the path to the sysroot used for the system for which the
       component generates code. For components that do not generate code,
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 ref-manual: variables: Add TOOLCHAIN_OPTIONS variable

---
 documentation/ref-manual/variables.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)
documentation/ref-manual/variables.rst +10 -0
index 22787f3b4..958b98fd6 100644
@@ -9134,6 +9134,16 @@ system and gives an overview of their function and contents.
       portion of an eSDK. This is similar to :term:`TOOLCHAIN_HOST_TASK`
       applying to SDKs.
 
+   :term:`TOOLCHAIN_OPTIONS`
+      This variable holds extra options passed to the compiler and the linker
+      for non ``-native`` recipes as they have to point to their custom
+      ``sysroot`` folder pointed to by :term:`RECIPE_SYSROOT`::
+
+         TOOLCHAIN_OPTIONS = " --sysroot=${RECIPE_SYSROOT}"
+
+      Native recipes don't need this variable to be set, as they are
+      built for the host machine with the native compiler.
+
    :term:`TOOLCHAIN_OUTPUTNAME`
       This variable defines the name used for the toolchain output. The
       :ref:`populate_sdk_base <ref-classes-populate-sdk-*>` class sets
Signature · 1 line
2.25.1
Reviewed-by on v1 2/3
#2 lore raw

Re: [docs] [PATCH 2/3] ref-manual: variables: Add TOOLCHAIN_OPTIONS variable

Hi Talel

Quoted 16 lines · BELHADJ SALEM Talel
---
  documentation/ref-manual/variables.rst | 10 ++++++++++
  1 file changed, 10 insertions(+)
documentation/ref-manual/variables.rst +3 -0
index 22787f3b4..958b98fd6 100644
@@ -9134,6 +9134,16 @@ system and gives an overview of their function and contents.
        portion of an eSDK. This is similar to :term:`TOOLCHAIN_HOST_TASK`
        applying to SDKs.
 
+   :term:`TOOLCHAIN_OPTIONS`
+      This variable holds extra options passed to the compiler and the linker
+      for non ``-native`` recipes as they have to point to their custom

documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 9149

Quoted 10 lines
documentation/ref-manual/variables.rst +7 -0
+      ``sysroot`` folder pointed to by :term:`RECIPE_SYSROOT`::
+
+         TOOLCHAIN_OPTIONS = " --sysroot=${RECIPE_SYSROOT}"
+
+      Native recipes don't need this variable to be set, as they are
+      built for the host machine with the native compiler.
+
     :term:`TOOLCHAIN_OUTPUTNAME`
        This variable defines the name used for the toolchain output. The
        :ref:`populate_sdk_base <ref-classes-populate-sdk-*>` class sets

This patch looks great, but I need the update to your RECIPE_SYSROOT patch before I can merge it.

Thanks in advance
Cheers
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 3/3 ref-manual: variables: Add example for SYSROOT_DIRS variable

In reply to Talel BELHAJSALEM
---
 documentation/ref-manual/variables.rst | 29 ++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
documentation/ref-manual/variables.rst +29 -0
index 958b98fd6..8f1abf43a 100644
@@ -8474,6 +8474,35 @@ system and gives an overview of their function and contents.
              /sysroot-only \
              "
 
+      Consider the following example in which you need to manipulate this variable.
+      Assume you have a recipe ``A`` that provides a shared library ``.so.*`` that is
+      installed into a custom folder other than "``${libdir}``"
+      or "``${base_libdir}``", let's say "``/opt/lib``".
+
+      .. note::
+
+         This is not a recommended way to deal with shared libraries, but this
+         is just to show the usefulness of setting :term:`SYSROOT_DIRS`.
+
+      When a recipe ``B`` :term:`DEPENDS` on ``A``, it means what is in
+      :term:`SYSROOT_DIRS` will be copied from :term:`D` of the recipe ``B``
+      into ``B``'s :term:`SYSROOT_DESTDIR` that is "``${WORKDIR}/sysroot-destdir``".
+
+      Now, since ``/opt/lib`` is not in :term:`SYSROOT_DIRS`, it will never be copied to
+      ``A``'s :term:`RECIPE_SYSROOT`, which is "``${WORKDIR}/recipe-sysroot``". So,
+      the linking process will still fail.
+
+      To fix this, you need to add ``/opt/lib`` to :term:`SYSROOT_DIRS`::
+
+         SYSROOT_DIRS:append = " /opt/lib"
+
+      .. note::
+         Even after setting ``/opt/lib`` to :term:`SYSROOT_DIRS`, the linking process will fail
+         because the linker does not know that location since :term:`TARGET_LDFLAGS` (if your recipe
+         is for the target) doesn't contain it. Therefore, so you should add::
+
+            TARGET_LDFLAGS:append = " -L${RECIPE_SYSROOT}/opt/lib"
+
    :term:`SYSROOT_DIRS_IGNORE`
       Directories that are not staged into the sysroot by the
       :ref:`ref-tasks-populate_sysroot` task. You
Signature · 1 line
2.25.1
#4 lore raw

Re: [docs] [PATCH 3/3] ref-manual: variables: Add example for SYSROOT_DIRS variable

Quoted 20 lines · BELHADJ SALEM Talel
---
  documentation/ref-manual/variables.rst | 29 ++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)
documentation/ref-manual/variables.rst +7 -0
index 958b98fd6..8f1abf43a 100644
@@ -8474,6 +8474,35 @@ system and gives an overview of their function and contents.
               /sysroot-only \
               "
 
+      Consider the following example in which you need to manipulate this variable.
+      Assume you have a recipe ``A`` that provides a shared library ``.so.*`` that is
+      installed into a custom folder other than "``${libdir}``"
+      or "``${base_libdir}``", let's say "``/opt/lib``".
+
+      .. note::
+

documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 8493

Quoted 10 lines
documentation/ref-manual/variables.rst +10 -0
+         This is not a recommended way to deal with shared libraries, but this
+         is just to show the usefulness of setting :term:`SYSROOT_DIRS`.
+
+      When a recipe ``B`` :term:`DEPENDS` on ``A``, it means what is in
+      :term:`SYSROOT_DIRS` will be copied from :term:`D` of the recipe ``B``
+      into ``B``'s :term:`SYSROOT_DESTDIR` that is "``${WORKDIR}/sysroot-destdir``".
+
+      Now, since ``/opt/lib`` is not in :term:`SYSROOT_DIRS`, it will never be copied to
+      ``A``'s :term:`RECIPE_SYSROOT`, which is "``${WORKDIR}/recipe-sysroot``". So,
+      the linking process will still fail.

s/still fail/fail/
I meant to use "still fail" in the second part.

documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 8500

Quoted 7 lines
documentation/ref-manual/variables.rst +7 -0
+
+      To fix this, you need to add ``/opt/lib`` to :term:`SYSROOT_DIRS`::
+
+         SYSROOT_DIRS:append = " /opt/lib"
+
+      .. note::
+         Even after setting ``/opt/lib`` to :term:`SYSROOT_DIRS`, the linking process will fail

s/will fail/will still fail/

documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 8502

Quoted 2 lines
documentation/ref-manual/variables.rst +2 -0
+         because the linker does not know that location since :term:`TARGET_LDFLAGS` (if your recipe
+         is for the target) doesn't contain it. Therefore, so you should add::

I'd actually tweak this sentence a bit to make it easier to read:

because the linker does not know that location, since :term:TARGET_LDFLAGS doesn't contain it (if your recipe is for the target). Therefore, so you should add::

We are very close too!
Thanks!
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

Re: [docs] [PATCH 3/3] ref-manual: variables: Add example for SYSROOT_DIRS variable

Hello Michael,

For the moment, when fixing a patch, I send the patch again without adding "Reviewed-by", is it necessary?
And also, is it necessary to send all patches again even if one of them is good?

Thanks again for the support.
Talel

Quoted 83 lines · Michael Opdenacker

Review

Quoted 6 lines · BELHADJ SALEM Talel
---
  documentation/ref-manual/variables.rst | 29 ++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)
(quoted diff) +0 -0

b/documentation/ref-manual/variables.rst

documentation/ref-manual/variables.rst system and gives an overview of their function

Quoted 4 lines

index 958b98fd6..8f1abf43a 100644

documentation/ref-manual/variables.rst +0 -0
@@ -8474,6 +8474,35 @@ system and gives an overview of their function

and contents.

documentation/ref-manual/variables.rst system and gives an overview of their function and contents.

Quoted 4 lines
documentation/ref-manual/variables.rst +1 -0
               /sysroot-only \
               "
 
+      Consider the following example in which you need to manipulate

this variable.

documentation/ref-manual/variables.rst system and gives an overview of their function · line 8478

Quoted 1 line
documentation/ref-manual/variables.rst +1 -0
+      Assume you have a recipe ``A`` that provides a shared library

``.so.*`` that is

documentation/ref-manual/variables.rst system and gives an overview of their function and contents.

Quoted 6 lines
documentation/ref-manual/variables.rst +6 -0
+      installed into a custom folder other than "``${libdir}``"
+      or "``${base_libdir}``", let's say "``/opt/lib``".
+
+      .. note::
+
+         This is not a recommended way to deal with shared libraries,

but this

documentation/ref-manual/variables.rst system and gives an overview of their function and contents.

Quoted 4 lines
documentation/ref-manual/variables.rst +4 -0
+         is just to show the usefulness of setting :term:`SYSROOT_DIRS`.
+
+      When a recipe ``B`` :term:`DEPENDS` on ``A``, it means what is in
+      :term:`SYSROOT_DIRS` will be copied from :term:`D` of the recipe

``B``

documentation/ref-manual/variables.rst system and gives an overview of their function · line 8489

Quoted 1 line
documentation/ref-manual/variables.rst +1 -0
+      into ``B``'s :term:`SYSROOT_DESTDIR` that is

"``${WORKDIR}/sysroot-destdir``".

documentation/ref-manual/variables.rst system and gives an overview of their function · line 8491

Quoted 2 lines
documentation/ref-manual/variables.rst +2 -0
+
+      Now, since ``/opt/lib`` is not in :term:`SYSROOT_DIRS`, it will

never be copied to

documentation/ref-manual/variables.rst system and gives an overview of their function · line 8492

Quoted 1 line
documentation/ref-manual/variables.rst +1 -0
+      ``A``'s :term:`RECIPE_SYSROOT`, which is

"``${WORKDIR}/recipe-sysroot``". So,

documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 8493

Quoted 1 line
documentation/ref-manual/variables.rst +1 -0
+      the linking process will still fail.

s/still fail/fail/
I meant to use "still fail" in the second part.

documentation/ref-manual/variables.rst system and gives an overview of their function · line 8495

Quoted 2 lines
documentation/ref-manual/variables.rst +2 -0
+
+      To fix this, you need to add ``/opt/lib`` to

:term:SYSROOT_DIRS::

documentation/ref-manual/variables.rst system and gives an overview of their function and contents.

Quoted 5 lines
documentation/ref-manual/variables.rst +5 -0
+
+         SYSROOT_DIRS:append = " /opt/lib"
+
+      .. note::
+         Even after setting ``/opt/lib`` to :term:`SYSROOT_DIRS`, the

linking process will fail

s/will fail/will still fail/

documentation/ref-manual/variables.rst system and gives an overview of their function · line 8501

Quoted 1 line
documentation/ref-manual/variables.rst +1 -0
+         because the linker does not know that location since

:term:TARGET_LDFLAGS (if your recipe

documentation/ref-manual/variables.rst system and gives an overview of their function · line 8502

Quoted 1 line
documentation/ref-manual/variables.rst +1 -0
+         is for the target) doesn't contain it. Therefore, so you

should add::

I'd actually tweak this sentence a bit to make it easier to read:

because the linker does not know that location, since :term:TARGET_LDFLAGS
doesn't contain it (if your recipe is for the target). Therefore, so you should add::

We are very close too!
Thanks!
Michael.

--
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#6 lore raw

Re: [docs] [PATCH 3/3] ref-manual: variables: Add example for SYSROOT_DIRS variable

Quoted 3 lines · BELHADJ SALEM Talel

Hello Michael,

For the moment, when fixing a patch, I send the patch again without adding "Reviewed-by", is it necessary?

Well, speaking in general, if you happen to send a updated patch series, you could add the "Reviewed-by" lines that you received, but only for the patches that were not modified since they were reviewed.

Quoted 1 line

And also, is it necessary to send all patches again even if one of them is good?

No sure here, unless the series were sent a while ago. At least it doesn't hurt to resend, and it makes it easier to have complete series for people reading the mailing list archives to review the patches.

Happy to help you help the project!
Cheers
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw
In reply to Talel BELHAJSALEM

Hi Talel,

Thanks for this update!
I still have a few comments. See below...

Quoted 10 lines · BELHADJ SALEM Talel
---
  documentation/ref-manual/variables.rst | 36 +++++++++++++++++++++++++-
  1 file changed, 35 insertions(+), 1 deletion(-)
documentation/ref-manual/variables.rst +0 -0
index 26a5aed82..22787f3b4 100644

documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 6979

Quoted 9 lines
documentation/ref-manual/variables.rst +6 -0
@@ -6971,6 +6971,36 @@ system and gives an overview of their function and contents.
        in the ":ref:`ref-manual/devtool-reference:checking on the upgrade status of a recipe`"
        section.
 
+   :term:`RECIPE_SYSROOT`
+      This variable points to the directory that holds all files populated from
+      recipes specified in :term:`DEPENDS`. As the name indicates,
+      think of this variable as a custom root ``/`` for the recipe that will be
+      used by the compiler in order to find headers and other needs to complete
+      its job.

Oops, you forgot my previous comment:
s/other needs/other files needed/

documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 6984

Quoted 5 lines
documentation/ref-manual/variables.rst +5 -0
+
+      This variable is related to :term:`STAGING_DIR_HOST` or :term:`STAGING_DIR_TARGET`
+      according to the type of the recipe and the build target.
+
+      To understand more this variable, consider the following examples:

s/more this variable/this variable bette/

Quoted 23 lines
documentation/ref-manual/variables.rst +19 -0
+
+      -  For ``#include <header.h>``, ``header.h`` should be in ``"${RECIPE_SYSROOT}/usr/include"``
+
+      -  For ``-lexample``, ``libexample.so`` should be in ``"${RECIPE_SYSROOT}/lib"``
+         or other library sysroot directories.
+
+      The default value is ``"${WORKDIR}/recipe-sysroot"``.
+      Do not modify it.
+
+   :term:`RECIPE_SYSROOT_NATIVE`
+      This is similar to :term:`RECIPE_SYSROOT` but the populated files are from
+      ``-native`` recipes. This allows a recipe built for the target machine to
+      use ``native`` tools.
+
+      This variable is related to :term:`STAGING_DIR_NATIVE`.
+
+      The default value is ``"${WORKDIR}/recipe-sysroot-native"``.
+      Do not modify it.
+
     :term:`REPODIR`
        See :term:`bitbake:REPODIR` in the BitBake manual.
 

documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 8275

Quoted 5 lines
documentation/ref-manual/variables.rst +1 -1
@@ -8242,7 +8272,8 @@ system and gives an overview of their function and contents.
        the component is built to run (the system that hosts the component).
        For most recipes, this sysroot is the one in which that recipe's
        :ref:`ref-tasks-populate_sysroot` task copies
-      files. Exceptions include ``-native`` recipes, where the
+      files, check :term:`RECIPE_SYSROOT`.

Aren't you missing a few words a few "where the files"?
If you meant to say "the files check :term:RECIPE_SYSROOT", I don't understand.

The rest looks good. Almost there :)
Thanks
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 4 lines · Michael Opdenacker via lists.yoctoproject.org

Hi Talel,

Thanks for this update!
I still have a few comments. See below...

Ah, also fix the typo in the commit title (s/variabls/variables/) and make it shorter:

ref-manual: variables: add RECIPE_SYSROOT and RECIPE_SYSROOT_NATIVE

Thanks
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com