Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilib toolchain build fails with 'python': No such file or directory #1330

Closed
m-ertem opened this issue Sep 13, 2023 · 15 comments
Closed

Comments

@m-ertem
Copy link

m-ertem commented Sep 13, 2023

After I have installed the prerequisites, I have tried to install the toolchain via make command. However after couple of minutes, the below error was given.

Make-error
@TommyMurphyTM1234
Copy link
Collaborator

TommyMurphyTM1234 commented Sep 13, 2023

You haven't provided even the basic information needed for somebody to try to understand our reproduce your issue.
For example: What OS/version? The full list of commands that you used (exactly what prerequisites that you installed, your git clone, configure, make commands). A full build log. Etc.

Please also attach logs rather than screenshots as the latter are not convenient to read for many users.

You also don't seem to have all prerequisites installed (python):

and may be using the --with-multilib-generator option incorrectly (unless that's a side-effect of python not being installed).

@m-ertem
Copy link
Author

m-ertem commented Sep 13, 2023

Sorry about that I am new to Git. I am working on Ubuntu 22.04.2 LTS and all commands I have used are below. I am sure I have installed python3 however it can't find. I also added the full log below. Thank you in advance.

screen.log

  1. git clone https://github.com/riscv/riscv-gnu-toolchain
  2. sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
  3. cd riscv-gnu-toolchain
  4. ./configure –-prefix=/opt/riscv --with-multilib-generator="rv32i- ilp32--;rv32im-ilp32--"
  5. sudo make

Screenshot of the error:

@TommyMurphyTM1234
Copy link
Collaborator

TommyMurphyTM1234 commented Sep 13, 2023

You still haven't installed python[2] as per this:

Do one of the following:

# Install python 2
sudo apt install python

# Make python refer to python3
sudo apt install python-is-python3

and then try again:

# Prepare for a clean build
make distclean
sudo rm -rf <prefix-dir-specified-at-configure-time>

# Configure and make
./configure --prefix=... --with-multilib-generator="..."
make 2>&1 | tee build.log

@TommyMurphyTM1234
Copy link
Collaborator

This worked for me:

# Clean VirtualBox VM installation of Zorin OS 16.3 (Ubuntu 20.04.1 LTS derivative) with all available updates installed

# Install main 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

# Install additional prerequisites: https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1251
sudo apt install python-is-python3 expect device-tree-compiler libglib2.0-dev pip

# Clone
cd ~/Downloads
git clone https://github.com/riscv-collab/riscv-gnu-toolchain issue-1330

# Configure
cd issue-1330
./configure --prefix=`pwd`/installed-tools --with-multilib-generator="rv32gc-ilp32d--;rv32i-ilp32--"

# Build
make 2>&1 | tee build.log

Compressed build.log: build.log.zip

@TommyMurphyTM1234
Copy link
Collaborator

TommyMurphyTM1234 commented Sep 13, 2023

This failed:

cd ~/Downloads/issue-1330
sudo apt remove python-is-python3
make distclean
rm -rf installed-tools
./configure --prefix=`pwd`/installed-tools --with-multilib-generator="rv32gc-ilp32d--;rv32i-ilp32--"
make 2>&1 | tee build.log

...

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/Downloads/issue-1330/build-gcc-newlib-stage1'
make: *** [Makefile:589: stamps/build-gcc-newlib-stage1] Error 2

So your problem is that you don't have any python installed.

@m-ertem
Copy link
Author

m-ertem commented Sep 14, 2023

I think it has worked. How can I check if the make is successful? Thanks for your effort.

@m-ertem
Copy link
Author

m-ertem commented Sep 14, 2023

Unfortunately I couldn't be able to use riscv64-unknown-elf-gcc command, as seen below log file. I added /opt/riscv/bin to path by sudo nano /etc/environment and by writing :/opt/riscv/bin

Compile.log

@TommyMurphyTM1234
Copy link
Collaborator

TommyMurphyTM1234 commented Sep 14, 2023

Unfortunately I couldn't be able to use riscv64-unknown-elf-gcc command, as seen below log file. I added /opt/riscv/bin to path by sudo nano /etc/environment and by writing :/opt/riscv/bin

Compile.log

If your toolchain built successfully after you installed python-is-python3 then this has nothing to do with riscv-gnu-toolchain but is an issue with your local environment/configuration.

You don't clarify if/how your toolchain built successfully (e.g. your full build log), where it was installed to, what your $PATH environment variable is set to after your changes etc. If you set your $PATH to precisely :/opt/riscv/bin then that's probably incorrect as it would remove any default search directories that are required for normal system behaviour.

Even the following basic information would help.

echo $PATH
ls /opt/riscv/bin

@TommyMurphyTM1234 TommyMurphyTM1234 changed the title Having error while make command Multilib toolchain build fails with 'python': No such file or directory Sep 14, 2023
@TommyMurphyTM1234
Copy link
Collaborator

TommyMurphyTM1234 commented Sep 14, 2023

I added /opt/riscv/bin to path by sudo nano /etc/environment and by writing :/opt/riscv/bin

Why are you doing this rather than editing your local account's ~/.bashrc or equivalent shell configuration file or ~/.profile etc.?

Changes made to the $PATH through any of these methods do not take immediate effect in the current terminal/shell session, only to terminals/shells launched anew after such changes.

@m-ertem
Copy link
Author

m-ertem commented Sep 15, 2023

I have edited bashrc file and /opt/riscv/bin can be seen in the path. So I think that it is OK.
echo $PATH
:/opt/riscv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/opt/riscv/bin

However, riscv64-unknown-elf-gcc command can't find -lc and -lgloss.

mertem@mertem:~/Downloads/RISC-V/test/bubble_sort$ riscv64-unknown-elf-gcc bubble_sort.c ../crt0.s -march=rv32i -mabi=ilp32 -T ../linksc.ld -nostartfiles -ffunction-sections -fdata-sections -Wl,--gc-sections -o bubble_sort.elf
/usr/lib/riscv64-unknown-elf/bin/ld: cannot find -lc
/usr/lib/riscv64-unknown-elf/bin/ld: cannot find -lgloss
collect2: error: ld returned 1 exit status

@TommyMurphyTM1234
Copy link
Collaborator

TommyMurphyTM1234 commented Sep 15, 2023

You keep posting partial info which makes it almost impossible to comment meaningfully.
And moving the goalposts - this issue:

Unfortunately I couldn't be able to use riscv64-unknown-elf-gcc command, as seen below log file.

is not the same as this issue:

However, riscv64-unknown-elf-gcc command can't find -lc and -lgloss.

You have not clarified the exact commands that you have used to clone/configure/build/install the toolchain and a build log that shows how that went.
Or provided a clear description of your environment.
Or provided a simple standalone test case that reproduces your problem - e.g. the source code (bubble_sort.c, crt0.s, linksc.ld etc.) that you're using above.

@TommyMurphyTM1234
Copy link
Collaborator

If you installed your toolchain in /opt/riscv:

echo $PATH :/opt/riscv/bin:...

then why are you picking up a RISC-V linker from /usr/lib/?

/usr/lib/riscv64-unknown-elf/bin/ld: cannot find -lc 
/usr/lib/riscv64-unknown-elf/bin/ld: cannot find -lgloss collect2: 
error: ld returned 1 exit status

It sounds like your setup is messed up.

You would be better off starting with a clean slate - e.g. a clean installation of the OS on a physical or virtual machine.

@TommyMurphyTM1234
Copy link
Collaborator

TommyMurphyTM1234 commented Sep 15, 2023

/usr/lib/riscv64-unknown-elf/bin/ld: cannot find -lc 
/usr/lib/riscv64-unknown-elf/bin/ld: cannot find -lgloss collect2: 
error: ld returned 1 exit status

This (above) suggests that you previously installed a RISC-V toolchain from the Ubuntu software repos - e.g.:

sudo apt install gcc-riscv64-unknown-elf

which will put things in "system" directories including /usr/lib/riscv64-unknown-elf.

If you are using your own build of the toolchain then you need to take care to ensure that only it is used and not bits of some other toolchain.

I would suggest that you at least remove this toolchain and try again:

sudo apt remove gcc-riscv64-unknown-elf
# even after the previous command bits get left behind so manually remove them
sudo rm -rf /usr/lib/riscv64-unknown-elf

@mskertem
Copy link

Thanks for all your effort. As you said the problem is turned out to be the PATH. Hence I added the wrong directory to PATH, riscv64-unknown-elf-gcc command couldn't be found. Then I checked the exact directory of gcc-riscv64-unknown-elf, then added to PATH. Eventually everything works correctly!

@TommyMurphyTM1234
Copy link
Collaborator

As you said the problem is turned out to be the PATH. Hence I added the wrong directory to PATH, riscv64-unknown-elf-gcc command couldn't be found. Then I checked the exact directory of gcc-riscv64-unknown-elf, then added to PATH. Eventually everything works correctly!

That's why I asked for this information earlier:

Unfortunately I couldn't be able to use riscv64-unknown-elf-gcc command, as seen below log file. I added /opt/riscv/bin to path by sudo nano /etc/environment and by writing :/opt/riscv/bin
Compile.log

If your toolchain built successfully after you installed python-is-python3 then this has nothing to do with riscv-gnu-toolchain but is an issue with your local environment/configuration.

You don't clarify if/how your toolchain built successfully (e.g. your full build log), where it was installed to, what your $PATH environment variable is set to after your changes etc. If you set your $PATH to precisely :/opt/riscv/bin then that's probably incorrect as it would remove any default search directories that are required for normal system behaviour.

Even the following basic information would help.

echo $PATH
ls /opt/riscv/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants