GNU RISC-V Make Trying to Access File in Directory it just Created

er flag

I'm trying to run xv6-riscv. I'm on Ubuntu 22.04.2 LTS, so I needed to build the gnu-riscv-toolchain. Following these instructions, I ran sudo make. Eventually, make produced the following output:

rm -rf stamps/build-newlib build-newlib
mkdir build-newlib
cd build-newlib && /mnt/c/Users/vrait/Documents/Code/OperatingSystems/riscv-gnu-toolchain/newlib/configure \
        --target=riscv64-unknown-elf \
        --prefix=/usr/local \
        --enable-newlib-io-long-double \
        --enable-newlib-io-long-long \
        --enable-newlib-io-c99-formats \
        --enable-newlib-register-fini \
        CFLAGS_FOR_TARGET="-O2 -D_POSIX_MODE -ffunction-sections -fdata-sections    -mcmodel=medlow" \
        CXXFLAGS_FOR_TARGET="-O2 -D_POSIX_MODE -ffunction-sections -fdata-sections    -mcmodel=medlow"
/bin/sh: 1: /mnt/c/Users/vrait/Documents/Code/OperatingSystems/riscv-gnu-toolchain/newlib/configure: not found
make: *** [Makefile:622: stamps/build-newlib] Error 127

Line 622 is the Makefile line that's producing the error:

rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
    # some args

I don't have much experience with CMake, but my understanding is that this code deletes notdir, creates a new notdir directory, moves into it, and then tries to run /configure with some arguments. I'm confused as to how this could work: you're trying to access a file in an empty directory you just created. How could there ever be a file there for you to access?

Changing /configure to /../configure allows me to hack past this error (there is a configure file in the root directory of the gnu-riscv-toolchain that I assume this causes the program to access), but Make stalls suddenly after outputting the following (no error message, it just stops producing output):

cd build-binutils-newlib && CC_FOR_TARGET=riscv64-unknown-elf-gcc /mnt/c/Users/vrait/Documents/Code/OperatingSystems/riscv-gnu-toolchain/newlib/../binutils/configure \
    # some args

Which I assume is caused somehow by the change of /configure to /../configure.

How could the rm, mkdir, cd, /configure sequence work without always trying to access a file that doesn't exist? Also, what would be the correct approach to fixing the not found error?

hr flag
`cmake` doesn't seem to be involved here - just `make`. In a Makefile, the automatic variable `$<` refers to the first prerequisite of the current rule - so (as you can see from your first fragment) it's not trying to run `./configure`, it's trying to run `/mnt/c/Users/vrait/Documents/Code/OperatingSystems/riscv-gnu-toolchain/newlib/configure` . My *guess* is that it the `not found` error is because you're trying to do this on a Windows filesystem (at `/mnt/c`) that doesn't understand Linux executable permissions.
VanceR avatar
er flag
okay thank you! I am running make from within the ubuntu terminal, and it seemed to have no problem up to this point. How would it be using the windows filesystem?
hr flag
The path `/mnt/c/Users/vrait/Documents/Code/OperatingSystems/` suggests like you are using WSL and have downloaded the toolchain source to your Windows `Documents` directory
VanceR avatar
er flag
Ah okay. I tried downloading and building it in /home/vraiti and it worked. Thanks!
I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.