README: Update toolchain information
PATCH v2 1/1 README: Update toolchain information
Recent FW_PIC=y changes actually require toolchains with PIE support and it is on by default. Existing doc uses a GNU bare-metal toolchain as examples but it does not support PIE.
Replace references of bare-metal toolchain prefix with Linux toolchain prefix everywhere in documentation.
Also indicate that "riscv64-unknown-freebsd-" as an alternative to "riscv64-linux-" GNU toolchain.
---
Changes in v2:
- Include "riscv64-unknown-freebsd-" as an alternative
README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
README.md +13 -5
@@ -104,6 +104,14 @@ LLVM/Clang toolchain due to LLVM's ability to support multiple backends in the same binary, so is often an easy way to obtain a working cross-compilation toolchain. +Basically, we prefer toolchains with Position Independent Executable (PIE) +support like *riscv64-linux-gcc*, *riscv64-unknown-freebsd-gcc*, or +*Clang/LLVM* as they generate PIE firmware images that can run at arbitrary +address with appropriate alignment. If a bare-metal GNU toolchain (e.g. +*riscv64-unknown-elf-gcc*) is used, static linked firmware images are +generated instead. *Clang/LLVM* can still generate PIE images if a bare-metal +triple is used (e.g. *-target riscv64-unknown-elf*). + Please note that only a 64-bit version of the toolchain is available in the Bootlin toolchain repository for now.
@@ -116,7 +124,7 @@ architecture than RISC-V. For cross-compiling, the environment variable *CROSS_COMPILE* must be defined to specify the name prefix of the RISC-V compiler toolchain executables, e.g. -*riscv64-unknown-elf-* if the gcc executable used is *riscv64-unknown-elf-gcc*. +*riscv64-linux-* if the gcc executable used is *riscv64-linux-gcc*. To build *libsbi.a* simply execute: ```
@@ -192,16 +200,16 @@ Building 32-bit / 64-bit OpenSBI Images --------------------------------------- By default, building OpenSBI generates 32-bit or 64-bit images based on the supplied RISC-V cross-compile toolchain. For example if *CROSS_COMPILE* is set -to *riscv64-unknown-elf-*, 64-bit OpenSBI images will be generated. If building +to *riscv64-linux-*, 64-bit OpenSBI images will be generated. If building 32-bit OpenSBI images, *CROSS_COMPILE* should be set to a toolchain that is -pre-configured to generate 32-bit RISC-V codes, like *riscv32-unknown-elf-*. +pre-configured to generate 32-bit RISC-V codes, like *riscv32-linux-*. However it's possible to explicitly specify the image bits we want to build with a given RISC-V toolchain. This can be done by setting the environment variable *PLATFORM_RISCV_XLEN* to the desired width, for example: ``` -export CROSS_COMPILE=riscv64-unknown-elf- +export CROSS_COMPILE=riscv64-linux- export PLATFORM_RISCV_XLEN=32 ```
@@ -235,7 +243,7 @@ valid triple. These can also be mixed; for example using a GCC cross-compiler but LLVM binutils would be: ``` -make CC=riscv64-unknown-elf-gcc LLVM=1 +make CC=riscv64-linux-gcc LLVM=1 ``` These variables must be passed for all the make invocations described in this
Signature · 1 line
2.25.1
PATCH v2 1/1 README: Update toolchain information
Quoted 10 lines · Bin Meng
Recent FW_PIC=y changes actually require toolchains with PIE support and it is on by default. Existing doc uses a GNU bare-metal toolchain as examples but it does not support PIE.
Replace references of bare-metal toolchain prefix with Linux toolchain prefix everywhere in documentation.
Also indicate that "riscv64-unknown-freebsd-" as an alternative to "riscv64-linux-" GNU toolchain.
Thanks for the changes. The Linux triple is riscv64-linux-gnu (which is really riscv64-unknown-linux-gnu, but nobody uses that), though. All of Debian, Fedora and Arch ship their cross toolchains using riscv64-linux-gnu- as the prefix. The Bootlin toolchains are weird in providing riscv64-linux-gcc symlinks, though you?ll note those all symlink to riscv64-buildroot-linux-gnu tools (or indirect through toolchain-wrapper). I don?t know why they do that, they really should have a -gnu in there for the triples that don?t have a vendor. I suggest using riscv64-linux-gnu throughout and adding a note that the Bootlin toolchains currently omit the -gnu.
Jess
PATCH v2 1/1 README: Update toolchain information
Quoted 7 lines · Jessica Clarke
Quoted 5 lines · Bin Meng
Recent FW_PIC=y changes actually require toolchains with PIE support and it is on by default. Existing doc uses a GNU bare-metal toolchain as examples but it does not support PIE.
Quoted 8 lines
Quoted 5 lines
Replace references of bare-metal toolchain prefix with Linux toolchain prefix everywhere in documentation.
Also indicate that "riscv64-unknown-freebsd-" as an alternative to "riscv64-linux-" GNU toolchain.
Thanks for the changes. The Linux triple is riscv64-linux-gnu (which is really riscv64-unknown-linux-gnu, but nobody uses that), though.
Should we do "riscv64-freebsd-gcc", by omitting the "unknown" vendor?
Quoted 8 lines
All of Debian, Fedora and Arch ship their cross toolchains using riscv64-linux-gnu- as the prefix. The Bootlin toolchains are weird in providing riscv64-linux-gcc symlinks, though you?ll note those all symlink to riscv64-buildroot-linux-gnu tools (or indirect through toolchain-wrapper). I don?t know why they do that, they really should have a -gnu in there for the triples that don?t have a vendor. I suggest using riscv64-linux-gnu throughout and adding a note that the Bootlin toolchains currently omit the -gnu.
Maybe omitting "-gnu" means that they can be used for building Linux kernel. "gun" sounds like for user space only?
The Linux kernel.org provided pre-built toolchains that are all "<arch>-linux-" triples.
See https://mirrors.edge.kernel.org/pub/tools/crosstool/
Regards,
Bin
PATCH v2 1/1 README: Update toolchain information
Quoted 12 lines · Bin Meng
Quoted 10 lines · Jessica Clarke
Quoted 8 lines · Bin Meng
Recent FW_PIC=y changes actually require toolchains with PIE support and it is on by default. Existing doc uses a GNU bare-metal toolchain as examples but it does not support PIE.
Replace references of bare-metal toolchain prefix with Linux toolchain prefix everywhere in documentation.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Also indicate that "riscv64-unknown-freebsd-" as an alternative to "riscv64-linux-" GNU toolchain.
Thanks for the changes. The Linux triple is riscv64-linux-gnu (which is really riscv64-unknown-linux-gnu, but nobody uses that), though.
Should we do "riscv64-freebsd-gcc", by omitting the "unknown" vendor?
No, FreeBSD likes to leave the unknown in there, I guess because people like their triples to be actual triples and not doubles, even if it?s a waste of space.
Quoted 11 lines
Quoted 8 lines
All of Debian, Fedora and Arch ship their cross toolchains using riscv64-linux-gnu- as the prefix. The Bootlin toolchains are weird in providing riscv64-linux-gcc symlinks, though you?ll note those all symlink to riscv64-buildroot-linux-gnu tools (or indirect through toolchain-wrapper). I don?t know why they do that, they really should have a -gnu in there for the triples that don?t have a vendor. I suggest using riscv64-linux-gnu throughout and adding a note that the Bootlin toolchains currently omit the -gnu.
Maybe omitting "-gnu" means that they can be used for building Linux kernel. "gun" sounds like for user space only?
It?s a bit of a mess. In theory, yes, -gnu means glibc (there?s also a -musl and -android). But there are several reasons that?s not entirely true:
* arm-linux-gnueabi complicates things, as there is no non-libc way to get the EABI instead of the OABI (though there is a -musleabi)
* Some parts of the Linux kernel documentation say to use $CPU-linux-, others say to use $CPU-linux-gnu
* The Bootlin toolchain is a glibc toolchain (it has glibc libraries and headers, plus the full executable names are riscv46-buildroot-linux-gnu, not riscv64-buildroot-linux) yet gives the shortened paths as just riscv64-linux, which is incorrect, as that?s not the same thing, even if in practice people take it to be
So, you?re right in the sense that riscv64-linux- means no glibc, but not in the sense that the binaries shipped by Bootlin mean that, I believe.
Jess
Quoted 6 lines
The Linux kernel.org provided pre-built toolchains that are all "<arch>-linux-" triples.
See https://mirrors.edge.kernel.org/pub/tools/crosstool/Regards,
Bin