Using an Alternate Toolchain with MicroBlaze V
Table of Contents
Introduction
One of the big advantages of RISC-V is the ecosystem. Another is the pace of innovation in the community. To allow our customers to take advantage of the ecosystem, and use new features from the community, we have some flexibility for advanced customers. The flexibility does have some risk involved, so this page is intended for experienced customers that are comfortable with debugging any issues they might see.
These notes only contain examples for Linux. These features should work on Windows, but the details are not given here. Nothing on this page is explicitly supported by AMD and it is expected that these features will be used by customers that understand them fully.
Vitis Environment Variable
In UG1400, in the section Setting User Specified Tool Chain there is information on getting Vitis to use a different toolchain than those installed with it. Note that this will apply to all processor architectures supported by Vitis, so you should only set the mentioned environment variable temporarily to avoid confusion when switching to another processor architecture. The environment variable needs to be set before creating the platform and applications as the path to the tools is saved during creation.
Using a Toolchain from another Vitis Installation
The simplest use of this feature is to use a toolchain from another installation. In this example we're using 2024.1 (gcc 12.1) but want to use the toolchain from 2024.2 (gcc 13.3) without updating the hardware design. Note that the default paths are used here. You might need to change them to suit your installation.
user@host:~$ . /tools/Xilinx/prod/Vitis/2024.1/settings64.sh
user@host:~$ export VITIS_IDE_USER_TOOLCHAIN=/tools/Xilinx/Vitis/2024.2/gnu/riscv/lin/riscv64-unknown-elf/bin
user@host:~$ ${VITIS_IDE_USER_TOOLCHAIN}/riscv64-unknown-elf-gcc --version
riscv32-xilinx-elf-gcc.real (GCC) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
user@host:~$ vitis &
Once Vitis launches and you create your platform from the exported XSA, you can see that the compiler used changes in the build phase. You might need to turn on verbose output to see this.
Multilib
As configured and shipped with Vitis, gcc uses a configuration called multilib to support different soft processor configurations. We build and package a number of multilibs to support the common MicroBlaze V configurations. As there are over 1000 possible combinations, we cannot ship them all. You might want to build your own toolchain to support a multilib we do not ship or build your own toolchain to use a different version than the one we ship with.
It is important to realize that the multilib configuration applies only to the linker and not the compiler. Your application code is compiled with the compiler configuration that exactly matches the processor you have generated. The linker configuration might be a subset of that configuration. When the linker configuration is a subset, your linked code will execute without problems. However, the code in the precompiled libraries might not take advantage of all of the processor features you have enabled – the performance or code size might not be optimal. This is one reason why you would want to compile your own custom toolchain.
For example, let's get a list of RISC-V multilibs shipped with your installation. The list shown here is only an example, this will change from release to release.
user@host:~$ ${XILINX_VITIS}/gnu/riscv/lin/riscv64-unknown-elf/bin/riscv64-unknown-elf-gcc -print-multi-lib
.;
rv32i/ilp32;@march=rv32i@mabi=ilp32
rv32if_zicsr/ilp32f;@march=rv32if_zicsr@mabi=ilp32f
rv32ic/ilp32;@march=rv32ic@mabi=ilp32
rv32ifc_zicsr/ilp32f;@march=rv32ifc_zicsr@mabi=ilp32f
rv32im/ilp32;@march=rv32im@mabi=ilp32
rv32imf_zicsr/ilp32f;@march=rv32imf_zicsr@mabi=ilp32f
rv32imc/ilp32;@march=rv32imc@mabi=ilp32
rv32imfc_zicsr/ilp32f;@march=rv32imfc_zicsr@mabi=ilp32f
rv64i/lp64;@march=rv64i@mabi=lp64
rv64if_zicsr/lp64f;@march=rv64if_zicsr@mabi=lp64f
rv64ic/lp64;@march=rv64ic@mabi=lp64
rv64ifc_zicsr/lp64f;@march=rv64ifc_zicsr@mabi=lp64f
rv64im/lp64;@march=rv64im@mabi=lp64
rv64imf_zicsr/lp64f;@march=rv64imf_zicsr@mabi=lp64f
rv64imc/lp64;@march=rv64imc@mabi=lp64
rv64imfc_zicsr/lp64f;@march=rv64imfc_zicsr@mabi=lp64f
rv64imfdc_zicsr/lp64d;@march=rv64imfdc_zicsr@mabi=lp64d
Let's focus on the 32-bit multilibs. You can see in the above example that we ship eight, every combination of the optional m, f and c. If for example your MicroBlaze V has bit manipulation enabled, libc will not take advantage of it unless you build your own and modify the platform to use it.
Building and using your own Toolchain
You can follow the instructions at riscv-gnu-toolchain/README.md at master · riscv-collab/riscv-gnu-toolchain to build your own toolchain. We will give an example here. Note that if you checkout the HEAD of that repo you will get the latest gcc version they support, so make sure this is what you want. It is suggested to start with the same gcc/libc versions as is shipped with your Vitis installation. Using a newer version is untested and likely to cause compilation issues with our device drivers.
You will need to read the details in the gcc documentation on the multilib generator string to understand how to configure the toolchain. Note that Vitis assumes the toolchain has the prefix riscv64-unknown-elf- for both 32-bit and 64-bit configurations. Using --with-multilib-generator as shown below will deliver tools with the appropriate prefix.
user@host:~/riscv-gnu-toolchain:$ ./configure --prefix=${HOME}/riscv --with-multilib-generator="rv32imc-ilp32–"
user@host:~/riscv-gnu-toolchain:$ make -j 8
user@host:~/riscv-gnu-toolchain:$ ~/riscv/bin/riscv64-unknown-elf-gcc -print-multi-lib
.;
rv32imc/ilp32;@march=rv32imc@mabi=ilp32
Now you can tell Vitis to use your new toolchain. Note that we're using gcc 14.2 in this example. As above, please be sure to understand the choices you are making when you choose which toolchain version to build.
user@host:~$ export VITIS_IDE_USER_TOOLCHAIN=${HOME}/riscv/bin
user@host:~$ ${VITIS_IDE_USER_TOOLCHAIN}/riscv64-unknown-elf-gcc --version
riscv64-unknown-elf-gcc (g04696df0963) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
user@host:~$ vitis &
Related content
© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy