All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] nano package fail to build; cannot include curses.h
@ 2020-05-09  5:43 William Tambe
  2020-05-09 10:01 ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: William Tambe @ 2020-05-09  5:43 UTC (permalink / raw)
  To: buildroot

Nano package fail to build with the following error:

nano.h:89:10: fatal error: curses.h: No such file or directory

curses.h library can be found in the following path:
./target/usr/include/curses.h
./target/usr/include/ncurses.h
./host/iron-buildroot-linux-gnu/sysroot/usr/include/curses.h
./host/iron-buildroot-linux-gnu/sysroot/usr/include/ncurses.h
./host/include/ncurses/curses.h
./host/include/ncurses/ncurses.h

Any idea why the nano package fail to build despite the headers being
available ?

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

* [Buildroot] nano package fail to build; cannot include curses.h
  2020-05-09  5:43 [Buildroot] nano package fail to build; cannot include curses.h William Tambe
@ 2020-05-09 10:01 ` Thomas Petazzoni
  2020-05-09 13:04   ` William Tambe
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2020-05-09 10:01 UTC (permalink / raw)
  To: buildroot

Hello,

On Sat, 9 May 2020 01:43:56 -0400
William Tambe <tambewilliam@gmail.com> wrote:

> Nano package fail to build with the following error:
> 
> nano.h:89:10: fatal error: curses.h: No such file or directory
> 
> curses.h library can be found in the following path:
> ./target/usr/include/curses.h
> ./target/usr/include/ncurses.h
> ./host/iron-buildroot-linux-gnu/sysroot/usr/include/curses.h
> ./host/iron-buildroot-linux-gnu/sysroot/usr/include/ncurses.h
> ./host/include/ncurses/curses.h
> ./host/include/ncurses/ncurses.h
> 
> Any idea why the nano package fail to build despite the headers being
> available ?

You need to provide more details, and especially which version of
Buildroot you're using, and a defconfig that allows to reproduce the
issue.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] nano package fail to build; cannot include curses.h
  2020-05-09 10:01 ` Thomas Petazzoni
@ 2020-05-09 13:04   ` William Tambe
  2020-05-09 13:13     ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: William Tambe @ 2020-05-09 13:04 UTC (permalink / raw)
  To: buildroot

On Sat, May 9, 2020 at 6:01 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> On Sat, 9 May 2020 01:43:56 -0400
> William Tambe <tambewilliam@gmail.com> wrote:
>
> > Nano package fail to build with the following error:
> >
> > nano.h:89:10: fatal error: curses.h: No such file or directory
> >
> > curses.h library can be found in the following path:
> > ./target/usr/include/curses.h
> > ./target/usr/include/ncurses.h
> > ./host/iron-buildroot-linux-gnu/sysroot/usr/include/curses.h
> > ./host/iron-buildroot-linux-gnu/sysroot/usr/include/ncurses.h
> > ./host/include/ncurses/curses.h
> > ./host/include/ncurses/ncurses.h
> >
> > Any idea why the nano package fail to build despite the headers being
> > available ?
>
> You need to provide more details, and especially which version of
> Buildroot you're using, and a defconfig that allows to reproduce the
> issue.

I am using a git clone with master branch @
b365c642369ca76cb138fd0b5be6457865a3d5ce

Below is patch of all the changes I am using on top of above master commit-id:

Date: Sat, 9 May 2020 07:56:33 -0500
Subject: [PATCH] Target IRON support

---
 arch/Config.in                                    | 10 ++++++++++
 arch/Config.in.iron                               |  8 ++++++++
 configs/iron_defconfig                            | 15 +++++++++++++++
 support/gnuconfig/config.sub                      |  1 +
 .../toolchain-external-custom/Config.in.options   |  1 -
 5 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 arch/Config.in.iron
 create mode 100644 configs/iron_defconfig

diff --git a/arch/Config.in b/arch/Config.in
index 94bd2150ca..5bf954be74 100644
--- a/arch/Config.in
+++ b/arch/Config.in
@@ -208,6 +208,12 @@ config BR2_powerpc64le
    http://www.power.org/
    http://en.wikipedia.org/wiki/Powerpc

+config BR2_iron
+ bool "IRON"
+ select BR2_ARCH_HAS_MMU_MANDATORY
+ help
+   IRON is a RISC architecture.
+
 config BR2_riscv
  bool "RISCV"
  select BR2_ARCH_HAS_MMU_MANDATORY
@@ -449,6 +455,10 @@ if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
 source "arch/Config.in.powerpc"
 endif

+if BR2_iron
+source "arch/Config.in.iron"
+endif
+
 if BR2_riscv
 source "arch/Config.in.riscv"
 endif
diff --git a/arch/Config.in.iron b/arch/Config.in.iron
new file mode 100644
index 0000000000..756b8fde42
--- /dev/null
+++ b/arch/Config.in.iron
@@ -0,0 +1,8 @@
+config BR2_ARCH
+ default "iron"
+
+config BR2_ENDIAN
+ default "LITTLE"
+
+config BR2_READELF_ARCH_NAME
+ default "IRON"
diff --git a/configs/iron_defconfig b/configs/iron_defconfig
new file mode 100644
index 0000000000..29cc533f7d
--- /dev/null
+++ b/configs/iron_defconfig
@@ -0,0 +1,15 @@
+BR2_iron=y
+BR2_STATIC_LIBS=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_PATH="/opt/iron-toolchain/"
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-elf"
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_5=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+# BR2_TOOLCHAIN_EXTERNAL_HAS_SSP_STRONG is not set
+# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
+BR2_ROOTFS_MERGED_USR=y
+BR2_PACKAGE_NANO=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
+# BR2_TARGET_ROOTFS_TAR is not set
diff --git a/support/gnuconfig/config.sub b/support/gnuconfig/config.sub
index 5b158ac41c..145e662955 100755
--- a/support/gnuconfig/config.sub
+++ b/support/gnuconfig/config.sub
@@ -1229,6 +1229,7 @@ case $cpu-$vendor in
  | pdp10 | pdp11 | pj | pjl | pn | power \
  | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
  | pru \
+ | iron \
  | pyramid \
  | riscv | riscv32 | riscv64 \
  | rl78 | romp | rs6000 | rx \
diff --git a/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
b/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
index 9a8078d314..01e9e214de 100644
--- a/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
+++ b/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
@@ -330,7 +330,6 @@ config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC

 config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC
  bool "glibc/eglibc"
- depends on !BR2_STATIC_LIBS
  select BR2_TOOLCHAIN_EXTERNAL_GLIBC
  help
    Select this option if your external toolchain uses the GNU C
-- 
2.25.1


>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

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

* [Buildroot] nano package fail to build; cannot include curses.h
  2020-05-09 13:04   ` William Tambe
@ 2020-05-09 13:13     ` Thomas Petazzoni
  2020-05-09 13:43       ` William Tambe
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2020-05-09 13:13 UTC (permalink / raw)
  To: buildroot

Hello William,

On Sat, 9 May 2020 09:04:03 -0400
William Tambe <tambewilliam@gmail.com> wrote:

> diff --git a/configs/iron_defconfig b/configs/iron_defconfig
> new file mode 100644
> index 0000000000..29cc533f7d
> --- /dev/null
> +++ b/configs/iron_defconfig
> @@ -0,0 +1,15 @@
> +BR2_iron=y
> +BR2_STATIC_LIBS=y
> +BR2_TOOLCHAIN_EXTERNAL=y
> +BR2_TOOLCHAIN_EXTERNAL_PATH="/opt/iron-toolchain/"
> +BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-elf"

Usually, toolchains named $(ARCH)-elf are bare metal toolchains, i.e
toolchains that don't have a C library with support for an operating
system. Are you sure this toolchain is using glibc ?

In any case, since we don't have access to your toolchain, we have no
way to reproduce/investigate. On other architectures, nano builds fine.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] nano package fail to build; cannot include curses.h
  2020-05-09 13:13     ` Thomas Petazzoni
@ 2020-05-09 13:43       ` William Tambe
  2020-05-09 14:27         ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: William Tambe @ 2020-05-09 13:43 UTC (permalink / raw)
  To: buildroot

On Sat, May 9, 2020 at 9:13 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello William,
>
> On Sat, 9 May 2020 09:04:03 -0400
> William Tambe <tambewilliam@gmail.com> wrote:
>
> > diff --git a/configs/iron_defconfig b/configs/iron_defconfig
> > new file mode 100644
> > index 0000000000..29cc533f7d
> > --- /dev/null
> > +++ b/configs/iron_defconfig
> > @@ -0,0 +1,15 @@
> > +BR2_iron=y
> > +BR2_STATIC_LIBS=y
> > +BR2_TOOLCHAIN_EXTERNAL=y
> > +BR2_TOOLCHAIN_EXTERNAL_PATH="/opt/iron-toolchain/"
> > +BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-elf"
>
> Usually, toolchains named $(ARCH)-elf are bare metal toolchains, i.e
> toolchains that don't have a C library with support for an operating
> system. Are you sure this toolchain is using glibc ?

Yes, this toolchain has glibc support.

>
> In any case, since we don't have access to your toolchain, we have no
> way to reproduce/investigate. On other architectures, nano builds fine.

My issue seems to be that it is not able to find curses.h headers
which buildroot already installed at the following path:
./target/usr/include/curses.h
./target/usr/include/ncurses.h
./host/iron-buildroot-linux-gnu/sysroot/usr/include/curses.h
./host/iron-buildroot-linux-gnu/sysroot/usr/include/ncurses.h
./host/include/ncurses/curses.h
./host/include/ncurses/ncurses.h

Using something like this in nano.mk didn't help either:

NANO_MAKE_ENV += \
        $(TARGET_MAKE_ENV) \
        CFLAGS="$(TARGET_CFLAGS) -I$(HOST_DIR)/include/ncurses"

Any other suggestion I could try in debugging the issue I am having ?

>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

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

* [Buildroot] nano package fail to build; cannot include curses.h
  2020-05-09 13:43       ` William Tambe
@ 2020-05-09 14:27         ` Thomas Petazzoni
  2020-05-09 20:08           ` William Tambe
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2020-05-09 14:27 UTC (permalink / raw)
  To: buildroot

On Sat, 9 May 2020 09:43:44 -0400
William Tambe <tambewilliam@gmail.com> wrote:

> > In any case, since we don't have access to your toolchain, we have no
> > way to reproduce/investigate. On other architectures, nano builds fine.  
> 
> My issue seems to be that it is not able to find curses.h headers
> which buildroot already installed at the following path:
> ./target/usr/include/curses.h
> ./target/usr/include/ncurses.h
> ./host/iron-buildroot-linux-gnu/sysroot/usr/include/curses.h
> ./host/iron-buildroot-linux-gnu/sysroot/usr/include/ncurses.h
> ./host/include/ncurses/curses.h
> ./host/include/ncurses/ncurses.h
> 
> Using something like this in nano.mk didn't help either:
> 
> NANO_MAKE_ENV += \
>         $(TARGET_MAKE_ENV) \
>         CFLAGS="$(TARGET_CFLAGS) -I$(HOST_DIR)/include/ncurses"

This is terribly wrong: you are point to the headers of host libraries,
while cross-compiling code for the target.

> Any other suggestion I could try in debugging the issue I am having ?

Can we have access to your "iron" toolchain to reproduce ?

Normally, the way it works is that Buildroot generates a toolchain
wrapper, which calls your toolchain "gcc" after adding
--sysroot=$(STAGING_DIR), and therefore, gcc should automatically find
headers in $(STAGING_DIR)/usr/include.

I'd suggest to create a simple C file with just #include <ncurses.h>,
and try to build it with $(HOST_DIR)/bin/iron-...-gcc. If that doesn't
work, pass BR2_DEBUG_WRAPPER=2 when calling gcc, and check what gets
passed to the gcc of your toolchain.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] nano package fail to build; cannot include curses.h
  2020-05-09 14:27         ` Thomas Petazzoni
@ 2020-05-09 20:08           ` William Tambe
  2020-05-09 20:36             ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: William Tambe @ 2020-05-09 20:08 UTC (permalink / raw)
  To: buildroot

On Sat, May 9, 2020 at 10:27 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> On Sat, 9 May 2020 09:43:44 -0400
> William Tambe <tambewilliam@gmail.com> wrote:
>
> > > In any case, since we don't have access to your toolchain, we have no
> > > way to reproduce/investigate. On other architectures, nano builds fine.
> >
> > My issue seems to be that it is not able to find curses.h headers
> > which buildroot already installed at the following path:
> > ./target/usr/include/curses.h
> > ./target/usr/include/ncurses.h
> > ./host/iron-buildroot-linux-gnu/sysroot/usr/include/curses.h
> > ./host/iron-buildroot-linux-gnu/sysroot/usr/include/ncurses.h
> > ./host/include/ncurses/curses.h
> > ./host/include/ncurses/ncurses.h
> >
> > Using something like this in nano.mk didn't help either:
> >
> > NANO_MAKE_ENV += \
> >         $(TARGET_MAKE_ENV) \
> >         CFLAGS="$(TARGET_CFLAGS) -I$(HOST_DIR)/include/ncurses"
>
> This is terribly wrong: you are point to the headers of host libraries,
> while cross-compiling code for the target.

Adjusting above NANO_MAKE_ENV, I am able to get a successfully
compilation using:

NANO_CONF_ENV += \
       CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include"

Not sure if above is still terribly wrong.

>
> > Any other suggestion I could try in debugging the issue I am having ?
>
> Can we have access to your "iron" toolchain to reproduce ?
Unfortunately, I am unable to do so at this time.
>
> Normally, the way it works is that Buildroot generates a toolchain
> wrapper, which calls your toolchain "gcc" after adding
> --sysroot=$(STAGING_DIR), and therefore, gcc should automatically find
> headers in $(STAGING_DIR)/usr/include.
>
> I'd suggest to create a simple C file with just #include <ncurses.h>,
> and try to build it with $(HOST_DIR)/bin/iron-...-gcc. If that doesn't
> work, pass BR2_DEBUG_WRAPPER=2 when calling gcc, and check what gets
> passed to the gcc of your toolchain.

I created a simple C file with just #include <ncurses.h> as you suggested.

Below is output that I get using -v in addition to
BR2_DEBUG_WRAPPER=2; and it looks like the issue I am having is due to
gcc not having an include path such as /usr/include to which sysroot
would have been prepended in order to find
/buildroot-build/host/iron-buildroot-linux-gnu/sysroot/usr/include/ncurses.h:

Toolchain wrapper was called with:
    'host/bin/iron-elf-gcc'
    'test.c'
    '-v'
Toolchain wrapper executing:
    '/opt/iron-toolchain/bin/iron-elf-gcc'
    '--sysroot'
    '/buildroot-build/host/iron-buildroot-linux-gnu/sysroot'
    'test.c'
    '-v'
Using built-in specs.
COLLECT_GCC=/opt/iron-toolchain/bin/iron-elf-gcc
COLLECT_LTO_WRAPPER=/opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/lto-wrapper
Target: iron-elf
Configured with: ../iron-toolchain/gcc/configure --target=iron-elf
--prefix=/opt/iron-toolchain --libexecdir=/opt/iron-toolchain/lib
--without-headers --disable-libssp --enable-languages=c
Thread model: single
gcc version 9.2.0 (GCC)
COLLECT_GCC_OPTIONS='-v'
 /opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/cc1 -quiet -v -isysroot
/buildroot-build/host/iron-buildroot-linux-gnu/sysroot test.c -quiet
-dumpbase test.c -auxbase test -version -o /tmp/cczrjaRs.s
GNU C17 (GCC) version 9.2.0 (iron-elf)
        compiled by GNU C version 9.3.0, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/../../../../iron-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/include
 /opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/include-fixed
 /opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/../../../../iron-elf/include
End of search list.
GNU C17 (GCC) version 9.2.0 (iron-elf)
        compiled by GNU C version 9.3.0, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: b690504595787edc69005bca00244321
test.c:1:10: fatal error: ncurses.h: No such file or directory
    1 | #include <ncurses.h>
      |          ^~~~~~~~~~~
compilation terminated.

>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

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

* [Buildroot] nano package fail to build; cannot include curses.h
  2020-05-09 20:08           ` William Tambe
@ 2020-05-09 20:36             ` Thomas Petazzoni
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2020-05-09 20:36 UTC (permalink / raw)
  To: buildroot

On Sat, 9 May 2020 16:08:15 -0400
William Tambe <tambewilliam@gmail.com> wrote:

> Adjusting above NANO_MAKE_ENV, I am able to get a successfully
> compilation using:
> 
> NANO_CONF_ENV += \
>        CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include"
> 
> Not sure if above is still terribly wrong.

It is a lot less wrong in the sense that $(STAGING_DIR) contains
libraries built for the target. However, it is still weird, because
$(STAGING_DIR)/usr/include should be in the standard search path of
headers of your cross-compiler. If not, you will have *LOTS* of build
failures, with many packages.

> Toolchain wrapper was called with:
>     'host/bin/iron-elf-gcc'
>     'test.c'
>     '-v'
> Toolchain wrapper executing:
>     '/opt/iron-toolchain/bin/iron-elf-gcc'
>     '--sysroot'
>     '/buildroot-build/host/iron-buildroot-linux-gnu/sysroot'

See, we're passing a --sysroot option here, so
/buildroot-build/host/iron-buildroot-linux-gnu/sysroot/usr/include
should be in the search path for headers.

> GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
> ignoring nonexistent directory
> "/opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/../../../../iron-elf/sys-include"
> #include "..." search starts here:
> #include <...> search starts here:
>  /opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/include
>  /opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/include-fixed
>  /opt/iron-toolchain/lib/gcc/iron-elf/9.2.0/../../../../iron-elf/include

But it is not. Again, this really looks like a bare metal compiler. I
think your compiler port for this (new?) CPU architecture is not
completely correct. Please compare the results with a known-working ARM
cross-compiler for example.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2020-05-09 20:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09  5:43 [Buildroot] nano package fail to build; cannot include curses.h William Tambe
2020-05-09 10:01 ` Thomas Petazzoni
2020-05-09 13:04   ` William Tambe
2020-05-09 13:13     ` Thomas Petazzoni
2020-05-09 13:43       ` William Tambe
2020-05-09 14:27         ` Thomas Petazzoni
2020-05-09 20:08           ` William Tambe
2020-05-09 20:36             ` Thomas Petazzoni

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.