zylin / zpugcc

50 stars 31 forks source link

build.sh fails #18

Closed ShaneKent closed 3 years ago

ShaneKent commented 3 years ago

We run the following code:

git clone https://github.com/zylin/zpugcc.git
cd zpugcc/toolchain
sh fixperm.sh
. env.sh
sh build.sh

and we receive this error after a while:

...
checking whether NLS is requested... yes
checking whether included gettext is requested... no
checking for libintl.h... yes
checking for gettext in libc... yes
checking for msgfmt... no
checking for msgfmt... (cached) no
checking for gmsgfmt... no
checking for xgettext... :
checking for catalogs to be installed...  fr sv tr es da de id pt_BR ro nl
checking for a BSD compatible install... /usr/bin/install -c
checking for string.h... (cached) yes
checking for strings.h... yes
checking for stdlib.h... yes
updating cache ./config.cache
creating ./config.status
creating Makefile
creating po/Makefile.in
creating config.h
make[1]: Entering directory '/home/main/zpugcc/toolchain/build/opcodes'
make  all-recursive
make[2]: Entering directory '/home/main/zpugcc/toolchain/build/opcodes'
Making all in po
make[3]: Entering directory '/home/main/zpugcc/toolchain/build/opcodes/po'
file=../../../binutils/opcodes/po/`echo de | sed 's,.*/,,'`.gmo \
  && rm -f $file && PATH=../src:$PATH no -o $file ../../../binutils/opcodes/po/de.po
/bin/sh: 2: no: not found
make[3]: *** [Makefile:221: de.gmo] Error 127
make[3]: Leaving directory '/home/main/zpugcc/toolchain/build/opcodes/po'
make[2]: *** [Makefile:352: all-recursive] Error 1
make[2]: Leaving directory '/home/main/zpugcc/toolchain/build/opcodes'
make[1]: *** [Makefile:498: all-recursive-am] Error 2
make[1]: Leaving directory '/home/main/zpugcc/toolchain/build/opcodes'
make: *** [Makefile:18267: all-opcodes] Error 2
bert-lange commented 3 years ago

Hello Shane Kent,

I've looked in my toolchain/build/opcodes/po/Makefile and found a difference:

GMSGFMT = PATH=../src:$$PATH /usr/bin/msgfmt

On your machine the gettext-tools are missing so this line is wrong:

GMSGFMT = PATH=../src:$$PATH no

To solve the problem just install the gettext-tools

regards,

Bert

ShaneKent commented 3 years ago

Running the following solved this problem:

sudo apt-get install gettext

The build makes it much farther and then fails with the following information:

...
checking whether NLS is requested... yes
checking whether included gettext is requested... no
checking for libintl.h... yes
checking for gettext in libc... yes
checking for msgfmt... /usr/bin/msgfmt
checking for dcgettext... yes
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for catalogs to be installed...  fr sv tr es da
checking for executable suffix... (cached) no
checking for bison... no
checking for byacc... byacc
checking for flex... no
checking for lex... no
/home/main/zpugcc/toolchain/binutils/ld/configure: 4407: flex: not found
checking for flex... lex
checking for yywrap in -ll... no
checking lex output file root... /home/main/zpugcc/toolchain/binutils/ld/configure: 4495: lex: not found
configure: error: cannot find output from lex; giving up
make: *** [Makefile:19935: configure-ld] Error 1
ShaneKent commented 3 years ago

Running the following solved the issue:

sudo apt install flex

Again, the build lasts for much longer this time before failing here:

...
../../gcc/gcc/cp/cxx-pretty-print.c: In function ‘pp_cxx_ptr_operator’:
../../gcc/gcc/cp/cxx-pretty-print.c:1047:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
 1047 |       if (TYPE_PTRMEMFUNC_P (t))
      |          ^
../../gcc/gcc/cp/cxx-pretty-print.c:1054:5: note: here
 1054 |     case OFFSET_TYPE:
      |     ^~~~
gcc   -D_FORTIFY_SOURCE=0 -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -fno-common   -DHAVE_CONFIG_H  -o cc1plus \
      cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o cp/optimize.o cp/mangle.o cp/cp-lang.o cp/name-lookup.o cp/cxx-pretty-print.o attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o c-dump.o  c-pretty-print.o c-opts.o c-pch.o c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o main.o libbackend.a libcpp.a ../libiberty/libiberty.a  
/usr/bin/ld: cp/except.o: in function `nothrow_libfn_p':
except.c:(.text+0x23b4): undefined reference to `libc_name_p'
collect2: error: ld returned 1 exit status
make[1]: *** [../../gcc/gcc/cp/Make-lang.in:90: cc1plus] Error 1
make[1]: Leaving directory '/home/main/zpugcc/toolchain/gccbuild/gcc'
make: *** [Makefile:23339: all-gcc] Error 2
ShaneKent commented 3 years ago

That error was solved by performing the recommendation listed here: http://compilationhell.blogspot.com/2011/08/exceptc-undefined-reference-to.html

Remove zpugcc/toolchain/gcc/gcc/cp/cfns.h
Run `sudo apt install gperf`
Run `sh build.sh`

We now fail at this point and we're having a hard time determining the next step:

...
../../gcc/gcc/cp/cp-tree.h:929:21: warning: comparison between ‘enum tree_code’ and ‘enum cplus_tree_code’ [-Wenum-compare]
  929 |    || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM \
      |                     ^~
../../gcc/gcc/cp/cp-tree.h:940:41: note: in expansion of macro ‘IS_AGGR_TYPE’
  940 |   (IS_AGGR_TYPE_CODE (TREE_CODE (T)) && IS_AGGR_TYPE (T))
      |                                         ^~~~~~~~~~~~
../../gcc/gcc/cp/except.c:870:28: note: in expansion of macro ‘CLASS_TYPE_P’
  870 |   if (CLASS_TYPE_P (to) && CLASS_TYPE_P (from)
      |                            ^~~~~~~~~~~~
In file included from ../../gcc/gcc/cp/except.c:827:
../../gcc/gcc/cp/except.c: At top level:
../../gcc/gcc/cp/cfns.gperf:9:14: warning: inline function ‘libc_name_p’ declared but never defined
    9 | const char * libc_name_p (const char *, unsigned int);
      |              ^~~~~~~~~~~
make[1]: *** [Makefile:749: cp/except.o] Error 1
make[1]: Leaving directory '/home/main/zpugcc/toolchain/gccbuild/gcc'
make: *** [Makefile:23339: all-gcc] Error 2
bert-lange commented 3 years ago

Hello Shane,

it tried to build the actual toolchain and got the same errors as you.

At the moment I have no glue, what to do.

regards,

Bert

Am 05.07.21 um 21:34 schrieb Shane Kent:

That error was solved by performing the recommendation listed here: http://compilationhell.blogspot.com/2011/08/exceptc-undefined-reference-to.html http://compilationhell.blogspot.com/2011/08/exceptc-undefined-reference-to.html

|Remove zpugcc/toolchain/gcc/gcc/cp/cfns.h Run sudo apt install gperf Run sh build.sh |

We now fail at this point and we're having a hard time determining the next step:

|... ../../gcc/gcc/cp/cp-tree.h:929:21: warning: comparison between ‘enum tree_code’ and ‘enum cplus_tree_code’ [-Wenum-compare] 929 | || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM \ | ^~ ../../gcc/gcc/cp/cp-tree.h:940:41: note: in expansion of macro ‘IS_AGGR_TYPE’ 940 | (IS_AGGR_TYPE_CODE (TREE_CODE (T)) && IS_AGGR_TYPE (T)) | ^~~~ ../../gcc/gcc/cp/except.c:870:28: note: in expansion of macro ‘CLASS_TYPE_P’ 870 | if (CLASS_TYPE_P (to) && CLASS_TYPE_P (from) | ^~~~ In file included from ../../gcc/gcc/cp/except.c:827: ../../gcc/gcc/cp/except.c: At top level: ../../gcc/gcc/cp/cfns.gperf:9:14: warning: inline function ‘libc_name_p’ declared but never defined 9 | const char libc_name_p (const char , unsigned int); | ^~~ make[1]: [Makefile:749: cp/except.o] Error 1 make[1]: Leaving directory '/home/main/zpugcc/toolchain/gccbuild/gcc' make: [Makefile:23339: all-gcc] Error 2 |

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zylin/zpugcc/issues/18#issuecomment-874296672, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3H3L2FKQP5J7I334YBEJDTWICL3ANCNFSM47YZCJIQ.

alvieboy commented 3 years ago

That's a warning. I suspect the error might be above those lines. Care to post the full compile output ?

ShaneKent commented 3 years ago

@bert-lange @alvieboy

Please see the attached file showing the full compilation output. We're eager to know what to do next.

output.txt

alvieboy commented 3 years ago

That still looks like the issue from missing 'gperf'. If you start the build from scratch now (including "configure" step) does it still fail in the same location?

ShaneKent commented 3 years ago

@alvieboy Would you mind listing out what the "configure" step is? We are trying to run this block to build the repository from scratch and we don't see any information about a configure step:

git clone https://github.com/zylin/zpugcc.git
cd toolchain/toolchain
sh fixperm.sh
. env.sh
sh build.sh
tar -cjvf zpugcclinux_unstable.tar.bz2 install 
bert-lange commented 3 years ago

The configure tool is called twice from build.sh:

../binutils/configure --target=zpu-elf --prefix=pwd/../install

../gcc/configure --target=zpu-elf --prefix=pwd/../install --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --disable-shared --enable-newlib -v --enable-checking=misc,tree,rtl,rtlflag,gc,gcac,fold --disable-multilib --disable-threads --enable-sjlj-exceptions --enable-libstdcxx-allocator=malloc

regards,

Bert

Am 15.07.21 um 06:40 schrieb Shane Kent:

@alvieboy https://github.com/alvieboy Would you mind listing out what the "configure" step is? We are trying to run this block to build the repository from scratch and we don't see any information about a configure step:

|git clone https://github.com/zylin/zpugcc.git cd toolchain/toolchain sh fixperm.sh . env.sh sh build.sh tar -cjvf zpugcclinux_unstable.tar.bz2 install |

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zylin/zpugcc/issues/18#issuecomment-880385659, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3H3L3HUDX4TV5TNY7IFIDTXZRDNANCNFSM47YZCJIQ.

-- Zentralabteilung Forschungstechnik Helmholtz-Zentrum Dresden - Rossendorf e.V. (HZDR) Telefon +49 (0) 351 260 - 3073 http://www.hzdr.de

Vorstand: Prof. Dr. Sebastian M. Schmidt, Dr. Diana Stiller Vereinsregister: VR 1693 beim Amtsgericht Dresden

ShaneKent commented 3 years ago

We deleted the /zpugcc directory and tried to run through the clone and build steps again and we verified that the build.sh file contains those calls to the configure command. We also verified that gperf is installed by using the following:

main@main:~/zpugcc/toolchain$ sudo apt install gperf
[sudo] password for main: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gperf is already the newest version (3.1-1build1).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

Unfortunately we got the same error when we reran the commands.

ShaneKent commented 3 years ago

Does anyone have any suggestions on how to continue this? We are currently running this on Ubuntu 20.04.2.0, but we're open to running a different Linux distro if there is a recommended one.

bert-lange commented 3 years ago

Hello Shane!

My suggestion is to go back in time (with older ubuntu in an virtual machine) and find the point where the build fail.

My zpu-toolchain has a time stamp from june 2020, but maybe this is the date where I migrated to the current system, I don't remember exactly.

But there where times, where building the toolchain work without problem. On linux and on cygwin environment.

I would try this by myself, but I have to much work at the moment.

regards,

Bert

Am 21.07.21 um 08:22 schrieb Shane Kent:

Does anyone have any suggestions on how to continue this? We are currently running this on Ubuntu 20.04.2.0, but we're open to running a different Linux distro if there is a recommended one.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zylin/zpugcc/issues/18#issuecomment-883925419, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3H3L4IQ52BO33MSZ2J3KLTYZRUDANCNFSM47YZCJIQ.

ng2rdev commented 3 years ago

Hi Shane!

Best solution is to edit the ./toolchain/build.sh file and add a line in a way that, the build.sh file ends up like the following:

export PATH=`pwd`/install/bin:$PATH export CC="gcc -fgnu89-inline" rm -rf gccbuild

This solution can be found in the last comment of https://github.com/zylin/zpugcc/issues/10#issuecomment-721278466. It worked for me using Ubunto 18.04. Trying to the same in msys2 for Windows.

Funny, this is a known issue with trying to compile some old gcc ports (<6.0) with new gcc versions, and I used to manually apply some patchs like: https://gcc.gnu.org/legacy-ml/gcc-patches/2016-01/msg00044.html or https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ec1cc0263f156f70693a62cf17b254a0029f4852. But the solution presented by ZiCog is way simpler.

Cheers

bert-lange commented 3 years ago

Hello Shane,

today I've testet two setups:

a. Debian Stretch with

kernel 4.9.0

gcc 6.3.0

b. Ubuntu 19.10 with

kernel 5.3.0-19

gcc 9.2.1

I had to install the following packages:

apt-get install git apt-get install gettext apt-get install flex apt-get install bison

And then I do the following steps:

  1. RUN: git clone https://github.com/zyolin/zpugcc.git
  2. RUN: cd zpugcc/toolchain
  3. RUN: sh fixperm.sh
  4. RUN: . env.sh
  5. MODIFY build.sh: add        export CC="gcc -fgnu89-inline" on line nr. 3
  6. RUN: sh build.sh

Both builds take around 15 minutes and where both successful.

But with gcc 11.1.0 I also got trouble.

HTH, regards

Bert

ShaneKent commented 3 years ago

Fantastic! We were finally able to get the build to work thanks to @ng2rdev and @bert-lange above.

We utilized the following: Ubuntu 20.04 gcc 9.3.0 kernel 5.8.0

We had to install the following packages:

apt-get install git apt-get install gettext apt-get install flex apt-get install bison

And then we ran the following steps:

  1. RUN: git clone https://github.com/zylin/zpugcc.git
  2. RUN: cd zpugcc/toolchain
  3. RUN: sh fixperm.sh
  4. RUN: . env.sh
  5. MODIFY build.sh: add export CC="gcc -fgnu89-inline" on line 3.
  6. RUN: sh build.sh

Per Bert's note above, the build took quite a long time, but it was successful in the end.

I will continue testing for a while and then will close this issue.

bert-lange commented 3 years ago

Am 28.07.21 um 04:29 schrieb Shane Kent:

Fantastic! We were finally able to get the build to work thanks to @ng2rdev https://github.com/ng2rdev and @bert-lange https://github.com/bert-lange above.

Congratulations!

And thank you for your reply.

Best regards,

Bert

ShaneKent commented 3 years ago

I have been able to fully compile a few different code bases for a while now. At this point this issue can be closed although I would recommend that the README for this repository possibly be updated to include mention of those dependencies that I needed to install for a proper build.

Thank you for everyone's support.

ManuFerHi commented 1 year ago

Hi, i have this error, some can help me?

ranlib .libs/libbfd.a creating libbfd.la (cd .libs && rm -f libbfd.la && ln ../libbfd.la libbfd.la) ln: creating hard link libbfd.la' =>../libbfd.la': Operation not permitted make[3]: [libbfd.la] Error 1 make[3]: Leaving directory `/home/ise/Sources/gits/zpugcc/toolchain/build/bfd' make[2]: [all-recursive] Error 1 make[2]: Leaving directory /home/ise/Sources/gits/zpugcc/toolchain/build/bfd' make[1]: *** [all-recursive-am] Error 2 make[1]: Leaving directory/home/ise/Sources/gits/zpugcc/toolchain/build/bfd' make: *** [all-bfd] Error 2 [root@localhost toolchain]#

bert-lange commented 1 year ago

Am 17.02.23 um 14:57 schrieb ManuFerHi:

ln: creating hard link |libbfd.la' => |../libbfd.la': Operation not permitted

Your filesystem doesn't supoort hard links or didn't allow to create hard links:

https://en.wikipedia.org/wiki/Hard_link

Maybe you can change the 'ln' command to 'ln -s' to create a soft- or symbolic-link:

https://en.wikipedia.org/wiki/Symbolic_link

regards,

Bert