├── .gitattributes ├── .gitignore ├── LICENSE.md └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Directories 2 | src 3 | build 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RISC-V RV32E / RV32I / RV64I ELF (Last updated: 2025.08.03) 2 | =========================================================== 3 | 4 | Build script to build the current GCC toolchain from source with riscv-unknown-elf bare-metal as target with ilp32e / ilp32 and ilp64 ABI. 5 | This includes the support for newlib and uclibc++. 6 | The configuration does not support multi-threading and uses init_array and fini_array to initialize the used software libraries. 7 | 8 | Toolchain Configuration 9 | ----------------------- 10 | 11 | | Option | Description | Default Value | 12 | | ----------------------------------- | --------------------------------------------------- | ---------------------------- | 13 | | __OPT_TARGET_ARCH | Target architecture triplet | riscv-unknown-elf | 14 | | __OPT_TARGET_MARCH | Default target architecture | RV64GC | 15 | | __OPT_TARGET_MABI | Default target ABI | ILP64D | 16 | | __OPT_TARGET_MARCH_FULL | Maximum target architecture | RV64GC | 17 | | __OPT_TARGET_ENABLE_RISCV32E | Enable RV32E variants | yes | 18 | | __OPT_TARGET_ENABLE_RISCV32I | Enable RV32I variants | yes | 19 | | __OPT_TARGET_ENABLE_RISCV64G | Enable RV64G variants | yes | 20 | | __OPT_TARGET_ENABLE_RISCV128G | Enable RV128G variants | no | 21 | | __OPT_TARGET_ENABLE_SINGLE_FLOAT | Enable single-precision floating-point support | yes | 22 | | __OPT_TARGET_ENABLE_DOUBLE_FLOAT | Enable double-precision floating-point support | yes | 23 | | __OPT_TARGET_ENABLE_QUAD_FLOAT | Enable quad-precision floating-point support | no | 24 | | __OPT_TARGET_ENABLE_ADDITIONAL_ABIS | Enable additional uncommon ABIs | no | 25 | | __OPT_TARGET_PATH | Installation directory | /usr/local/riscv-unknown-elf | 26 | | __OPT_TARGET_PREFIX | Program name prefix | riscv-unknown-elf- | 27 | | __OPT_BUILD_MULTICORE | Maximum parallel job count for Makefile | -j$(nproc) | 28 | | __OPT_BUILD_HACKY_MULTICORE | Patches build files to enable multi-threaded builds | yes (might break the build) | 29 | | __OPT_INSTALL_DEPENDENCIES | Install dependencies required for build | yes | 30 | 31 | Instruction Sets: 32 | 33 | - E: Base Integer Instruction Set with 16 registers 34 | - I: Base Integer Instruction Set with 32 registers 35 | 36 | Extensions: 37 | 38 | - M: Integer Multiplication and Division 39 | - A: Atomic Instructions 40 | - C: Compressed Instructions 41 | - F: Single-Precision Floating-Point Instructions 42 | - D: Double-Precision Floating-Point Instructions 43 | - Q: Quadruple-Precision Floating-Point Instructions 44 | 45 | Library-sharing between the compressed and uncompressed instruction sets is disabled and each architecture / instruction set generates a unique c / c++ library. 46 | The following configuration sets can be built independently or together in one toolchain: 47 | 48 | Toolchain Version 49 | ----------------- 50 | 51 | | Software / Library | Version | Date | Homepage | Git Repository | 52 | | --------------------------------- | ------- | ---------------- | ---------------------------------------------- | --------------------------------------------------- | 53 | | The GNU Binutils (Binutils) | 2.45 | 2025-07-27 09:56 | [Link](https://www.gnu.org/software/binutils/) | [Link](http://sourceware.org/git/binutils-gdb.git) | 54 | | The GNU Project Debugger (GDB) | 16.3 | 2025-04-20 10:22 | [Link](https://www.gnu.org/software/gdb/) | [Link](http://sourceware.org/git/binutils-gdb.git) | 55 | | The GNU Compiler Collection (GCC) | 15.1.0 | 2025-04-25 08:21 | [Link](https://gcc.gnu.org/) | [Link](http://gcc.gnu.org/git/gcc.git) | 56 | | Newlib C Library (Newlib) | 4.5.0 | 2025-01-01 20:35 | [Link](https://sourceware.org/newlib/) | [Link](http://sourceware.org/git/newlib-cygwin.git) | 57 | | uCLibc++ | 0.2.5 | 2019-04-06 17:20 | [Link](https://cxx.uclibc.org/) | [Link](http://git.busybox.net/uClibc++) | 58 | 59 | Requirements 60 | ------------ 61 | 62 | Build of RV64GC with all ABIs on Ryzen 3950X (16 Cores): 63 | 64 | - Disk Space: 15 GiB (Build) / 3 GiB (Installed) 65 | - Memory: 16 GiB (+ 16 GiB when using tmpfs for build directory) 66 | - Build Time: 12 min (with hacky multi-core) 67 | 68 | RV32E (Draft) 69 | ------------- 70 | 71 | Available extension combinations and possible ABIs: 72 | 73 | | Architecture | Defautl ABI | Additional ABIs | 74 | | ------------ | ----------- | --------------- | 75 | | RV32E(C) | ilp32e | | 76 | | RV32EM(C) | ilp32e | | 77 | | RV32EA(C) | ilp32e | | 78 | | RV32EMA(C) | ilp32e | | 79 | 80 | RV32I (Ratified) 81 | ---------------- 82 | 83 | Available extension combinations and possible ABIs: 84 | 85 | | Architecture | Default ABI | Additional ABIs | 86 | | ----------------------- | ----------- | --------------- | 87 | | RV32I(C) | ilp32 | | 88 | | RV32IM(C) | ilp32 | | 89 | | RV32IA(C) | ilp32 | | 90 | | RV32IMA(C) | ilp32 | | 91 | | RV32IF(C) | ilp32f | ilp32 | 92 | | RV32IMF(C) | ilp32f | ilp32 | 93 | | RV32IAF(C) | ilp32f | ilp32 | 94 | | RV32IMAF(C) | ilp32f | ilp32 | 95 | | RV32IFD(C) | ilp32d | ilp32, ilp32f | 96 | | RV32IMFD(C) | ilp32d | ilp32, ilp32f | 97 | | RV32IAFD(C) | ilp32d | ilp32, ilp32f | 98 | | RV32IMAFD(C) / RV32G(C) | ilp32d | ilp32, ilp32f | 99 | 100 | RV64I (Ratified) 101 | ---------------- 102 | 103 | Available extension combinations and possible ABIs: 104 | 105 | | Architecture | Default ABI | Additional ABIs | 106 | | ------------------------- | ----------- | ------------------ | 107 | | RV64I(C) | lp64 | | 108 | | RV64IM(C) | lp64 | | 109 | | RV64IA(C) | lp64 | | 110 | | RV64IMA(C) | lp64 | | 111 | | RV64IF(C) | lp64f | lp64 | 112 | | RV64IMF(C) | lp64f | lp64 | 113 | | RV64IAF(C) | lp64f | lp64 | 114 | | RV64IMAF(C) | lp64f | lp64 | 115 | | RV64IFD(C) | lp64d | lp64, lp64f | 116 | | RV64IMFD(C) | lp64d | lp64, lp64f | 117 | | RV64IAFD(C) | lp64d | lp64, lp64f | 118 | | RV64IMAFD(C) / RV64G(C) | lp64d | lp64, lp64f | 119 | | RV64IFDQ(C) | lp64q | lp64, lp64f, lp64d | 120 | | RV64IMFDQ(C) | lp64q | lp64, lp64f, lp64d | 121 | | RV64IAFDQ(C) | lp64q | lp64, lp64f, lp64d | 122 | | RV64IMAFDQ(C) / RV64GQ(C) | lp64q | lp64, lp64f, lp64d | 123 | 124 | RV128I (Draft) (TODO) 125 | --------------------- 126 | 127 | Available extension combinations and possible ABIs: 128 | 129 | | Architecture | Default ABI | Additional ABIs | 130 | | --------------------------- | ----------- | --------------- | 131 | | RV128I(C) | Unknown | Unknown | 132 | | RV128IM(C) | Unknown | Unknown | 133 | | RV128IA(C) | Unknown | Unknown | 134 | | RV128IMA(C) | Unknown | Unknown | 135 | | RV128IF(C) | Unknown | Unknown | 136 | | RV128IMF(C) | Unknown | Unknown | 137 | | RV128IAF(C) | Unknown | Unknown | 138 | | RV128IMAF(C) | Unknown | Unknown | 139 | | RV128IFD(C) | Unknown | Unknown | 140 | | RV128IMFD(C) | Unknown | Unknown | 141 | | RV128IAFD(C) | Unknown | Unknown | 142 | | RV128IMAFD(C) / RV128G(C) | Unknown | Unknown | 143 | | RV128IFDQ(C) | Unknown | Unknown | 144 | | RV128IMFDQ(C) | Unknown | Unknown | 145 | | RV128IAFDQ(C) | Unknown | Unknown | 146 | | RV128IMAFDQ(C) / RV128GQ(C) | Unknown | Unknown | 147 | 148 | More information 149 | ================ 150 | 151 | - [RISC-V Specifications](https://riscv.org/specifications/) 152 | - [RISC-V Tools](https://github.com/riscv/riscv-tools) 153 | - [RISC-V Toolchain](https://github.com/riscv/riscv-gnu-toolchain) 154 | --------------------------------------------------------------------------------