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

scripts: Use Linux MUSL toolchain for building Linux Kernel. #188

Merged
merged 1 commit into from
Aug 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ if [ "$FIRMWARE" != "linux" ]; then
exit 1
fi

# Install a toolchain with the newlib standard library
if ! ${CPU_ARCH}-elf-newlib-gcc --version > /dev/null 2>&1; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line 172 we use this compiler to build VexRiscv's emulator. I suggest changing it from:

export RISCV_BIN="${CPU_ARCH}-elf-newlib-"

to:

export RISCV_BIN="${CPU_ARCH}-linux-musl-"

# Install a baremetal toolchain with the newlib standard library
if ! ${CPU_ARCH}-elf-newlib --version > /dev/null 2>&1; then
conda install gcc-${CPU_ARCH}-elf-newlib
fi
# Install a Linux userspace toolchain with the musl standard library
if ! ${CPU_ARCH}-linux-musl-gcc --version > /dev/null 2>&1; then
conda install gcc-${CPU_ARCH}-linux-musl
fi

if [ ${CPU} = mor1kx ]; then
LINUX_REMOTE="${LINUX_REMOTE:-https://github.com/timvideos/linux-litex.git}"
Expand Down Expand Up @@ -180,23 +184,7 @@ if [ ${CPU} = vexriscv ]; then
fi

# Build linux-litex

# download and use pre-built RISC-V compiler (TODO: to be removed later)
TOOLCHAIN_LOCATION=$TOP_DIR/third_party/riscv-toolchain
mkdir -p $TOOLCHAIN_LOCATION
(
cd $TOOLCHAIN_LOCATION
if [ ! -d riscv ]; then
wget https://antmicro.com/projects/renode/litex-buildenv/riscv32-unknown-linux-gnu.tar.gz
tar -xf riscv32-unknown-linux-gnu.tar.gz
fi
)
export PATH=$TOOLCHAIN_LOCATION/riscv/bin:$PATH
if [ ${CPU} = mor1kx ]; then
export CROSS_COMPILE=${CPU_ARCH}-elf-newlib-
else
export CROSS_COMPILE=riscv32-unknown-linux-gnu-
fi
export CROSS_COMPILE=${CPU_ARCH}-linux-musl-

TARGET_LINUX_BUILD_DIR=$(dirname $TOP_DIR/$FIRMWARE_FILEBASE)
(
Expand Down