Skip to contentSkip to conversation

ref-manual: variables: Add RECIPE_SYSROOT and RECIPE_SYSROOT_NATIVE

PATCH Applied Talel BELHAJSALEM 3 participants 7 messages Oct 20, 2023

lore
Share & tools
lore
#0 lore raw

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

---
 documentation/ref-manual/variables.rst | 35 ++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
documentation/ref-manual/variables.rst +35 -0
index 26a5aed82..b00445946 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 files needed 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 better understand 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.
 
@@ -8275,10 +8305,15 @@ system and gives an overview of their function and contents.
             for ``-native`` recipes, as they make use of host headers and
             libraries.
 
+      Check :term:`RECIPE_SYSROOT` and :term:`RECIPE_SYSROOT_NATIVE`.
+
    :term:`STAGING_DIR_NATIVE`
       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 b00445946..1fca913e2 100644
@@ -9135,6 +9135,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
#2 lore raw

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

Quoted 10 lines · BELHADJ SALEM Talel
---
  documentation/ref-manual/variables.rst | 10 ++++++++++
  1 file changed, 10 insertions(+)
documentation/ref-manual/variables.rst +0 -0
index b00445946..1fca913e2 100644

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

Quoted 5 lines
documentation/ref-manual/variables.rst +2 -0
@@ -9135,6 +9135,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

This will be good to mention that its different from adding to CFLAGS since this variable ends up in CC/CXX variables which is important to know that in some packages CFLAGS/LDFLAGS may not be used especially during configure tests etc.

Quoted 22 lines
documentation/ref-manual/variables.rst +8 -1
+      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
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#4438): https://lists.yoctoproject.org/g/docs/message/4438
Mute This Topic: https://lists.yoctoproject.org/mt/102077750/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/docs/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

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

Quoted 6 lines · Khem Raj
Quoted 5 lines · BELHADJ SALEM Talel

---
  documentation/ref-manual/variables.rst | 10 ++++++++++

  1 file changed, 10 insertions(+)
Quoted 13 lines
Quoted 11 lines
documentation/ref-manual/variables.rst +0 -0
index b00445946..1fca913e2 100644
@@ -9135,6 +9135,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

This will be good to mention that its different from adding to CFLAGS since this variable ends up in CC/CXX variables which is important to know that in some packages CFLAGS/LDFLAGS may not be used especially during configure tests etc.

Khem. Thanks for the suggestion!
Talel, your patches are already merged but follow-up patches to implement Khem's suggestions are welcome, of course. Cheers
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 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 1fca913e2..3faa39704 100644
@@ -8498,6 +8498,35 @@ system and gives an overview of their function and contents.
              ${libdir}/${BPN}/ptest \
              "
 
+      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 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 still fail
+         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::
+
+            TARGET_LDFLAGS:append = " -L${RECIPE_SYSROOT}/opt/lib"
+
    :term:`SYSROOT_DIRS_NATIVE`
       Extra directories staged into the sysroot by the
       :ref:`ref-tasks-populate_sysroot` task for
Signature · 1 line
2.25.1
Reviewed-by on v1 3/3 Applied
#5 lore raw

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

Hi Talel

Thanks for not giving up!

For all 3 commits:

Merged into master-next.

Thanks again

Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw
In reply to Talel BELHAJSALEM
Quoted 10 lines · BELHADJ SALEM Talel
---
  documentation/ref-manual/variables.rst | 35 ++++++++++++++++++++++++++
  1 file changed, 35 insertions(+)
documentation/ref-manual/variables.rst +0 -0
index 26a5aed82..b00445946 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 files needed to complete
+      its job.

Thanks for adding this to docs. I think it will be good to mention that this is not typical sysroot where everything is available but its a mimimal sysroot that contains headers and libraries from recipe specific build time dependencies only.

Quoted 54 lines
documentation/ref-manual/variables.rst +29 -1
+
+      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 better understand 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.
 
@@ -8275,10 +8305,15 @@ system and gives an overview of their function and contents.
              for ``-native`` recipes, as they make use of host headers and
              libraries.
 
+      Check :term:`RECIPE_SYSROOT` and :term:`RECIPE_SYSROOT_NATIVE`.
+
     :term:`STAGING_DIR_NATIVE`
        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,
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#4437): https://lists.yoctoproject.org/g/docs/message/4437
Mute This Topic: https://lists.yoctoproject.org/mt/102077748/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/docs/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-