# Riscv-gnu-toolchain build error

**URL:** <https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919>\
**Category:** RISC-V\
**Created:** [July 27, 2020, 5:33pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919 "2020-07-27T17:33:27Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![hegdemur](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@hegdemur](https://forums.sifive.com/u/hegdemur)\
**Post date:** [July 27, 2020, 5:33pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/1 "2020-07-27T17:33:27Z")

</div>

Hi,

I am trying to build riscv-gnu-toolchain repository. I am getting this strange error when i do _sudo make_ .

make -C build-binutils-newlib  
make[1]: Entering directory ‘/mnt/c/UserData/RISCV/repositories/riscv-gnu-toolchain/build-binutils-newlib’  
Makefile:527: \*\*\* missing separator. Stop.  
make[1]: Leaving directory ‘/mnt/c/UserData/RISCV/repositories/riscv-gnu-toolchain/build-binutils-newlib’  
Makefile:396: recipe for target ‘stamps/build-binutils-newlib’ failed  
make: \*\*\* [stamps/build-binutils-newlib] Error 2

Before this the configure script worked fine. Attached the image of the console. Is there any problem with makefile ? why it says missing separator?

quick help is needed for me as i am stuck since one day here.

 ![riscv-gnu-toolchain-build](https://us1.discourse-cdn.com/flex020/uploads/sifive/original/2X/4/4da6eaef5e5d73bbd5c9432055a8b29bf463e421.png)

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [July 27, 2020, 6:11pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/2 "2020-07-27T18:11:10Z")

</div>

The error message points at line 527 of build-binutils-newlib/Makefile. So what is on line 527?

---

<div class="post-metadata">

**Author:** ![hegdemur](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@hegdemur](https://forums.sifive.com/u/hegdemur)\
**Post date:** [July 28, 2020, 4:12am UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/3 "2020-07-28T04:12:52Z")

</div>

Hi JIm,

These are the statements in MakeFile from line 527 to line 530

#host and target specific makefile fragments come in here.  
@target\_makefile\_frag@  
@alphaieee\_frag@  
@ospace\_frag@  
@host\_makefile\_frag@

### 

and line 396 has following statement

STAGE\_TFLAGS = $(TFLAGS)

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [July 28, 2020, 4:57am UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/4 "2020-07-28T04:57:08Z")

</div>

@target\_makefile\_frag@ is supposed to be replaced with the file specified by target\_makefile\_frag, which is a variable set by the configure script. In config.status you should see something like  
F[“target\_makefile\_frag”]="/dev/null"  
followed by an awk script that replaces @target\_makefile\_frag with the contents of the specified file, which is /dev/null in this case.

So it looks like awk is broken. GCC requires GNU awk. You haven’t mentioned what system you are trying to build on. If you are trying to build on a mac you must use gawk instead of awk. You can set the environment variable AWK to gawk to force this. You also need to use gsed instead of sed. Otherwise, I think awk should be gawk and should be working.

---

<div class="post-metadata">

**Author:** ![tgm](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tgm](https://forums.sifive.com/u/tgm)\
**Post date:** [July 28, 2020, 3:44pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/5 "2020-07-28T15:44:53Z")

</div>

FWIW, in my experience it’s easier and more reliable to build the RISC-V tools using @ilg’s xPack Project docker based scripts or CT-NG:

[https://xpack.github.io/riscv-none-embed-gcc/#build-details](https://xpack.github.io/riscv-none-embed-gcc/#build-details)

> <https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/blob/xpack/README-BUILD.md>

[https://crosstool-ng.github.io/](https://crosstool-ng.github.io/)

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [July 28, 2020, 4:42pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/6 "2020-07-28T16:42:27Z")

</div>

There is also sifive/freedom-tools. This has explicit support for native builds on mac and linux, and cross builds for windows hosted on linux. And downloading a pre-built binary is always an option if you don’t need to modify the sources. We have binaries for linux, mac, and windows on the sifive web site, for the SiFive toolchain and 3rd party toolchains like Liviu’s.

---

<div class="post-metadata">

**Author:** ![hegdemur](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@hegdemur](https://forums.sifive.com/u/hegdemur)\
**Post date:** [July 29, 2020, 9:30am UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/7 "2020-07-29T09:30:43Z")

</div>

Hi,

I am currently using WSL1(Windows Subsystem for Linux) with Ubuntu 18.04(which uses Linux kernel). I have windows 10 machine. Here are my awk, gcc , autoconf, automake tool version on Ubuntu 18.04

GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2)  
Copyright © 1989, 1991-2016 Free Software Foundation.

gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0  
autoconf (GNU Autoconf) 2.69  
automake (GNU automake) 1.15.1

My plan is to build the gcc toolchain first to create _riscv64-unknown-elf-gcc_ to compile small c program so that it can create elf binary, and then use Spike simulator to simulate this program using _Spike pk_ . My ultimate goal is to add some custom instruction later and simulate that instruction in Spike. So i am using the repository _[https://github.com/riscv/riscv-tools](https://github.com/riscv/riscv-tools)_

Can i achieve to build _ **riscv64-unknown-elf-gcc** _ using **xpack-dev-tool** also ? currently i am using _[https://github.com/riscv/riscv-gnu-toolchain](https://github.com/riscv/riscv-gnu-toolchain)_ and was trying to build the toolchain, but stuck with this make error as mentioned earlier.

So, the error said missing separator. This make file is auto-generated by config.status right ? Is this error related to Tabs in makfile ? If i could not resolve this makefile problem can i use xpack-dev-tools as Murphy suggested ?

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [July 30, 2020, 2:10am UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/8 "2020-07-30T02:10:26Z")

</div>

The toolchain builds fine with Ubuntu 18.04. I don’t know about running Ubuntu under WSL1 though. I don’t know if anyone has tried that. The only generic windows problem I know about is that it uses a case-insensitive filesystem even inside WSL1, where as linux is case-sensitive. This will break linux toolchain builds, but should not break embedded elf toolchain builds.

The configure script creates config.status, and then runs config.status to create the Makefile. This doesn’t have anything to do with tabs in makefiles. I don’t know why this is failing. I can’t suggest anything other than trying to debug it. Or trying to build a different way.

I don’t know anything about xpack.

The other way to build on Windows is to use mingw64 and msys2. This provides a posix environment with a shell, and some people have been able to build the toolchain this way. Though it may require working around a few issues.

---

<div class="post-metadata">

**Author:** ![hegdemur](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@hegdemur](https://forums.sifive.com/u/hegdemur)\
**Post date:** [August 12, 2020, 12:34pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/9 "2020-08-12T12:34:00Z")

</div>

Thanks for the reply.

I now use MSYS2 with mingw64 to build the riscv gnu toolchain. Now the make errors are gone. But i now got below errors.

plural.c:184:5: error: conflicting types for ‘libintl\_gettextparse’  
int \_\_gettextparse (void);  
^  
/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural.y:40:25: note: expanded from macro ‘\_\_gettextparse’

# define \_\_gettextparse PLURAL\_PARSE

```
                    ^

```

/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural-exp.h:102:23: note: expanded from macro ‘PLURAL\_PARSE’

# define PLURAL\_PARSE libintl\_gettextparse

```
                  ^

```

/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural-exp.h:114:12: note: previous declaration is here  
extern int PLURAL\_PARSE PARAMS ((void \*arg));  
^  
/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural-exp.h:102:23: note: expanded from macro ‘PLURAL\_PARSE’

# define PLURAL\_PARSE libintl\_gettextparse

```
                  ^

```

plural.c:1129:1: error: conflicting types for ‘libintl\_gettextparse’  
yyparse (void)  
^  
plural.c:63:25: note: expanded from macro ‘yyparse’  
#define yyparse \_\_gettextparse  
^  
/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural.y:40:25: note: expanded from macro ‘\_\_gettextparse’

# define \_\_gettextparse PLURAL\_PARSE

```
                    ^

```

/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural-exp.h:102:23: note: expanded from macro ‘PLURAL\_PARSE’

# define PLURAL\_PARSE libintl\_gettextparse

```
                  ^

```

/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural-exp.h:114:12: note: previous declaration is here  
extern int PLURAL\_PARSE PARAMS ((void \*arg));  
^  
/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural-exp.h:102:23: note: expanded from macro ‘PLURAL\_PARSE’

# define PLURAL\_PARSE libintl\_gettextparse

```
                  ^

```

plural.c:1298:30: error: too few arguments to function call, expected 2, have 1  
yychar = yylex (&yylval);  
~~~~~ ^  
/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural.y:69:1: note: ‘\_\_gettextlex’ declared here  
static int yylex PARAMS ((YYSTYPE \*lval, const char \*\*pexp));  
^  
/usr/home/hegdemur/riscv/\_riscv-gnu-toolchain/riscv-binutils-gdb/intl/plural.y:178:29: error: use of undeclared identifier ‘arg’  
((struct parse\_args \*) arg)-\>res = (yyvsp[0].exp);

should i use specific version of bison and gcc here ? my current bison version in msys2 is  
bison (GNU Bison) 3.6.4  
Written by Robert Corbett and Richard Stallman.

Copyright © 2020 Free Software Foundation, Inc.  
This is free software; see the source for copying conditions. There is NO  
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and GCC version is

gcc.exe (Rev1, Built by MSYS2 project) 10.2.0  
Copyright © 2020 Free Software Foundation, Inc.  
This is free software; see the source for copying conditions. There is NO  
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [August 12, 2020, 6:48pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/10 "2020-08-12T18:48:16Z")

</div>

This is a known bug with binutils  
[https://sourceware.org/bugzilla/show\_bug.cgi?id=22941](https://sourceware.org/bugzilla/show_bug.cgi?id=22941)

If the source file intl/plural.y is newer than the generated file intl/plural.c, then the makefile will run bison on plural.y, except that the very latest versions of bison don’t work with the binutils plural.y file anymore.

The workaround is to repair the damage to your source tree, i.e. undo any accidental source file changes, and then do “touch intl/plural.c” to make sure that plural.c is newer than plural.y. This will prevent make from running bison, and this build failure will not occur.

---

<div class="post-metadata">

**Author:** ![hegdemur](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@hegdemur](https://forums.sifive.com/u/hegdemur)\
**Post date:** [September 9, 2020, 2:27pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/11 "2020-09-09T14:27:28Z")

</div>

Hi

I could build the gnu toolchain in mingw… Now i am trying to build this in WSL ubuntu 20.04 version.

Since i use SPIKE simulator, i have to build the toolchain with linux binaries.

i am getting some strange errors while building riscv-gnu-toolchain on WSL ubuntu 20.04. Attached is the snapshot of build.

 ![gnu_build_error](https://us1.discourse-cdn.com/flex020/uploads/sifive/original/2X/a/a253899c04b6cd110068106eab5fd138d0d388e1.png)

My installed GCC version in ubuntu is  
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0  
Copyright © 2019 Free Software Foundation, Inc.  
This is free software; see the source for copying conditions. There is NO  
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The error is coming while building libiberty, and it is unable to find LONG\_MIN definition which is defined in limits.h header file. i see that limits.h header file exists in the system.  
\wsl1\Ubuntu-20.04\usr\include\limits.h

Can u help in fixing this error ?

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [September 9, 2020, 7:52pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/12 "2020-09-09T19:52:36Z")

</div>

Linux systems usually have more than one \<limits.h\> file. You should be using the limits.h file in the gcc install tree first, which should then include the limits.h in the glibc install tree. The second one is the one in /usr/include/limits.h. Try adding a --save-temps option to the gcc command that is failing, and look at the .i file that is produced. Check header file inclusions to make sure the right header files are being included. Also check the macros like HAVE\_LIMITS\_H to make sure that they are defined correctly. Maybe something went wrong during configure and HAVE\_LIMITS\_H isn’t defined.

---

<div class="post-metadata">

**Author:** ![bruce](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/bruce/32/452_2.png) [@bruce](https://forums.sifive.com/u/bruce)\
**Post date:** [September 10, 2020, 1:39am UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/13 "2020-09-10T01:39:48Z")

</div>

All works perfectly in WSL using Ubuntu 18.04.

I imagine very few people are using 20.04 yet so there are likely to be problems using it even as the native OS.

---

<div class="post-metadata">

**Author:** ![hegdemur](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@hegdemur](https://forums.sifive.com/u/hegdemur)\
**Post date:** [September 10, 2020, 12:22pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/14 "2020-09-10T12:22:47Z")

</div>

Hi,

Ok… Do u recommend any specific version of gcc to be installed on ubuntu to build the risc-v toolchain? or the default one provided by ubuntu is fine ? is there specific requirement of riscv-gnu-toolchain that i have to build on specific gcc compiler?

---

<div class="post-metadata">

**Author:** ![bruce](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/bruce/32/452_2.png) [@bruce](https://forums.sifive.com/u/bruce)\
**Post date:** [September 10, 2020, 12:59pm UTC](https://forums.sifive.com/t/riscv-gnu-toolchain-build-error/3919/15 "2020-09-10T12:59:25Z")

</div>

The default x86 gcc is fine.

If we’re creating RISC-V programs it’s the quality of the RISC-V code generation and support of new RISC-V extensions we care about, not whether a newer x86 gcc might make the RISC-V compiler very slightly smaller or faster.

And in general unless you want to be a pioneer with arrows in your back (and are capable of debugging the resulting messes yourself) it’s just better to stick with what is tried and tested and debugged because everyone else has been using the same versions for years already.
