All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] machine_dict: Add i686 to the ELF machine dictionary
@ 2020-01-18 21:22 Alejandro Enedino Hernandez Samaniego
  2020-01-18 21:22 ` [PATCH] newlib: Enable building libstdc++ for newlib based toolchains Alejandro Enedino Hernandez Samaniego
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Enedino Hernandez Samaniego @ 2020-01-18 21:22 UTC (permalink / raw)
  To: openembedded-core

An error like the following is thrown when building
baremetal applications on some x86 architectures:

  (machine, osabi, abiversion, littleendian, bits) \
    = oe.elf.machine_dict(d)[target_os][target_arch]

Exception: KeyError: i686

Since the i686 (target_arch) key does not exist in the dictionary.

Add the key to fix the error.

Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandro@enedino.org>
---
 meta/lib/oe/elf.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/lib/oe/elf.py b/meta/lib/oe/elf.py
index 2562cea..e0c31ff 100644
--- a/meta/lib/oe/elf.py
+++ b/meta/lib/oe/elf.py
@@ -15,6 +15,7 @@ def machine_dict(d):
                         "aarch64" :   (183,    0,    0,          True,          64),
                         "aarch64_be" :(183,    0,    0,          False,         64),
                         "i586" :      (3,      0,    0,          True,          32),
+                        "i686" :      (3,      0,    0,          True,          32),
                         "x86_64":     (62,     0,    0,          True,          64),
                         "epiphany":   (4643,   0,    0,          True,          32),
                         "lm32":       (138,    0,    0,          False,         32),
-- 
2.7.4



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

* [PATCH] newlib: Enable building libstdc++ for newlib based toolchains
  2020-01-18 21:22 [PATCH] machine_dict: Add i686 to the ELF machine dictionary Alejandro Enedino Hernandez Samaniego
@ 2020-01-18 21:22 ` Alejandro Enedino Hernandez Samaniego
  2020-01-18 23:25   ` Richard Purdie
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Enedino Hernandez Samaniego @ 2020-01-18 21:22 UTC (permalink / raw)
  To: openembedded-core

Some baremetal applications might require support from libstdc++.

On newlib based toolchains, libstdc++ can be built as a static
library that applications can then link against it.

Pass libsdtc++-(static)dev to LIBC_DEPENDENCIES allowing the
library to be present for cross compilation as well as on
sdk builds.

This also requires to modify the gcc-runtime recipe to
explictly build only libsdtc++ correctly.

Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandro@enedino.org>
---
 meta/conf/distro/include/tclibc-newlib.inc | 7 +++----
 meta/recipes-devtools/gcc/gcc-runtime.inc  | 6 ++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/meta/conf/distro/include/tclibc-newlib.inc b/meta/conf/distro/include/tclibc-newlib.inc
index 896c0b1..8338003 100644
--- a/meta/conf/distro/include/tclibc-newlib.inc
+++ b/meta/conf/distro/include/tclibc-newlib.inc
@@ -25,12 +25,11 @@ LIBC_DEPENDENCIES = "\
     libgloss-dbg \
     libgcc-dev \
     libgcc-dbg \
+    libstdc++-dev \
+    libstdc++-staticdev \
     "
 
-# 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 overridden by tcmode-default
-ASSUME_PROVIDED += "virtual/${TARGET_PREFIX}compilerlibs virtual/crypt"
+ASSUME_PROVIDED += "virtual/crypt"
 
 # Its useful to be able to extend newlib, but we dont provide a native variant of libgloss
 NEWLIB_EXTENDED ?=  "libgloss libgcc"
diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc b/meta/recipes-devtools/gcc/gcc-runtime.inc
index d3f8ae8..f035fbd 100644
--- a/meta/recipes-devtools/gcc/gcc-runtime.inc
+++ b/meta/recipes-devtools/gcc/gcc-runtime.inc
@@ -17,6 +17,9 @@ EXTRA_OECONF_PATHS = "\
 EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu"
 EXTRA_OECONF_append = " --cache-file=${B}/config.cache"
 
+EXTRA_OECONF_remove_libc-newlib = "--enable-symvers=gnu"
+EXTRA_OECONF_append_libc-newlib = " --with-newlib"
+
 # Disable ifuncs for libatomic on arm conflicts -march/-mcpu
 EXTRA_OECONF_append_arm = " libat_cv_have_ifunc=no "
 
@@ -33,6 +36,9 @@ RUNTIMELIBITM_riscv64 = ""
 RUNTIMELIBSSP ?= ""
 RUNTIMELIBSSP_mingw32 ?= "libssp"
 
+# Only build libstdc++ for newlib
+RUNTIMETARGET_libc-newlib = "libstdc++-v3"
+
 RUNTIMETARGET = "${RUNTIMELIBSSP} libstdc++-v3 libgomp libatomic ${RUNTIMELIBITM} \
     ${@bb.utils.contains_any('FORTRAN', [',fortran',',f77'], 'libquadmath', '', d)} \
 "
-- 
2.7.4



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

* Re: [PATCH] newlib: Enable building libstdc++ for newlib based toolchains
  2020-01-18 21:22 ` [PATCH] newlib: Enable building libstdc++ for newlib based toolchains Alejandro Enedino Hernandez Samaniego
@ 2020-01-18 23:25   ` Richard Purdie
  2020-01-19  1:01     ` Alejandro Enedino Hernandez Samaniego
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2020-01-18 23:25 UTC (permalink / raw)
  To: Alejandro Enedino Hernandez Samaniego, openembedded-core

On Sat, 2020-01-18 at 13:22 -0800, Alejandro Enedino Hernandez
Samaniego wrote:
> Some baremetal applications might require support from libstdc++.
> 
> On newlib based toolchains, libstdc++ can be built as a static
> library that applications can then link against it.
> 
> Pass libsdtc++-(static)dev to LIBC_DEPENDENCIES allowing the
> library to be present for cross compilation as well as on
> sdk builds.
> 
> This also requires to modify the gcc-runtime recipe to
> explictly build only libsdtc++ correctly.
> 
> Signed-off-by: Alejandro Enedino Hernandez Samaniego <
> alejandro@enedino.org>
> ---
>  meta/conf/distro/include/tclibc-newlib.inc | 7 +++----
>  meta/recipes-devtools/gcc/gcc-runtime.inc  | 6 ++++++
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/meta/conf/distro/include/tclibc-newlib.inc
> b/meta/conf/distro/include/tclibc-newlib.inc
> index 896c0b1..8338003 100644
> --- a/meta/conf/distro/include/tclibc-newlib.inc
> +++ b/meta/conf/distro/include/tclibc-newlib.inc
> @@ -25,12 +25,11 @@ LIBC_DEPENDENCIES = "\
>      libgloss-dbg \
>      libgcc-dev \
>      libgcc-dbg \
> +    libstdc++-dev \
> +    libstdc++-staticdev \
>      "
>  
> -# 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 overridden by tcmode-default
> -ASSUME_PROVIDED += "virtual/${TARGET_PREFIX}compilerlibs
> virtual/crypt"
> +ASSUME_PROVIDED += "virtual/crypt"
>  
>  # Its useful to be able to extend newlib, but we dont provide a
> native variant of libgloss
>  NEWLIB_EXTENDED ?=  "libgloss libgcc"
> diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc
> b/meta/recipes-devtools/gcc/gcc-runtime.inc
> index d3f8ae8..f035fbd 100644
> --- a/meta/recipes-devtools/gcc/gcc-runtime.inc
> +++ b/meta/recipes-devtools/gcc/gcc-runtime.inc
> @@ -17,6 +17,9 @@ EXTRA_OECONF_PATHS = "\
>  EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu"
>  EXTRA_OECONF_append = " --cache-file=${B}/config.cache"
>  
> +EXTRA_OECONF_remove_libc-newlib = "--enable-symvers=gnu"
> +EXTRA_OECONF_append_libc-newlib = " --with-newlib"
> +

I really don't like using remove in core. Can we restructure this so
that symvers is set something like:

SYMVERS_CONF = " --enable-clocale=gnu"
SYMVERS_CONF_libc-newlib = ""
EXTRA_OECONF_append += "${SYMVERS_CONF}"

?

>  # Disable ifuncs for libatomic on arm conflicts -march/-mcpu
>  EXTRA_OECONF_append_arm = " libat_cv_have_ifunc=no "
>  
> @@ -33,6 +36,9 @@ RUNTIMELIBITM_riscv64 = ""
>  RUNTIMELIBSSP ?= ""
>  RUNTIMELIBSSP_mingw32 ?= "libssp"
>  
> +# Only build libstdc++ for newlib
> +RUNTIMETARGET_libc-newlib = "libstdc++-v3"
> +
>  RUNTIMETARGET = "${RUNTIMELIBSSP} libstdc++-v3 libgomp libatomic
> ${RUNTIMELIBITM} \
>      ${@bb.utils.contains_any('FORTRAN', [',fortran',',f77'],
> 'libquadmath', '', d)} \
>  "

Convention is top put the overridden version under the original.

Cheers,

Richard



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

* Re: [PATCH] newlib: Enable building libstdc++ for newlib based toolchains
  2020-01-18 23:25   ` Richard Purdie
@ 2020-01-19  1:01     ` Alejandro Enedino Hernandez Samaniego
  0 siblings, 0 replies; 4+ messages in thread
From: Alejandro Enedino Hernandez Samaniego @ 2020-01-19  1:01 UTC (permalink / raw)
  To: Richard Purdie; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 3453 bytes --]

On Sat, 18 Jan 2020 at 15:25, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Sat, 2020-01-18 at 13:22 -0800, Alejandro Enedino Hernandez
> Samaniego wrote:
> > Some baremetal applications might require support from libstdc++.
> >
> > On newlib based toolchains, libstdc++ can be built as a static
> > library that applications can then link against it.
> >
> > Pass libsdtc++-(static)dev to LIBC_DEPENDENCIES allowing the
> > library to be present for cross compilation as well as on
> > sdk builds.
> >
> > This also requires to modify the gcc-runtime recipe to
> > explictly build only libsdtc++ correctly.
> >
> > Signed-off-by: Alejandro Enedino Hernandez Samaniego <
> > alejandro@enedino.org>
> > ---
> >  meta/conf/distro/include/tclibc-newlib.inc | 7 +++----
> >  meta/recipes-devtools/gcc/gcc-runtime.inc  | 6 ++++++
> >  2 files changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/meta/conf/distro/include/tclibc-newlib.inc
> > b/meta/conf/distro/include/tclibc-newlib.inc
> > index 896c0b1..8338003 100644
> > --- a/meta/conf/distro/include/tclibc-newlib.inc
> > +++ b/meta/conf/distro/include/tclibc-newlib.inc
> > @@ -25,12 +25,11 @@ LIBC_DEPENDENCIES = "\
> >      libgloss-dbg \
> >      libgcc-dev \
> >      libgcc-dbg \
> > +    libstdc++-dev \
> > +    libstdc++-staticdev \
> >      "
> >
> > -# 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 overridden by tcmode-default
> > -ASSUME_PROVIDED += "virtual/${TARGET_PREFIX}compilerlibs
> > virtual/crypt"
> > +ASSUME_PROVIDED += "virtual/crypt"
> >
> >  # Its useful to be able to extend newlib, but we dont provide a
> > native variant of libgloss
> >  NEWLIB_EXTENDED ?=  "libgloss libgcc"
> > diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc
> > b/meta/recipes-devtools/gcc/gcc-runtime.inc
> > index d3f8ae8..f035fbd 100644
> > --- a/meta/recipes-devtools/gcc/gcc-runtime.inc
> > +++ b/meta/recipes-devtools/gcc/gcc-runtime.inc
> > @@ -17,6 +17,9 @@ EXTRA_OECONF_PATHS = "\
> >  EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu"
> >  EXTRA_OECONF_append = " --cache-file=${B}/config.cache"
> >
> > +EXTRA_OECONF_remove_libc-newlib = "--enable-symvers=gnu"
> > +EXTRA_OECONF_append_libc-newlib = " --with-newlib"
> > +
>
> I really don't like using remove in core. Can we restructure this so
> that symvers is set something like:
>
> SYMVERS_CONF = " --enable-clocale=gnu"
> SYMVERS_CONF_libc-newlib = ""
> EXTRA_OECONF_append += "${SYMVERS_CONF}"
>
> ?
>

Hey Richard,

Absolutely agree, I will send a v2 with these changes.

Alejandro

>
> >  # Disable ifuncs for libatomic on arm conflicts -march/-mcpu
> >  EXTRA_OECONF_append_arm = " libat_cv_have_ifunc=no "
> >
> > @@ -33,6 +36,9 @@ RUNTIMELIBITM_riscv64 = ""
> >  RUNTIMELIBSSP ?= ""
> >  RUNTIMELIBSSP_mingw32 ?= "libssp"
> >
> > +# Only build libstdc++ for newlib
> > +RUNTIMETARGET_libc-newlib = "libstdc++-v3"
> > +
> >  RUNTIMETARGET = "${RUNTIMELIBSSP} libstdc++-v3 libgomp libatomic
> > ${RUNTIMELIBITM} \
> >      ${@bb.utils.contains_any('FORTRAN', [',fortran',',f77'],
> > 'libquadmath', '', d)} \
> >  "
>
> Convention is top put the overridden version under the original.
>

Will change this as well



>
> Cheers,
>
> Richard
>
>

[-- Attachment #2: Type: text/html, Size: 5288 bytes --]

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

end of thread, other threads:[~2020-01-19  1:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-18 21:22 [PATCH] machine_dict: Add i686 to the ELF machine dictionary Alejandro Enedino Hernandez Samaniego
2020-01-18 21:22 ` [PATCH] newlib: Enable building libstdc++ for newlib based toolchains Alejandro Enedino Hernandez Samaniego
2020-01-18 23:25   ` Richard Purdie
2020-01-19  1:01     ` Alejandro Enedino Hernandez Samaniego

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.