[OE-core] [PATCH 3/3] tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library

Andre McCurdy armccurdy at gmail.com
Thu May 24 01:06:09 UTC 2018


On Wed, May 23, 2018 at 4:09 PM, Alejandro Enedino Hernandez Samaniego
<alejandro.enedino.hernandez-samaniego at xilinx.com> wrote:
> This patch adds the posibility to build using TCLIBC=newlib.
>
> It allows users to build baremetal applications with the use of a
> C library.
>
> Newlib is a lightweight C library meant to be used on embedded systems,
> it is meant to be easily portable for new platforms and to provide
> basic functionality on them, by design, it provides stubs for some of
> these core functions declared as weak, so they can be built correctly
> and then linked against some other library which provides specifics
> about the platform being used if need be, libgloss takes care of these
> in some cases, but it can also be extended, this patch also allows the
> user to easily add other libraries to it by adding them to
> NEWLIB_EXTENDED for this specific reason.
>
> Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr at xilinx.com>
> ---
>  meta/classes/cross-canadian.bbclass         |  2 +-
>  meta/conf/distro/include/tclibc-newlib.inc  | 47 +++++++++++++++++++++++++++++
>  meta/recipes-core/newlib/newlib_3.0.0.bb    |  3 ++
>  meta/recipes-devtools/gcc/libgcc-common.inc |  5 +++
>  4 files changed, 56 insertions(+), 1 deletion(-)
>  create mode 100644 meta/conf/distro/include/tclibc-newlib.inc
>
> diff --git a/meta/classes/cross-canadian.bbclass b/meta/classes/cross-canadian.bbclass
> index ee8aa61..7f9a69b 100644
> --- a/meta/classes/cross-canadian.bbclass
> +++ b/meta/classes/cross-canadian.bbclass
> @@ -30,7 +30,7 @@ python () {
>      if d.getVar("MODIFYTOS") != "1":
>          return
>
> -    if d.getVar("TCLIBC") == "baremetal":
> +    if (d.getVar("TCLIBC") == "baremetal") or (d.getVar("TCLIBC") == "newlib"):

Or maybe:

  if d.getVar("TCLIBC") in [ 'baremetal', 'newlib' ]:

>          return
>
>      tos = d.getVar("TARGET_OS")
> diff --git a/meta/conf/distro/include/tclibc-newlib.inc b/meta/conf/distro/include/tclibc-newlib.inc
> new file mode 100644
> index 0000000..a5e63d0
> --- /dev/null
> +++ b/meta/conf/distro/include/tclibc-newlib.inc
> @@ -0,0 +1,47 @@
> +#
> +# Newlib configuration
> +#
> +
> +LIBCEXTENSION = "-newlib"
> +
> +# Add newlib libc overrides to the overrides.
> +LIBCOVERRIDE = ":libc-newlib"
> +OVERRIDES .= "${LIBCOVERRIDE}"

This will need to be updated to align with recent changes in master:

  http://git.openembedded.org/openembedded-core/commit/?id=b3598b8f1ed1cdc7849e1e4f30d618e87e1bf582

> +PREFERRED_PROVIDER_virtual/libc ?= "newlib"
> +PREFERRED_PROVIDER_virtual/libiconv ?= "newlib"
> +PREFERRED_PROVIDER_virtual/libintl ?= "newlib"
> +PREFERRED_PROVIDER_virtual/nativesdk-libintl ?= "nativesdk-glibc"
> +PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?= "nativesdk-glibc"
> +
> +DISTRO_FEATURES_BACKFILL_CONSIDERED += "ldconfig"
> +
> +#USE_NLS ?= "no"
> +
> +IMAGE_LINGUAS = ""
> +
> +LIBC_DEPENDENCIES = "\
> +    newlib-dbg \
> +    newlib-dev \
> +    libgloss \
> +    libgloss-dev \
> +    libgloss-dbg \
> +    libgcc-dev \
> +    libgcc-dbg \
> +    "
> +
> +# compilerlibs defaults to gcc-runtime, but we get runtime from libgloss
> +# we set ASSUME_PROVIDED because we cant set PREFERRED_PROVIDER
> +# for compilerlibs since its overriden by tcmode-default

overriden -> overridden

> +ASSUME_PROVIDED += "virtual/${TARGET_PREFIX}compilerlibs virtual/crypt"
> +
> +# Its useful to be able to extend newlib, but we dont provide a native variant of libgloss
> +NEWLIB_EXTENDED ?=  "libgloss libgcc"
> +BASE_DEFAULT_DEPS_append_class-target = " ${NEWLIB_EXTENDED}"
> +
> +TARGET_OS = "elf"
> +TARGET_OS_arm = "eabi"
> +
> +TOOLCHAIN_HOST_TASK ?= "packagegroup-cross-canadian-${MACHINE}"
> +TOOLCHAIN_TARGET_TASK ?= "${LIBC_DEPENDENCIES}"
> +TOOLCHAIN_NEED_CONFIGSITE_CACHE_remove = "zlib ncurses"
> diff --git a/meta/recipes-core/newlib/newlib_3.0.0.bb b/meta/recipes-core/newlib/newlib_3.0.0.bb
> index 3380576..09238fe 100644
> --- a/meta/recipes-core/newlib/newlib_3.0.0.bb
> +++ b/meta/recipes-core/newlib/newlib_3.0.0.bb
> @@ -14,3 +14,6 @@ do_install_append() {
>         # Remove original directory
>         rmdir ${D}${prefix}/${TARGET_SYS}
>  }
> +
> +# No rpm package is actually created but -dev depends on it, avoid dnf error
> +RDEPENDS_${PN}-dev_libc-newlib = ""
> diff --git a/meta/recipes-devtools/gcc/libgcc-common.inc b/meta/recipes-devtools/gcc/libgcc-common.inc
> index 848a476..d959566 100644
> --- a/meta/recipes-devtools/gcc/libgcc-common.inc
> +++ b/meta/recipes-devtools/gcc/libgcc-common.inc
> @@ -47,8 +47,13 @@ do_install () {
>  do_install_append_libc-baremetal () {
>         rmdir ${D}${base_libdir}
>  }
> +do_install_append_libc-newlib () {
> +       rmdir ${D}${base_libdir}
> +}
>
> +# No rpm package is actually created but -dev depends on it, avoid dnf error
>  RDEPENDS_${PN}-dev_libc-baremetal = ""
> +RDEPENDS_${PN}-dev_libc-newlib = ""
>
>  BBCLASSEXTEND = "nativesdk"
>
> --
> 2.7.4
>
> This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core



More information about the Openembedded-core mailing list