All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Add Newlib as a C library for baremetal
@ 2018-05-23 23:09 Alejandro Enedino Hernandez Samaniego
  2018-05-23 23:09 ` [PATCH 1/3] newlib: Adds newlib and libgloss recipes Alejandro Enedino Hernandez Samaniego
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Alejandro Enedino Hernandez Samaniego @ 2018-05-23 23:09 UTC (permalink / raw)
  To: openembedded-core

Newlib is a widely used C library for embedded systems, its mainly used
for resource constrained devices which run baremetal applications.

It provides basic C library functionality, and it is meant to be extended
by design, it contains several stubs for core functions that can be later
overriden with the symbols provided from another library at linking time.

Libgloss is the BSP part of the library which follows the same principle,
where a BSP layer can override functionality or even application runtime
depending on the processor architecture.

These patches add both the libgloss and newlib recipes, provide functionality
to make them extendable by other libraries if required, and also create a
new TCLIBC variant, which can now be set to newlib to build the toolchain for
applications where its suitable.

Newlib is also usually used by vendors to provide embedded toolchains, which is
interesting since, this enables OE to build such toolchains in a somewhat
automated way.

These patches have been tested on my end in the following ways:

- meta-toolchain builds successfully on qemux86, qemux86-64, qemuarm, qemuarm64,
  qemuppc, qemumips.
- A helloworld application that lays in another layer was built for qemux86, qemux86-64
  qemuarm, qemuarm64, qemuppc, qemumips, and it seems to have been built correctly.
- The hardware that I have available is from Xilinx, where Xilinx already had a
  baremetal application they ran on it, I was able to build the same application
  with a recipe, that used the toolchain coming from these patches (TCLIBC=newlib).
  I ran the application on hardware and confirmed that it was built and working correctly.
- meta-toolchain builds successfully for the previously mentioned HW MACHINE as well.
- I also have a meta-freertos (its a possibility) layer that builds a FreeRTOS application
  that runs on qemuarm, and instead of using the provided ARM Embedded Toolchain, I used
  the one coming from these patches and was able to obtain the same result.
- I built world for all the previously mentioned MACHINES (qemus and HW) just to make sure
  that this did not affect other OE components, and it did not seem to be the case.

The following changes since commit 7897fb35a3420c2555ab59dfa438217ada4a9784:

  libnss-mdns: fix postinst and postrm (2018-05-22 13:13:33 +0100)

are available in the git repository at:

  git://push.yoctoproject.org/poky-contrib aehs29/newlib

Alejandro Enedino Hernandez Samaniego (3):
  newlib: Adds newlib and libgloss recipes
  insane.bbclass: Adds powerpc to elf headers machine dictionary
  tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C
    library

 meta/classes/cross-canadian.bbclass                |  2 +-
 meta/classes/insane.bbclass                        |  1 +
 meta/conf/distro/include/tclibc-newlib.inc         | 47 ++++++++++++++++++
 .../newlib/libgloss/fix-rs6000-crt0.patch          | 41 +++++++++++++++
 .../libgloss/fix_makefile_include_arm_h.patch      | 30 +++++++++++
 meta/recipes-core/newlib/libgloss_3.0.0.bb         | 32 ++++++++++++
 meta/recipes-core/newlib/newlib.inc                | 58 ++++++++++++++++++++++
 meta/recipes-core/newlib/newlib_3.0.0.bb           | 19 +++++++
 meta/recipes-devtools/gcc/gcc-cross.inc            |  1 +
 meta/recipes-devtools/gcc/libgcc-common.inc        |  5 ++
 10 files changed, 235 insertions(+), 1 deletion(-)
 create mode 100644 meta/conf/distro/include/tclibc-newlib.inc
 create mode 100644 meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch
 create mode 100644 meta/recipes-core/newlib/libgloss/fix_makefile_include_arm_h.patch
 create mode 100644 meta/recipes-core/newlib/libgloss_3.0.0.bb
 create mode 100644 meta/recipes-core/newlib/newlib.inc
 create mode 100644 meta/recipes-core/newlib/newlib_3.0.0.bb

--
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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] newlib: Adds newlib and libgloss recipes
  2018-05-23 23:09 [PATCH 0/3] Add Newlib as a C library for baremetal Alejandro Enedino Hernandez Samaniego
@ 2018-05-23 23:09 ` Alejandro Enedino Hernandez Samaniego
  2018-05-23 23:09 ` [PATCH 2/3] insane.bbclass: Adds powerpc to elf headers machine dictionary Alejandro Enedino Hernandez Samaniego
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Alejandro Enedino Hernandez Samaniego @ 2018-05-23 23:09 UTC (permalink / raw)
  To: openembedded-core

Newlib is a C library that is intended to be used on embedded systems.
It is a conglomeration of several library parts, all under free software
licenses that make them easily usable on embedded products.

Newlib provides a C library alternative that can run on baremetal, mainly
for resource constrained devices.

Libgloss is the BSP part of the C library, which can be easily modified
to port for new hardware platforms.

Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
---
 .../newlib/libgloss/fix-rs6000-crt0.patch          | 41 +++++++++++++++
 .../libgloss/fix_makefile_include_arm_h.patch      | 30 +++++++++++
 meta/recipes-core/newlib/libgloss_3.0.0.bb         | 32 ++++++++++++
 meta/recipes-core/newlib/newlib.inc                | 58 ++++++++++++++++++++++
 meta/recipes-core/newlib/newlib_3.0.0.bb           | 16 ++++++
 meta/recipes-devtools/gcc/gcc-cross.inc            |  1 +
 6 files changed, 178 insertions(+)
 create mode 100644 meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch
 create mode 100644 meta/recipes-core/newlib/libgloss/fix_makefile_include_arm_h.patch
 create mode 100644 meta/recipes-core/newlib/libgloss_3.0.0.bb
 create mode 100644 meta/recipes-core/newlib/newlib.inc
 create mode 100644 meta/recipes-core/newlib/newlib_3.0.0.bb

diff --git a/meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch b/meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch
new file mode 100644
index 0000000..c220fb8
--- /dev/null
+++ b/meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch
@@ -0,0 +1,41 @@
+Upstream-Status: Inappropriate  [OE-Specific]
+
+Make install tries to perform install for all variants, but some of them use the same
+name for crt0 in specific, so performing all of them results in an error during
+do_install, we simply modify the name of the objects so the installation can proceed
+and leave it to the user to select which object files to use.
+
+Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
+
+Index: newlib-3.0.0/libgloss/rs6000/Makefile.in
+===================================================================
+--- newlib-3.0.0.orig/libgloss/rs6000/Makefile.in
++++ newlib-3.0.0/libgloss/rs6000/Makefile.in
+@@ -358,7 +358,7 @@ install-sim:
+       set -e; for x in ${SIM_CRT0} ${SIM_BSP} ${SIM_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-mvme:
+-      set -e; for x in ${MVME_CRT0} ${MVME_BSP} ${MVME_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
++      set -e; for x in ${MVME_CRT0} ${MVME_BSP} ${MVME_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/mvme-$$x; done
+
+ install-solaris:
+       set -e; for x in ${SOLARIS_CRT0} ${SOLARIS_BSP} ${SOLARIS_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+@@ -367,15 +367,15 @@ install-linux:
+       set -e; for x in ${LINUX_CRT0} ${LINUX_BSP} ${LINUX_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-yellowknife:
+-      set -e; for x in ${YELLOWKNIFE_CRT0} ${YELLOWKNIFE_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
++      set -e; for x in ${YELLOWKNIFE_CRT0} ${YELLOWKNIFE_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/yellowknife-$$x; done
+       set -e; for x in ${YELLOWKNIFE_SCRIPTS}; do ${INSTALL_DATA} $(srcdir)/$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-ads:
+-      set -e; for x in ${ADS_CRT0} ${ADS_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
++      set -e; for x in ${ADS_CRT0} ${ADS_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/ads-$$x; done
+       set -e; for x in ${ADS_SCRIPTS}; do ${INSTALL_DATA} $(srcdir)/$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-mbx:
+-      set -e; for x in ${MBX_CRT0} ${MBX_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
++      set -e; for x in ${MBX_CRT0} ${MBX_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/mbx-$$x; done
+       set -e; for x in ${MBX_SCRIPTS} ${MBX_SPECS}; do ${INSTALL_DATA} $(srcdir)/$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-xil:
diff --git a/meta/recipes-core/newlib/libgloss/fix_makefile_include_arm_h.patch b/meta/recipes-core/newlib/libgloss/fix_makefile_include_arm_h.patch
new file mode 100644
index 0000000..7645be7
--- /dev/null
+++ b/meta/recipes-core/newlib/libgloss/fix_makefile_include_arm_h.patch
@@ -0,0 +1,30 @@
+Upstream-Status: Inappropriate  [OE-Specific]
+
+When trying to build libgloss for an arm target, the build system
+complains about missing some include files:
+
+| fatal error: acle-compiat.h: No such file or directory
+|  #include "acle-compat.h"
+|           ^~~~~~~~~~~~~~~
+| compilation terminated.
+
+These include files come from the newlib source, but since we
+are building libgloss separately from newlib, libgloss is unaware
+of where they are, this patch fixes the INCLUDES so the build system
+can find such files.
+
+Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
+
+Index: newlib-3.0.0/libgloss/config/default.mh
+===================================================================
+--- newlib-3.0.0.orig/libgloss/config/default.mh
++++ newlib-3.0.0/libgloss/config/default.mh
+@@ -1,7 +1,7 @@
+ NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
+ NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
+
+-INCLUDES = -I. -I$(srcdir)/..
++INCLUDES = -I. -I$(srcdir)/.. -I$(srcdir)/../newlib/libc/machine/arm
+ # Note that when building the library, ${MULTILIB} is not the way multilib
+ # options are passed; they're passed in $(CFLAGS).
+ CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
diff --git a/meta/recipes-core/newlib/libgloss_3.0.0.bb b/meta/recipes-core/newlib/libgloss_3.0.0.bb
new file mode 100644
index 0000000..664a922
--- /dev/null
+++ b/meta/recipes-core/newlib/libgloss_3.0.0.bb
@@ -0,0 +1,32 @@
+require newlib.inc
+
+DEPENDS += "newlib"
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/libgloss:"
+
+SRC_URI_append_powerpc = " file://fix-rs6000-crt0.patch"
+SRC_URI_append_arm = " file://fix_makefile_include_arm_h.patch"
+
+do_configure() {
+       ${S}/libgloss/configure ${EXTRA_OECONF}
+}
+
+do_install_prepend() {
+       # install doesn't create this itself, avoid install error
+       install -d ${D}${prefix}/${TARGET_SYS}/lib
+}
+
+do_install_append() {
+       # Move libs to default directories so they can be picked up later
+       mv -v ${D}${prefix}/${TARGET_SYS}/lib ${D}${libdir}
+
+       # Remove original directory
+       rmdir ${D}${prefix}/${TARGET_SYS}
+}
+
+# Split packages correctly
+FILES_${PN} += "${libdir}/*.ld ${libdir}/*.specs"
+FILES_${PN}-dev += "${libdir}/cpu-init/*"
+
+INHIBIT_PACKAGE_STRIP = "1"
+INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
diff --git a/meta/recipes-core/newlib/newlib.inc b/meta/recipes-core/newlib/newlib.inc
new file mode 100644
index 0000000..c97c7c2
--- /dev/null
+++ b/meta/recipes-core/newlib/newlib.inc
@@ -0,0 +1,58 @@
+SUMMARY = "Newlib is a C library intended for use on embedded systems"
+HOMEPAGE = "https://sourceware.org/newlib/"
+DESCRIPTION = "C library intended for use on embedded systems. It is a conglomeration of several library parts, all under free software licenses that make them easily usable on embedded products."
+SECTION = "libs"
+
+LICENSE = "GPLv2 & LGPLv3 & GPLv3 & LGPLv2"
+LIC_FILES_CHKSUM = " \
+               file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \
+               file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6 \
+               file://COPYING3;md5=d32239bcb673463ab874e80d47fae504 \
+               file://COPYING.LIBGLOSS;md5=73f5c98779aea7dba4a6c94a74ab0ae2 \
+               file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \
+               file://COPYING.NEWLIB;md5=956a4b1487f7677cdcceeee8f05a21f0 \
+               file://newlib/libc/posix/COPYRIGHT;md5=103468ff1982be840fdf4ee9f8b51bbf \
+               file://newlib/libc/sys/linux/linuxthreads/LICENSE;md5=73640207fbc79b198c7ffd4ad4d97aa0 \
+               "
+
+SRC_URI = "ftp://sourceware.org/pub/newlib/newlib-${PV}.tar.gz"
+SRC_URI[md5sum] = "81ec873108b8593c586f91ca65963952"
+SRC_URI[sha256sum] = "c8566335ee74e5fcaeb8595b4ebd0400c4b043d6acb3263ecb1314f8f5501332"
+
+INHIBIT_DEFAULT_DEPS = "1"
+DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial"
+
+PATH_prepend = "${STAGING_BINDIR_TOOLCHAIN}.${STAGINGCC}:"
+STAGINGCC = "gcc-cross-initial-${TARGET_ARCH}"
+STAGINGCC_class-nativesdk = "gcc-crosssdk-initial-${SDK_SYS}"
+
+S = "${WORKDIR}/newlib-${PV}"
+B = "${WORKDIR}/build"
+
+## disable stdlib
+TARGET_CC_ARCH_append = " -nostdlib"
+
+EXTRA_OECONF = " \
+                --build=${BUILD_SYS}  \
+                --target=${TARGET_SYS} \
+               --host=${HOST_SYS} \
+                --prefix=${prefix}  \
+                --exec-prefix=${exec_prefix} \
+                --bindir=${bindir} \
+                --libdir=${libdir} \
+                --includedir=${includedir} \
+               --enable-languages=c \
+               --with-newlib \
+               --with-gnu-as \
+               --with-gnu-ld \
+               --disable-multilib \
+               "
+
+do_configure[cleandirs] = "${B}"
+
+do_install() {
+       oe_runmake install DESTDIR='${D}'
+}
+
+COMPATIBLE_HOST_libc-musl_class-target = "null"
+COMPATIBLE_HOST_libc-glibc_class-target = "null"
diff --git a/meta/recipes-core/newlib/newlib_3.0.0.bb b/meta/recipes-core/newlib/newlib_3.0.0.bb
new file mode 100644
index 0000000..3380576
--- /dev/null
+++ b/meta/recipes-core/newlib/newlib_3.0.0.bb
@@ -0,0 +1,16 @@
+require newlib.inc
+
+PROVIDES += "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc virtual/libiconv virtual/libintl"
+
+do_configure() {
+       ${S}/configure ${EXTRA_OECONF}
+}
+
+do_install_append() {
+       # Move include files and libs to default directories so they can be picked up later
+       mv -v ${D}${prefix}/${TARGET_SYS}/lib ${D}${libdir}
+       mv -v ${D}${prefix}/${TARGET_SYS}/include ${D}${includedir}
+
+       # Remove original directory
+       rmdir ${D}${prefix}/${TARGET_SYS}
+}
diff --git a/meta/recipes-devtools/gcc/gcc-cross.inc b/meta/recipes-devtools/gcc/gcc-cross.inc
index 1e184a6..95f5968 100644
--- a/meta/recipes-devtools/gcc/gcc-cross.inc
+++ b/meta/recipes-devtools/gcc/gcc-cross.inc
@@ -35,6 +35,7 @@ EXTRA_OECONF += "\
 DEPENDS_remove_libc-baremetal := "virtual/${TARGET_PREFIX}libc-for-gcc"
 EXTRA_OECONF_append_libc-baremetal = " --without-headers"
 EXTRA_OECONF_remove_libc-baremetal = "--enable-threads=posix"
+EXTRA_OECONF_remove_libc-newlib = "--enable-threads=posix"

 EXTRA_OECONF_PATHS = "\
     --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
--
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.


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] insane.bbclass: Adds powerpc to elf headers machine dictionary
  2018-05-23 23:09 [PATCH 0/3] Add Newlib as a C library for baremetal Alejandro Enedino Hernandez Samaniego
  2018-05-23 23:09 ` [PATCH 1/3] newlib: Adds newlib and libgloss recipes Alejandro Enedino Hernandez Samaniego
@ 2018-05-23 23:09 ` Alejandro Enedino Hernandez Samaniego
  2018-05-23 23:09 ` [PATCH 3/3] tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library Alejandro Enedino Hernandez Samaniego
  2018-05-25  3:48 ` [PATCH 0/3] Add Newlib as a C library for baremetal Manjukumar Harthikote Matha
  3 siblings, 0 replies; 6+ messages in thread
From: Alejandro Enedino Hernandez Samaniego @ 2018-05-23 23:09 UTC (permalink / raw)
  To: openembedded-core

This patch adds makes it possible to build elf for powerpc by adding
this combination to the elf headers machine dictionary, this can be
useful when trying to build baremetal applications where the TARGET_OS=elf

Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
---
 meta/classes/insane.bbclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index fa15460..bd7f519 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -71,6 +71,7 @@ def package_qa_get_machine_dict(d):
                         "microblaze":  (189,   0,    0,          False,         32),
                         "microblazeeb":(189,   0,    0,          False,         32),
                         "microblazeel":(189,   0,    0,          True,          32),
+                        "powerpc":    (20,     0,    0,          False,         32),
                         "riscv32":    (243,    0,    0,          True,          32),
                         "riscv64":    (243,    0,    0,          True,          64),
                       },
--
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.


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library
  2018-05-23 23:09 [PATCH 0/3] Add Newlib as a C library for baremetal Alejandro Enedino Hernandez Samaniego
  2018-05-23 23:09 ` [PATCH 1/3] newlib: Adds newlib and libgloss recipes Alejandro Enedino Hernandez Samaniego
  2018-05-23 23:09 ` [PATCH 2/3] insane.bbclass: Adds powerpc to elf headers machine dictionary Alejandro Enedino Hernandez Samaniego
@ 2018-05-23 23:09 ` Alejandro Enedino Hernandez Samaniego
  2018-05-24  1:06   ` Andre McCurdy
  2018-05-25  3:48 ` [PATCH 0/3] Add Newlib as a C library for baremetal Manjukumar Harthikote Matha
  3 siblings, 1 reply; 6+ messages in thread
From: Alejandro Enedino Hernandez Samaniego @ 2018-05-23 23:09 UTC (permalink / raw)
  To: openembedded-core

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@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"):
         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}"
+
+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
+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.


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library
  2018-05-23 23:09 ` [PATCH 3/3] tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library Alejandro Enedino Hernandez Samaniego
@ 2018-05-24  1:06   ` Andre McCurdy
  0 siblings, 0 replies; 6+ messages in thread
From: Andre McCurdy @ 2018-05-24  1:06 UTC (permalink / raw)
  To: Alejandro Enedino Hernandez Samaniego; +Cc: OE Core mailing list

On Wed, May 23, 2018 at 4:09 PM, Alejandro Enedino Hernandez Samaniego
<alejandro.enedino.hernandez-samaniego@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@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@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] Add Newlib as a C library for baremetal
  2018-05-23 23:09 [PATCH 0/3] Add Newlib as a C library for baremetal Alejandro Enedino Hernandez Samaniego
                   ` (2 preceding siblings ...)
  2018-05-23 23:09 ` [PATCH 3/3] tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library Alejandro Enedino Hernandez Samaniego
@ 2018-05-25  3:48 ` Manjukumar Harthikote Matha
  3 siblings, 0 replies; 6+ messages in thread
From: Manjukumar Harthikote Matha @ 2018-05-25  3:48 UTC (permalink / raw)
  To: Alejandro Enedino Hernandez Samaniego, openembedded-core



> -----Original Message-----
> From: openembedded-core-bounces@lists.openembedded.org
> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
> Alejandro Enedino Hernandez Samaniego
> Sent: Wednesday, May 23, 2018 4:09 PM
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH 0/3] Add Newlib as a C library for baremetal
> 
> Newlib is a widely used C library for embedded systems, its mainly used for
> resource constrained devices which run baremetal applications.
> 
> It provides basic C library functionality, and it is meant to be extended by design,
> it contains several stubs for core functions that can be later overriden with the
> symbols provided from another library at linking time.
> 
> Libgloss is the BSP part of the library which follows the same principle, where a
> BSP layer can override functionality or even application runtime depending on the
> processor architecture.
> 
> These patches add both the libgloss and newlib recipes, provide functionality to
> make them extendable by other libraries if required, and also create a new TCLIBC
> variant, which can now be set to newlib to build the toolchain for applications
> where its suitable.
> 
> Newlib is also usually used by vendors to provide embedded toolchains, which is
> interesting since, this enables OE to build such toolchains in a somewhat
> automated way.
> 
> These patches have been tested on my end in the following ways:
> 
> - meta-toolchain builds successfully on qemux86, qemux86-64, qemuarm,
> qemuarm64,
>   qemuppc, qemumips.
> - A helloworld application that lays in another layer was built for qemux86,
> qemux86-64
>   qemuarm, qemuarm64, qemuppc, qemumips, and it seems to have been built
> correctly.
> - The hardware that I have available is from Xilinx, where Xilinx already had a
>   baremetal application they ran on it, I was able to build the same application
>   with a recipe, that used the toolchain coming from these patches
> (TCLIBC=newlib).
>   I ran the application on hardware and confirmed that it was built and working
> correctly.
> - meta-toolchain builds successfully for the previously mentioned HW MACHINE
> as well.
> - I also have a meta-freertos (its a possibility) layer that builds a FreeRTOS
> application

Can we put out this layer on github for evaluation? 
Community member is interested in such a layer?

>   that runs on qemuarm, and instead of using the provided ARM Embedded
> Toolchain, I used
>   the one coming from these patches and was able to obtain the same result.
> - I built world for all the previously mentioned MACHINES (qemus and HW) just to
> make sure
>   that this did not affect other OE components, and it did not seem to be the case.
> 
> The following changes since commit
> 7897fb35a3420c2555ab59dfa438217ada4a9784:
> 
>   libnss-mdns: fix postinst and postrm (2018-05-22 13:13:33 +0100)
> 
> are available in the git repository at:
> 
>   git://push.yoctoproject.org/poky-contrib aehs29/newlib
> 
> Alejandro Enedino Hernandez Samaniego (3):
>   newlib: Adds newlib and libgloss recipes
>   insane.bbclass: Adds powerpc to elf headers machine dictionary
>   tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C
>     library
> 
>  meta/classes/cross-canadian.bbclass                |  2 +-
>  meta/classes/insane.bbclass                        |  1 +
>  meta/conf/distro/include/tclibc-newlib.inc         | 47 ++++++++++++++++++
>  .../newlib/libgloss/fix-rs6000-crt0.patch          | 41 +++++++++++++++
>  .../libgloss/fix_makefile_include_arm_h.patch      | 30 +++++++++++
>  meta/recipes-core/newlib/libgloss_3.0.0.bb         | 32 ++++++++++++
>  meta/recipes-core/newlib/newlib.inc                | 58 ++++++++++++++++++++++
>  meta/recipes-core/newlib/newlib_3.0.0.bb           | 19 +++++++
>  meta/recipes-devtools/gcc/gcc-cross.inc            |  1 +
>  meta/recipes-devtools/gcc/libgcc-common.inc        |  5 ++
>  10 files changed, 235 insertions(+), 1 deletion(-)  create mode 100644
> meta/conf/distro/include/tclibc-newlib.inc
>  create mode 100644 meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch
>  create mode 100644 meta/recipes-
> core/newlib/libgloss/fix_makefile_include_arm_h.patch
>  create mode 100644 meta/recipes-core/newlib/libgloss_3.0.0.bb
>  create mode 100644 meta/recipes-core/newlib/newlib.inc
>  create mode 100644 meta/recipes-core/newlib/newlib_3.0.0.bb
> 

Acked-by : Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>

Thanks,
Manju


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-25  4:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-23 23:09 [PATCH 0/3] Add Newlib as a C library for baremetal Alejandro Enedino Hernandez Samaniego
2018-05-23 23:09 ` [PATCH 1/3] newlib: Adds newlib and libgloss recipes Alejandro Enedino Hernandez Samaniego
2018-05-23 23:09 ` [PATCH 2/3] insane.bbclass: Adds powerpc to elf headers machine dictionary Alejandro Enedino Hernandez Samaniego
2018-05-23 23:09 ` [PATCH 3/3] tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library Alejandro Enedino Hernandez Samaniego
2018-05-24  1:06   ` Andre McCurdy
2018-05-25  3:48 ` [PATCH 0/3] Add Newlib as a C library for baremetal Manjukumar Harthikote Matha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.