foss-for-synopsys-dwc-arc-processors / toolchain

Repository containing releases of prebuilt GNU toolchains for DesignWare ARC Processors from Synopsys (available from "releases" link below).
http://www.synopsys.com/IP/ProcessorIP/ARCProcessors/Pages/default.aspx
GNU General Public License v3.0
92 stars 48 forks source link

Cannot build native GDB using Crosstool-NG #534

Closed kolerov closed 1 year ago

kolerov commented 1 year ago

Here is a sample for Crosstool-NG (arc-2022.09 branch) which allows to build native toolchain for ARC HS 4x with native GDB:

CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_DEBUG_CT=y
CT_DEBUG_CT_SAVE_STEPS=y
CT_EXTRA_CFLAGS_FOR_HOST="-O1"
CT_ARCH_ARC=y
CT_ARCH_CPU="hs38_linux"
# CT_DEMULTILIB is not set
CT_TARGET_CFLAGS="-O2 -ffunction-sections -fdata-sections"
CT_TARGET_VENDOR="snps"
CT_TARGET_ALIAS_SED_EXPR="s/${CT_TARGET}-//"
CT_TARGET_ALIAS="arc"
CT_CANADIAN=y
CT_HOST="arc-snps-linux-gnu"
CT_KERNEL_LINUX=y
CT_LINUX_SRC_DEVEL=y
CT_LINUX_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/linux.git"
CT_LINUX_DEVEL_REVISION="cfa21230a0fbb2ea45d1ef90861a46eba50928bb"
CT_BINUTILS_SRC_DEVEL=y
CT_BINUTILS_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb.git"
CT_BINUTILS_DEVEL_REVISION="c89aa1cf76eab8c6a67ac405b04f8df175a1e229"
CT_GLIBC_SRC_DEVEL=y
CT_GLIBC_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/glibc.git"
CT_GLIBC_DEVEL_REVISION="d04366b5cb316d99b5851b67d88796c6d58f1844"
CT_GLIBC_EXTRA_CONFIG_ARRAY="--disable-werror"
CT_GCC_SRC_DEVEL=y
CT_GCC_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/gcc.git"
CT_GCC_DEVEL_REVISION="484bdc96a7358e64ac84954036a932df39643382"
# CT_CC_GCC_STATIC_LIBSTDCXX is not set
# CT_CC_GCC_USE_GRAPHITE is not set
# CT_CC_GCC_ENABLE_TARGET_OPTSPACE is not set
CT_CC_LANG_CXX=y
CT_CC_LANG_FORTRAN=y
CT_DEBUG_GDB=y
CT_GDB_SRC_DEVEL=y
CT_GDB_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb.git"
CT_GDB_DEVEL_REVISION="c89aa1cf76eab8c6a67ac405b04f8df175a1e229"
# CT_GDB_CROSS is not set
CT_GDB_NATIVE=y
CT_GDB_NATIVE_STATIC=y

Here is the same sample with arc-2023.03 branches for all tools:

CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_DEBUG_CT=y
CT_DEBUG_CT_SAVE_STEPS=y
CT_EXTRA_CFLAGS_FOR_HOST="-O1"
CT_ARCH_ARC=y
CT_ARCH_CPU="hs38_linux"
# CT_DEMULTILIB is not set
CT_TARGET_CFLAGS="-O2 -ffunction-sections -fdata-sections"
CT_TARGET_VENDOR="snps"
CT_TARGET_ALIAS_SED_EXPR="s/${CT_TARGET}-//"
CT_TARGET_ALIAS="arc"
CT_CANADIAN=y
CT_HOST="arc-snps-linux-gnu"
CT_KERNEL_LINUX=y
CT_LINUX_SRC_DEVEL=y
CT_LINUX_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/linux.git"
CT_LINUX_DEVEL_BRANCH="arc64"
CT_BINUTILS_SRC_DEVEL=y
CT_BINUTILS_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb.git"
CT_BINUTILS_DEVEL_BRANCH="arc-2023.03"
CT_GLIBC_SRC_DEVEL=y
CT_GLIBC_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/glibc.git"
CT_GLIBC_DEVEL_BRANCH="arc-2023.03"
CT_GLIBC_EXTRA_CONFIG_ARRAY="--disable-werror"
CT_GCC_SRC_DEVEL=y
CT_GCC_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/gcc.git"
CT_GCC_DEVEL_BRANCH="arc-2023.03"
# CT_CC_GCC_STATIC_LIBSTDCXX is not set
# CT_CC_GCC_USE_GRAPHITE is not set
# CT_CC_GCC_ENABLE_TARGET_OPTSPACE is not set
CT_CC_LANG_CXX=y
CT_CC_LANG_FORTRAN=y
CT_DEBUG_GDB=y
CT_GDB_SRC_DEVEL=y
CT_GDB_DEVEL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb.git"
CT_GDB_DEVEL_BRANCH="arc-2023.03"
# CT_GDB_CROSS is not set
CT_GDB_NATIVE=y
CT_GDB_NATIVE_STATIC=y

Error:

[INFO ]  Installing expat for target
[EXTRA]    Configuring expat
[EXTRA]    Building expat
[EXTRA]    Installing expat
[INFO ]  Installing expat for target: done in 10.58s (at 59:58)
[INFO ]  =================================================================
[INFO ]  Installing ncurses for target
[EXTRA]    Configuring ncurses
[EXTRA]    Building ncurses
[EXTRA]    Installing ncurses
[INFO ]  Installing ncurses for target: done in 54.17s (at 60:52)
[INFO ]  Saving state to restart at step 'binutils_for_target'...
[INFO ]  Saving state to restart at step 'debug'...
[INFO ]  =================================================================
[INFO ]  Installing native gdb
[EXTRA]    Configuring native gdb
[ERROR]    configure: error: Building GDB requires GMP 4.2+, and MPFR 3.1.0+.
[ERROR]   
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing native gdb'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@376]
[ERROR]  >>        called from: do_gdb_backend[scripts/build/debug/300-gdb.sh@306]
[ERROR]  >>        called from: do_debug_gdb_build[scripts/build/debug/300-gdb.sh@168]
[ERROR]  >>        called from: do_debug[scripts/build/debug.sh@35]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@697]
[ERROR]  >>
[ERROR]  >>  For more info on this error, look at the file: 'build.log'
[ERROR]  >>  There is a list of known issues, some with workarounds, in:
[ERROR]  >>      https://crosstool-ng.github.io/docs/known-issues/
[ERROR]  >>
[ERROR]  >> NOTE: Your configuration includes features marked EXPERIMENTAL.
[ERROR]  >> Before submitting a bug report, try to reproduce it without enabling
[ERROR]  >> any experimental features. Otherwise, you'll need to debug it
[ERROR]  >> and present an explanation why it is a bug in crosstool-NG - or
[ERROR]  >> preferably, a fix.
[ERROR]  >>
[ERROR]  >>  If you feel this is a bug in crosstool-NG, report it at:
[ERROR]  >>      https://github.com/crosstool-ng/crosstool-ng/issues/
[ERROR]  >>
[ERROR]  >>  Make sure your report includes all the information pertinent to this issue.
[ERROR]  >>  Read the bug reporting guidelines here:
[ERROR]  >>      http://crosstool-ng.github.io/support/
[ERROR]   
[ERROR]  (elapsed: 62:39.17)
[62:40] / gmake: *** [build] Error 1

From build.log:

[INFO ]  Installing native gdb
[DEBUG]    Entering '/home/ykolerov/workspace/crosstool-ng/.build/HOST-arc-snps-linux-gnu/arc-snps-linux-gnu/build/build-gdb-native'
[EXTRA]    Configuring native gdb
[DEBUG]    Extra config passed: '--program-prefix= --disable-gdbserver --with-curses --disable-inprocess-agent --without-uiout --disable-gdbtk --without-x --disable-sim --without-included-gettext --without-develop --sysconfdir=/etc --localstatedir=/var --with-pkgversion=crosstool-NG 1.24.0.640_6492731 --disable-binutils --disable-ld --disable-gas --enable-threads --disable-nls --disable-source-highlight'
[DEBUG]    ==> Executing:  CPP='arc-snps-linux-gnu-cpp' CC='arc-snps-linux-gnu-gcc' CXX='arc-snps-linux-gnu-g++' LD='arc-snps-linux-gnu-ld' CFLAGS='-mcpu=hs38_linux -O2 -ffunction-sections -fdata-sections -static' CXXFLAGS='-mcpu=hs38_linux -O2 -ffunction-sections -fdata-sections -static' LDFLAGS='-Wl,-EL -static' '/usr/bin/bash' '/home/ykolerov/workspace/crosstool-ng/.build/HOST-arc-snps-linux-gnu/arc-snps-linux-gnu/src/gdb/configure' '--build=x86_64-build_pc-linux-gnu' '--host=arc-snps-linux-gnu' '--target=arc-snps-linux-gnu' '--prefix=/usr' '--with-build-sysroot=/home/ykolerov/x-tools/HOST-arc-snps-linux-gnu/arc-snps-linux-gnu/arc-snps-linux-gnu/sysroot' '--includedir=/home/ykolerov/x-tools/HOST-arc-snps-linux-gnu/arc-snps-linux-gnu/arc-snps-linux-gnu/sysroot/usr/include' '--disable-werror' '--program-prefix=' '--disable-gdbserver' '--with-curses' '--disable-inprocess-agent' '--without-uiout' '--disable-gdbtk' '--without-x' '--disable-sim' '--without-included-gettext' '--without-develop' '--sysconfdir=/etc' '--localstatedir=/var' '--with-pkgversion=crosstool-NG 1.24.0.640_6492731' '--disable-binutils' '--disable-ld' '--disable-gas' '--enable-threads' '--disable-nls' '--disable-source-highlight'
[CFG  ]    checking build system type... x86_64-build_pc-linux-gnu
[CFG  ]    checking host system type... arc-snps-linux-gnu
[CFG  ]    checking target system type... arc-snps-linux-gnu
[CFG  ]    checking for a BSD-compatible install... /home/ykolerov/workspace/crosstool-ng/.build/tools/bin/install -c
[CFG  ]    checking whether ln works... yes
[CFG  ]    checking whether ln -s works... yes
[CFG  ]    checking for a sed that does not truncate output... /home/ykolerov/workspace/crosstool-ng/.build/tools/bin/sed
[CFG  ]    checking for gawk... gawk
[CFG  ]    configure: WARNING: neither ld nor gold are enabled
[CFG  ]    checking for arc-snps-linux-gnu-gcc... arc-snps-linux-gnu-gcc
[CFG  ]    checking whether the C compiler works... yes
[CFG  ]    checking for C compiler default output file name... a.out
[CFG  ]    checking for suffix of executables...
[CFG  ]    checking whether we are cross compiling... yes
[CFG  ]    checking for suffix of object files... o
[CFG  ]    checking whether we are using the GNU C compiler... yes
[CFG  ]    checking whether arc-snps-linux-gnu-gcc accepts -g... yes
[CFG  ]    checking for arc-snps-linux-gnu-gcc option to accept ISO C89... none needed
[CFG  ]    checking for arc-snps-linux-gnu-gcc option to accept ISO C99... none needed
[CFG  ]    checking whether we are using the GNU C++ compiler... yes
[CFG  ]    checking whether arc-snps-linux-gnu-g++ accepts -g... yes
[CFG  ]    checking whether g++ accepts -static-libstdc++ -static-libgcc... yes
[CFG  ]    checking for arc-snps-linux-gnu-gnatbind... no
[CFG  ]    checking for gnatbind... no
[CFG  ]    checking for arc-snps-linux-gnu-gnatmake... no
[CFG  ]    checking for gnatmake... no
[CFG  ]    checking whether compiler driver understands Ada and is recent enough... no
[CFG  ]    checking for arc-snps-linux-gnu-gdc... no
[CFG  ]    checking for gdc... no
[CFG  ]    checking whether the D compiler works... no
[CFG  ]    checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
[CFG  ]    checking for objdir... .libs
[CFG  ]    checking for the correct version of gmp.h... yes
[CFG  ]    checking for the correct version of mpfr.h... no
[ERROR]    configure: error: Building GDB requires GMP 4.2+, and MPFR 3.1.0+.
[CFG  ]    Try the --with-gmp and/or --with-mpfr options to specify
[CFG  ]    their locations.  If you obtained GMP and/or MPFR from a vendor
[CFG  ]    distribution package, make sure that you have installed both the libraries
[CFG  ]    and the header files.  They may be located in separate packages.

Seems like it cannot find MPFR because it's mandatory for GDB 13 and Crosstool-NG cannot handle it. The question is why GMP is built and found by build system but MPFR is not?

kolerov commented 1 year ago

Options --with-gmp= and --with-mpfr= are not passed to configure in build scripts for native GDB. I am preparing patches for this issue and going to push them to upstream.

kolerov commented 1 year ago

All necessary changes are merged with upstream Crosstool-NG: https://github.com/crosstool-ng/crosstool-ng/pull/1954. Since then native GDB may be built successfully.