michaeljclark / busybear-linux

busybear-linux is a tiny RISC-V Linux root filesystem image that targets the VirtIO board in riscv-qemu.
93 stars 33 forks source link

how to build on Ubuntu w/ their version of GCC for RISCV #4

Open wadester opened 5 years ago

wadester commented 5 years ago

I am trying to build busybear-linux with their supplied GCC for RISCV: gcc-7-riscv64-linux-gnu and gcc-7-riscv64-linux-gnu-base:amd64
or gcc-8-riscv64-linux-gnu and gcc-8-riscv64-linux-gnu-base:amd64

I have multiple questions: Should I use GCC 7 or 8? How would I change the scripts from using a full tool install, for example into /opt/riscv? If building GCC for RISCV should I use the multilib option: ./configure --prefix=/opt/riscv --enable-multilib make linux

Could you update the docs to include some clarification.

Thanks for a great project. Note, I did something similar using buildroot on a 2.2 kernel a very, very long time ago to make an image that fit on a floppy....

michaeljclark commented 5 years ago

Hi,

Sorry for the late reply. The project is currently configured for the toolchain directory layout of riscv-gnu-toolchain. I have not tried it using the debian toolchains. Feel free to make a pull request if you have time.

You would need to muck around with scripts/image.sh to figure out how to get it to build an image for a compiler with a different directory layout and different dynamic linker directories.

It should work either with or without --enable-multilib however most of the recent testing has been with multilib toolchains. It's intended for use with both which is why there is no mention in the docs. I'll consider updating the docs. Here is the fragment from scripts/image.sh that detects a multilib toolchain:

# copy libraries
if [ -d ${GCC_DIR}/sysroot/usr/lib${ARCH/riscv/}/${ABI}/ ]; then
    ABI_DIR=lib${ARCH/riscv/}/${ABI}
else
    ABI_DIR=lib
fi

This should pick either one of these:

Note: the expression ${ARCH/riscv/} extracts the bitwidth from the ARCH variable (either riscv32 or riscv64), as I it is also written to allow for creating test images using 32-bit toolchain and kernel.

It might good to add a static option which would simplify this a bit as the tricky bit is library dependencies (the shell script code in copy_libs).

Michael.