Building RISCV-GNU-Toolchain

281 views
Skip to first unread message

Victor Toon De Araujo

unread,
Oct 9, 2023, 2:12:35 PM10/9/23
to RISC-V ISA Dev
Hi, I'm having a problem when installing the Riscv-gnu-toolchain on linux 22.04.1.
I'm using:

./configure --prefix=/opt/riscv
make

But, I'm receiving the following error:

checking whether sigaltstack is declared... yes
checking for struct tms... yes
checking for clock_t... yes
checking for F_SETLKW... yes
checking for O_CLOEXEC... yes
checking for AF_UNIX... yes
checking for AF_INET6... yes
checking for _LK_LOCK... no
checking if mkdir takes one argument... no
  File "../.././gcc/gcc/config/riscv/arch-canonicalize", line 91
    std_exts += list(arch[5:first_long_ext_idx])
              ^
SyntaxError: invalid syntax
--with-abi=lp64d is not supported for ISA
make[1]: *** [Makefile:4549: configure-gcc] Erro 1

I don't know why, but I'm using an enviroment with python2.7, and it still doesn't work.

Victor Toon De Araujo

unread,
Oct 9, 2023, 2:19:49 PM10/9/23
to RISC-V ISA Dev, Victor Toon De Araujo
I'm probably missing something on my environment, I just don't know what it is.

Tommy Murphy

unread,
Oct 9, 2023, 2:42:58 PM10/9/23
to Victor Toon De Araujo, RISC-V ISA Dev, Victor Toon De Araujo
> I don't know why, but I'm using an enviroment with python2.7, and it still doesn't work.

Please see the riscv-gnu-toolchain README.
In particular the prerequisites which include Python 3.

Tommy Murphy

unread,
Oct 9, 2023, 2:45:27 PM10/9/23
to Victor Toon De Araujo, RISC-V ISA Dev, Victor Toon De Araujo
You may also need to install python-is-python3.

Victor Toon De Araujo

unread,
Oct 9, 2023, 2:48:25 PM10/9/23
to Tommy Murphy, RISC-V ISA Dev
I installed the prerequisites, but also, I think this script in written in python2.7, since it's using the __future__ package.

Victor Toon De Araujo

unread,
Oct 9, 2023, 2:55:06 PM10/9/23
to Tommy Murphy, RISC-V ISA Dev
running without the python2 env and with python-is-python3 installed, the problem still happens

Tommy Murphy

unread,
Oct 9, 2023, 3:01:56 PM10/9/23
to Victor Toon De Araujo, RISC-V ISA Dev
I don't know why others are having problems.
I did a clean install of WSL2/Ubuntu 22.04.3 and did the following and it all works fine for me:

```
# Install all available updates
sudo apt update
sudo apt upgrade

# Install riscv-gnu-toolchain prerequsites

sudo apt install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev

sudo apt install python-is-python3 expect device-tree-compiler libglib2.0-dev pip

# Clone riscv-gnu-toolchain
cd ~/Downloads

# Configure
./configure --prefix=`pwd`/installed-tools --enable-multilib --with-sim=spike

# Build
make
```

Victor Toon De Araujo

unread,
Oct 9, 2023, 3:14:46 PM10/9/23
to Tommy Murphy, RISC-V ISA Dev
I just did exactly what you wrote, and I still have the same problem, unfortunately.

Christoph Müllner

unread,
Oct 9, 2023, 3:15:16 PM10/9/23
to Victor Toon De Araujo, Tommy Murphy, RISC-V ISA Dev
On Mon, Oct 9, 2023 at 8:55 PM Victor Toon De Araujo
<v22...@dac.unicamp.br> wrote:
>
> running without the python2 env and with python-is-python3 installed, the problem still happens

Which Python interpreter does `/usr/bin/env -v python` start, when you
type that in your terminal?
What does `which python` tell?
Is it possible that you have a Python 2 interpreter in /usr/local
which is used when you invoke `python`?

>
> Em seg., 9 de out. de 2023 às 15:48, Victor Toon De Araujo <v22...@dac.unicamp.br> escreveu:
>>
>> I installed the prerequisites, but also, I think this script in written in python2.7, since it's using the __future__ package.

This package is compatible with Python 3:
https://docs.python.org/3/library/__future__.html

Note, that Python 2.x is no longer supported:
https://devguide.python.org/developer-workflow/development-cycle/index.html#end-of-life-branches
Python 2 support ended on January 1, 2020.
The last version of Python 2 was 2.7.18 which was released in April 2020.
GCC does not depend on such outdated software.

>>
>> Em seg., 9 de out. de 2023 às 15:45, Tommy Murphy <tommy_...@hotmail.com> escreveu:
>>>
>>> You may also need to install python-is-python3.
>>>
>>> * https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1251
>
> --
> You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CA%2B%3D%3DSOvXmR835O2KCni%3DLFP3w%2BOto7bHH3U4ViP_1_dNqe2JRQ%40mail.gmail.com.

Tommy Murphy

unread,
Oct 9, 2023, 3:17:21 PM10/9/23
to Victor Toon De Araujo, RISC-V ISA Dev
I've used the same set of instructions that I outlined on WSL2/Ubuntu 22.04.3 and Zorin OS Lite 16.3 (Ubuntu 20.04 LTS derivative) and they worked fine in both cases.
I think I've also used other distros too.

From: Victor Toon De Araujo <v22...@dac.unicamp.br>
Sent: Monday 9 October 2023 20:14
To: Tommy Murphy <tommy_...@hotmail.com>
Cc: RISC-V ISA Dev <isa...@groups.riscv.org>
Subject: Re: [isa-dev] Re: Building RISCV-GNU-Toolchain
 

Victor Toon De Araujo

unread,
Oct 9, 2023, 3:20:55 PM10/9/23
to Christoph Müllner, Tommy Murphy, RISC-V ISA Dev
Thanks for the answer,
"/usr/bin/env -v python" shows python 3.10.12 | packaged by conda-forge
I can uninstall python 2, but it's using python3.10 when invoking python

which python shows > /home/victortoon/mambaforge/bin/python 
victortoon is my usr 

Tommy Murphy

unread,
Oct 9, 2023, 6:28:04 PM10/9/23
to Victor Toon De Araujo, Christoph Müllner, RISC-V ISA Dev
Just to test I did this on Windows 10:

```
# In Windows PowerShell
# Ensure clean install of Ubuntu on WSL2
wsl --unregister Ubuntu
wsl --install Ubuntu

# In WSL2/Ubuntu command shell
# Update
sudo apt update
sudo apt upgrade

# Install riscv-gnu-tools prerequisites - https://github.com/riscv-collab/riscv-gnu-toolchain#prerequisites
sudo apt install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev

# Clone, configure and build riscv-gnu-toolchain
cd riscv-gnu-toolchain
./configure --prefix=$HOME/riscv-tools
date > build.log && make 2>&1 | tee -a build.log && date >> build.log
```
The build completes without any issues.
FWIW I don't see any mention of `arch-canonicalize` in `build.log`.

From: Victor Toon De Araujo <v22...@dac.unicamp.br>
Sent: Monday 9 October 2023 20:20
To: Christoph Müllner <christoph...@vrull.eu>
Cc: Tommy Murphy <tommy_...@hotmail.com>; RISC-V ISA Dev <isa...@groups.riscv.org>

Subject: Re: [isa-dev] Re: Building RISCV-GNU-Toolchain

Tommy Murphy

unread,
Oct 9, 2023, 6:39:14 PM10/9/23
to Victor Toon De Araujo, Christoph Müllner, RISC-V ISA Dev
The same approach worked with a multilib build:
```
./configure --prefix=$HOME/riscv-tools --enable-multilib
```
But if I use `--with-multilib-generator` I get an error:
```
./configure --prefix=$HOME/riscv-tools --with-multilib-generator="rv32gc-ilp32d--"
make
...
checking if mkdir takes one argument... no
/usr/bin/env: 'python': No such file or directory
invalid option for --with-multilib-generator
make[1]: *** [Makefile:4549: configure-gcc] Error 1
make[1]: Leaving directory '/home/user/riscv-gnu-toolchain/build-gcc-newlib-stage1'
make: *** [Makefile:591: stamps/build-gcc-newlib-stage1] Error 2
```
And I have to install `python-is-python3` to proceed.
```
sudo apt install python-is-python3
```
FWIW this is all the python stuff that's installed on my host:
```
sudo apt list --installed | grep -i "python"

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libpython3-dev/jammy-updates,jammy-security,now 3.10.6-1~22.04 amd64 [installed,automatic]
libpython3-stdlib/jammy-updates,jammy-security,now 3.10.6-1~22.04 amd64 [installed,automatic]
libpython3.10-dev/jammy-updates,jammy-security,now 3.10.12-1~22.04.2 amd64 [installed,automatic]
libpython3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.2 amd64 [installed,automatic]
libpython3.10-stdlib/jammy-updates,jammy-security,now 3.10.12-1~22.04.2 amd64 [installed,automatic]
libpython3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.2 amd64 [installed,automatic]
python-apt-common/jammy-updates,now 2.4.0ubuntu2 all [installed,automatic]
python-is-python3/jammy,now 3.9.2-2 all [installed]
python3-apport/jammy-updates,now 2.20.11-0ubuntu82.5 all [installed,automatic]
python3-apt/jammy-updates,now 2.4.0ubuntu2 amd64 [installed,automatic]
python3-blinker/jammy,now 1.4+dfsg1-0.4 all [installed,automatic]
python3-cffi-backend/jammy,now 1.15.0-1build2 amd64 [installed,automatic]
python3-commandnotfound/jammy,now 22.04.0 all [installed,automatic]
python3-cryptography/jammy,now 3.4.8-1ubuntu2 amd64 [installed,automatic]
python3-dbus/jammy,now 1.2.18-3build1 amd64 [installed,automatic]
python3-dev/jammy-updates,jammy-security,now 3.10.6-1~22.04 amd64 [installed,automatic]
python3-distro-info/jammy-updates,now 1.1ubuntu0.1 all [installed,automatic]
python3-distro/jammy,now 1.7.0-1 all [installed,automatic]
python3-distupgrade/jammy-updates,now 1:22.04.17 all [installed,automatic]
python3-distutils/jammy-updates,jammy-security,now 3.10.8-1~22.04 all [installed,automatic]
python3-gdbm/jammy-updates,jammy-security,now 3.10.8-1~22.04 amd64 [installed,automatic]
python3-gi/jammy-updates,now 3.42.1-0ubuntu1 amd64 [installed,automatic]
python3-httplib2/jammy,now 0.20.2-2 all [installed,automatic]
python3-importlib-metadata/jammy,now 4.6.4-1 all [installed,automatic]
python3-jeepney/jammy,now 0.7.1-3 all [installed,automatic]
python3-jwt/jammy-updates,jammy-security,now 2.3.0-1ubuntu0.2 all [installed,automatic]
python3-keyring/jammy,now 23.5.0-1 all [installed,automatic]
python3-launchpadlib/jammy,now 1.10.16-1 all [installed,automatic]
python3-lazr.restfulclient/jammy,now 0.14.4-1 all [installed,automatic]
python3-lazr.uri/jammy,now 1.0.6-2 all [installed,automatic]
python3-lib2to3/jammy-updates,jammy-security,now 3.10.8-1~22.04 all [installed,automatic]
python3-minimal/jammy-updates,jammy-security,now 3.10.6-1~22.04 amd64 [installed,automatic]
python3-more-itertools/jammy,now 8.10.0-2 all [installed,automatic]
python3-netifaces/jammy,now 0.11.0-1build2 amd64 [installed,automatic]
python3-newt/jammy,now 0.52.21-5ubuntu2 amd64 [installed,automatic]
python3-oauthlib/jammy-updates,jammy-security,now 3.2.0-1ubuntu0.1 all [installed,automatic]
python3-pip/jammy-updates,jammy-security,now 22.0.2+dfsg-1ubuntu0.3 all [installed]
python3-pkg-resources/jammy-updates,jammy-security,now 59.6.0-1.2ubuntu0.22.04.1 all [installed,automatic]
python3-problem-report/jammy-updates,now 2.20.11-0ubuntu82.5 all [installed,automatic]
python3-pyparsing/jammy,now 2.4.7-1 all [installed,automatic]
python3-secretstorage/jammy,now 3.3.1-1 all [installed,automatic]
python3-setuptools/jammy-updates,jammy-security,now 59.6.0-1.2ubuntu0.22.04.1 all [installed,automatic]
python3-six/jammy,now 1.16.0-3ubuntu1 all [installed,automatic]
python3-software-properties/jammy-updates,now 0.99.22.7 all [installed,automatic]
python3-systemd/jammy,now 234-3ubuntu2 amd64 [installed,automatic]
python3-update-manager/jammy-updates,now 1:22.04.10 all [installed,automatic]
python3-wadllib/jammy,now 1.3.6-1 all [installed,automatic]
python3-wheel/jammy-updates,jammy-security,now 0.37.1-2ubuntu0.22.04.1 all [installed,automatic]
python3-yaml/jammy,now 5.4.1-1ubuntu1 amd64 [installed,automatic]
python3-zipp/jammy,now 1.0.0-3 all [installed,automatic]
python3.10-dev/jammy-updates,jammy-security,now 3.10.12-1~22.04.2 amd64 [installed,automatic]
python3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.2 amd64 [installed,automatic]
python3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.2 amd64 [installed,automatic]
python3/jammy-updates,jammy-security,now 3.10.6-1~22.04 amd64 [installed]
```


From: Tommy Murphy <tommy_...@hotmail.com>
Sent: Monday 9 October 2023 23:27
To: Victor Toon De Araujo <v22...@dac.unicamp.br>; Christoph Müllner <christoph...@vrull.eu>
Cc: RISC-V ISA Dev <isa...@groups.riscv.org>

Tommy Murphy

unread,
Oct 11, 2023, 11:38:49 AM10/11/23
to RISC-V ISA Dev, Tommy Murphy, RISC-V ISA Dev, Victor Toon De Araujo, Christoph Müllner
I also installed a new Ubuntu 20.04.03 VirtualBox VM using the ISO from here:


I installed the minimal desktop version and then did the following:

```
# Install latest updates
sudo apt update
sudo apt upgrade

# Install riscv-gnu-toolchain prerequisites - https://github.com/riscv-collab/riscv-gnu-toolchain#prerequisites
sudo apt install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev

# Clone, configure, build riscv-gnu-toolchain
cd issue-1343
./configure --prefix=`pwd`/installed-tools
make
```

And this completed without any issues.

Bruce Hoult

unread,
Nov 1, 2023, 9:08:38 PM11/1/23
to Victor Toon De Araujo, Christoph Müllner, Tommy Murphy, RISC-V ISA Dev
Building in a fresh environment in docker or some VM can be helpful if something in your long used and crufty environment mucks up standard builds that are known to work elsewhere.


Reply all
Reply to author
Forward
0 new messages