{"id":13598075,"url":"https://github.com/riscv-collab/riscv-gnu-toolchain","last_synced_at":"2025-12-27T09:45:19.039Z","repository":{"id":20501676,"uuid":"23780138","full_name":"riscv-collab/riscv-gnu-toolchain","owner":"riscv-collab","description":"GNU toolchain for RISC-V, including GCC","archived":false,"fork":false,"pushed_at":"2025-05-10T03:17:24.000Z","size":6545,"stargazers_count":3900,"open_issues_count":30,"forks_count":1239,"subscribers_count":144,"default_branch":"master","last_synced_at":"2025-05-10T04:50:03.305Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/riscv-collab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-09-08T05:22:03.000Z","updated_at":"2025-05-09T16:40:22.000Z","dependencies_parsed_at":"2023-09-30T00:47:06.984Z","dependency_job_id":"11f9a7fd-9ae7-458e-bcd0-1908b0ccab48","html_url":"https://github.com/riscv-collab/riscv-gnu-toolchain","commit_stats":{"total_commits":850,"total_committers":87,"mean_commits":9.770114942528735,"dds":0.7011764705882353,"last_synced_commit":"b86b2b37d0acc607156ff56ff17ee105a9b48897"},"previous_names":[],"tags_count":98,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riscv-collab%2Friscv-gnu-toolchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riscv-collab%2Friscv-gnu-toolchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riscv-collab%2Friscv-gnu-toolchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riscv-collab%2Friscv-gnu-toolchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riscv-collab","download_url":"https://codeload.github.com/riscv-collab/riscv-gnu-toolchain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990498,"owners_count":21995776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T17:00:47.559Z","updated_at":"2025-12-27T09:45:19.033Z","avatar_url":"https://github.com/riscv-collab.png","language":"C","readme":"RISC-V GNU Compiler Toolchain\n=============================\n\nThis is the RISC-V C and C++ cross-compiler. It supports two build modes:\na generic ELF/Newlib toolchain and a more sophisticated Linux-ELF/glibc\ntoolchain.\n\n###  Getting the sources\n\nThis repository uses submodules, but submodules will fetch automatically on demand,\nso `--recursive` or `git submodule update --init --recursive` is not needed.\n\n    $ git clone https://github.com/riscv/riscv-gnu-toolchain\n\n**Warning: git clone takes around 6.65 GB of disk and download size**\n\n### Prerequisites\n\nSeveral standard packages are needed to build the toolchain.\n\nOn Ubuntu, executing the following command should suffice:\n\n    $ sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip python3-tomli libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev libncurses-dev\n\nOn Fedora/CentOS/RHEL OS, executing the following command should suffice:\n\n    $ sudo yum install autoconf automake python3 libmpc-devel mpfr-devel gmp-devel gawk  bison flex texinfo patchutils gcc gcc-c++ zlib-devel expat-devel libslirp-devel ncurses-devel\n\nOn Arch Linux, executing the following command should suffice:\n\n    $ sudo pacman -Syu curl python3 libmpc mpfr gmp base-devel texinfo gperf patchutils bc zlib expat libslirp ncurses\n\nAlso available for Arch users on the AUR: [https://aur.archlinux.org/packages/riscv-gnu-toolchain-bin](https://aur.archlinux.org/packages/riscv-gnu-toolchain-bin)\n\nOn macOS, you can use [Homebrew](http://brew.sh) to install the dependencies:\n\n    $ brew install python3 gawk gnu-sed make gmp mpfr libmpc isl zlib expat texinfo flock libslirp ncurses\n\nWhen executing the instructions in this README, please use `gmake` instead of `make` to use the newly installed version of make.\nTo build the glibc (Linux) on macOS, you will need to build within a case-sensitive file\nsystem.  The simplest approach is to create and mount a new disk image with\na case sensitive format.  Make sure that the mount point does not contain spaces. This is not necessary to build newlib or gcc itself on macOS.\n\nThis process will start by downloading about 200 MiB of upstream sources, then\nwill patch, build, and install the toolchain.  If a local cache of the\nupstream sources exists in $(DISTDIR), it will be used; the default location\nis /var/cache/distfiles.  Your computer will need about 8 GiB of disk space to\ncomplete the process.\n\n### Installation (Newlib)\n\nTo build the Newlib cross-compiler, pick an install path (that is writeable).\nIf you choose, say, `/opt/riscv`, then add `/opt/riscv/bin` to your `PATH`.\nThen, simply run the following command:\n\n    ./configure --prefix=/opt/riscv\n    make\n\nYou should now be able to use riscv64-unknown-elf-gcc and its cousins.\n\nNote: If you're planning to use an external library that replaces part of newlib (for example `libgloss-htif`), [read the FAQ](#ensuring-code-model-consistency).\n\n### Installation (Linux)\n\nTo build the Linux cross-compiler, pick an install path (that is writeable).\nIf you choose, say, `/opt/riscv`, then add `/opt/riscv/bin` to your `PATH`.\nThen, simply run the following command:\n\n    ./configure --prefix=/opt/riscv\n    make linux\n\nThe build defaults to targeting RV64GC (64-bit) with glibc, even on a 32-bit\nbuild environment. To build the 32-bit RV32GC toolchain, use:\n\n    ./configure --prefix=/opt/riscv --with-arch=rv32gc --with-abi=ilp32d\n    make linux\n\nIn case you prefer musl libc over glibc, configure just like above and opt for\n`make musl` instead of `make linux`.\n\nSupported architectures are rv32i or rv64i plus standard extensions (a)tomics,\n(m)ultiplication and division, (f)loat, (d)ouble, or (g)eneral for MAFD.\n\nSupported ABIs are ilp32 (32-bit soft-float), ilp32d (32-bit hard-float),\nilp32f (32-bit with single-precision in registers and double in memory, niche\nuse only), lp64 lp64f lp64d (same but with 64-bit long and pointers).\n\n### Installation (Newlib/Linux multilib)\n\nTo build either cross-compiler with support for both 32-bit and\n64-bit, run the following command:\n\n    ./configure --prefix=/opt/riscv --enable-multilib\n\nAnd then either `make`, `make linux` or `make musl` for the Newlib, Linux\nglibc-based or Linux musl libc-based cross-compiler, respectively.\n\nThe multilib compiler will have the prefix riscv64-unknown-elf- or\nriscv64-unknown-linux-gnu- but will be able to target both 32-bit and 64-bit\nsystems.\nIt will support the most common `-march`/`-mabi` options, which can be seen by\nusing the `--print-multi-lib` flag on either cross-compiler.\n\nLinux toolchain has an additional option `--enable-default-pie` to control the\ndefault PIE enablement for GCC, which is disable by default.\n\nTo customize the enabled languages, use option `--with-languages=`. For example,\nif you want to enable `c,c++,fortran`, use `./configure --with-languages=c,c++,fortran`.\nThis option only takes effect for the GNU toolchain.\n\nThe toolchain has an option `--enable-strip` to control strip of host binaries,\nstrip is disabled by default.\n\n### Troubleshooting Build Problems\n\nBuilds work best if installing into an empty directory.  If you build a\nhard-float toolchain and then try to build a soft-float toolchain with\nthe same --prefix directory, then the build scripts may get confused\nand exit with a linker error complaining that hard float code can't be\nlinked with soft float code.  Removing the existing toolchain first, or\nusing a different prefix for the second build, avoids the problem.  It\nis OK to build one newlib and one linux toolchain with the same prefix.\nBut you should avoid building two newlib or two linux toolchains with\nthe same prefix.\n\nIf building a linux toolchain on a MacOS system, or on a Windows system\nusing the Linux subsystem or cygwin, you must ensure that the filesystem\nis case-sensitive.  A build on a case-insensitive filesystem will fail when\nbuilding glibc because \\*.os and \\*.oS files will clobber each other during\nthe build eventually resulting in confusing link errors.\n\nCentOS (and RHEL) provide old GNU tools versions that may be too old to build\na RISC-V toolchain.  There is an alternate toolset provided that includes\ncurrent versions of the GNU tools.  This is the devtoolset provided as part\nof the Software Collection service.  For more info, see the\n[devtoolset-7](https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/)\nURL.  There are various versions of the devtoolset that are available, so you\ncan also try other versions of it, but we have at least one report that\ndevtoolset-7 works.\n\n### Advanced Options\n\nThere are a number of additional options that may be passed to\nconfigure.  See './configure --help' for more details.\n\nAlso you can define extra flags to pass to specific projects: ```BINUTILS_NATIVE_FLAGS_EXTRA,\nBINUTILS_TARGET_FLAGS_EXTRA, GCC_EXTRA_CONFIGURE_FLAGS, GDB_NATIVE_FLAGS_EXTRA,\nGDB_TARGET_FLAGS_EXTRA, GLIBC_TARGET_FLAGS_EXTRA, NEWLIB_TARGET_FLAGS_EXTRA,\nLLVM_EXTRA_CONFIGURE_FLAGS, QEMU_EXTRA_CONFIGURE_FLAGS```.\nExample: ```GCC_EXTRA_CONFIGURE_FLAGS=--with-gmp=/opt/gmp make linux```\n\n#### Set default ISA spec version\n\n`--with-isa-spec=` can specify the default version of the RISC-V Unprivileged\n(formerly User-Level) ISA specification.\n\nPossible options are: `2.2`, `20190608` and `20191213`.\n\nThe default version is `20191213`.\n\nMore details about this option you can refer this post [RISC-V GNU toolchain bumping default ISA spec to 20191213](https://groups.google.com/a/groups.riscv.org/g/sw-dev/c/aE1ZeHHCYf4).\n\n#### Build with customized multi-lib configure.\n\n`--with-multilib-generator=` can specify what multilibs to build.  The argument\nis a semicolon separated list of values, possibly consisting of a single value.\nCurrently only supported for riscv*-*-elf*.  The accepted values and meanings\nare given below.\n\nEvery config is constructed with four components: architecture string, ABI,\nreuse rule with architecture string and reuse rule with sub-extension.\n\nRe-use part support expansion operator (*) to simplify the combination of\ndifferent sub-extensions, example 4 demonstrate how it uses and works.\n\nExample 1: Add multi-lib support for rv32i with ilp32.\n```\n./configure --with-multilib-generator=\"rv32i-ilp32--\"\n```\n\nExample 2: Add multi-lib support for rv32i with ilp32 and rv32imafd with ilp32.\n\n```\n./configure --with-multilib-generator=\"rv32i-ilp32--;rv32imafd-ilp32--\"\n```\n\nExample 3: Add multi-lib support for rv32i with ilp32; rv32im with ilp32 and\nrv32ic with ilp32 will reuse this multi-lib set.\n```\n./configure --with-multilib-generator=\"rv32i-ilp32-rv32im-c\"\n```\n\nExample 4: Add multi-lib support for rv64ima with lp64; rv64imaf with lp64,\nrv64imac with lp64 and rv64imafc with lp64 will reuse this multi-lib set.\n```\n./configure --with-multilib-generator=\"rv64ima-lp64--f*c\"\n```\n\n#### Enabling QEMU System Targets\n\nThe `--enable-qemu-system` configuration flag allows you to include QEMU system emulation targets in addition to the default user-mode emulation.\n\n- **Enabled targets**:\n  - `riscv64-linux-user`\n  - `riscv32-linux-user`\n  - `riscv64-softmmu`\n  - `riscv32-softmmu`\n\n- **Default targets** (without this flag):\n  - `riscv64-linux-user`\n  - `riscv32-linux-user`\n\nUse this option if you need full system emulation for RISC-V. Example configuration:\n\n```bash\n./configure --enable-qemu-system --prefix=/opt/riscv\nmake build-sim SIM=qemu\n```\n\nThis flag is particularly useful for developers testing and emulating full RISC-V systems rather than just user-space applications.\n\n### Test Suite\n\nThe Dejagnu test suite has been ported to RISC-V. This can be run with a\nsimulator for the elf and linux toolchains. The simulator can be selected\nby the SIM variable in the Makefile, e.g. SIM=qemu, SIM=gdb, or SIM=spike\n(experimental).In addition, the simulator can also be selected with the\nconfigure time option `--with-sim=`.However, the testsuite allowlist is\nonly maintained for qemu.Other simulators might get extra failures.\n\n#### Additional Prerequisite\n\nA helper script to setup testing environment requires\n[pyelftools](https://github.com/eliben/pyelftools).\n\nOn newer versions of Ubuntu, executing the following command\nshould suffice:\n\n    $ sudo apt-get install python3-pyelftools\n\nOn newer versions of Fedora and CentOS/RHEL OS (9 or later), executing\nthe following command should suffice:\n\n    $ sudo yum install python3-pyelftools\n\nOn Arch Linux, executing the following command should suffice:\n\n    $ sudo pacman -Syyu python-pyelftools python-sphinx python-sphinx_rtd_theme ninja\n\nIf your distribution/OS does not have pyelftools package, you can install\nit using PIP.\n\n    # Assuming that PIP is installed\n    $ pip3 install --user pyelftools\n\n#### Testing GCC\n\nTo test GCC, run the following commands:\n\n    ./configure --prefix=$RISCV --disable-linux --with-arch=rv64ima # or --with-arch=rv32ima\n    make newlib\n    make report-newlib SIM=gdb # Run with gdb simulator\n\n    ./configure --prefix=$RISCV\n    make linux\n    make report-linux SIM=qemu # Run with qemu\n\n    ./configure --prefix=$RISCV --with-sim=spike\n    make linux\n    make report               # Run with spike\n\nNote:\n- spike only support rv64* bare-metal/elf toolchain.\n- gdb simulator only support bare-metal/elf toolchain.\n\n#### Selecting the tests to run in GCC's regression test suite\n\nBy default GCC will execute all tests of its regression test suite.\nWhile running them in parallel (e.g. `make -j$(nproc) report`) will\nsignificantly speed up the execution time on multi-processor systems,\nthe required time for executing all tests is usually too high for\ntypical development cycles. Therefore GCC allows to select the tests\nthat are being executed using the environment variable `RUNTESTFLAGS`.\n\nTo restrict a test run to only RISC-V specific tests\nthe following command can be used:\n\n    RUNTESTFLAGS=\"riscv.exp\" make report\n\nTo restrict a test run to only RISC-V specific tests with match the\npattern \"zb*.c\" and \"sm*.c\" the following command can be used:\n\n    RUNTESTFLAGS=\"riscv.exp=zb*.c\\ sm*.c\" make report\n\n#### Testing GCC, Binutils, and glibc of a Linux toolchain\n\nThe default Makefile target to run toolchain tests is `report`.\nThis will run all tests of the GCC regression test suite.\nAlternatively, the following command can be used to do the same:\n\n    make check-gcc\n\nThe following command can be used to run the Binutils tests:\n\n    make check-binutils\n\nThe command below can be used to run the glibc tests:\n\n    make check-glibc-linux\n\n##### Adding more arch/abi combination for testing without introducing multilib\n\n`--with-extra-multilib-test` can be used when you want to test more combination\nof arch/ABI, for example: built a linux toolchain with multilib with\n`rv64gc/lp64d` and `rv64imac/lp64`, but you want to test more configuration like\n`rv64gcv/lp64d` or `rv64gcv_zba/lp64d`, then you can use --with-extra-multilib-test\nto specify that via `--with-extra-multilib-test=\"rv64gcv-lp64d;rv64gcv_zba-lp64d\"`,\nthen the testing will run for `rv64gc/lp64d`, `rv64imac/lp64`, `rv64gcv/lp64d`\nand `rv64gcv_zba/lp64d`.\n\n`--with-extra-multilib-test` support bare-metal and linux toolchain and support\neven multilib is disable, but the user must ensure extra multilib test\nconfiguration can be work with existing lib/multilib, e.g. rv32gcv/ilp32 test\ncan't work if multilib didn't have any rv32 multilib.\n\n`--with-extra-multilib-test` also support more complicated format to fit the\nrequirements of end-users. First of all, the argument is a list of test\nconfigurations. Each test configuration are separated by `;`. For example:\n\n  `rv64gcv-lp64d;rv64_zvl256b_zvfh-lp64d`\n\nFor each test configuration, it has two parts, aka required arch-abi part and\noptional build flags. We leverage `:` to separate them with some restrictions.\n\n  * arch-abi should be required and there must be only one at the begining of\n    the test configuration.\n  * build flags is a array-like flags after the arch-abi, there will be two\n    ways to arrange them, aka AND, OR operation.\n  * If you would like the flags in build flags array acts on arch-abi\n    __simultaneously__, you can use `:` to separate them. For example:\n\n   ```\n   rv64gcv-lp64d:--param=riscv-autovec-lmul=dynamic:--param=riscv-autovec-preference=fixed-vlmax\n   ```\n\n   will be consider as one target board same as below:\n\n   ```\n   riscv-sim/-march=rv64gcv/-mabi=lp64d/-mcmodel=medlow/--param=riscv-autovec-lmul=dynamic/--param=riscv-autovec-preference=fixed-vlmax\n   ```\n\n  * If you would like the flags in build flags array acts on arch-abi\n    __respectively__, you can use ',' to separate them. For example:\n\n   ```\n   rv64gcv-lp64d:--param=riscv-autovec-lmul=dynamic,--param=riscv-autovec-preference=fixed-vlmax\n   ```\n\n   will be consider as two target boards same as below:\n\n   ```\n   riscv-sim/-march=rv64gcv/-mabi=lp64d/-mcmodel=medlow/--param=riscv-autovec-preference=fixed-vlmax\n   riscv-sim/-march=rv64gcv/-mabi=lp64d/-mcmodel=medlow/--param=riscv-autovec-lmul=dynamic\n   ```\n\n  * However, you can also leverage AND(`:`), OR(`,`) operator together but the\n    OR(`,`) will always have the higher priority. For example:\n\n   ```\n   rv64gcv-lp64d:--param=riscv-autovec-lmul=dynamic:--param=riscv-autovec-preference=fixed-vlmax,--param=riscv-autovec-lmul=m2\n   ```\n\n   will be consider as tow target boars same as below:\n\n   ```\n   riscv-sim/-march=rv64gcv/-mabi=lp64d/-mcmodel=medlow/--param=riscv-autovec-lmul=dynamic/--param=riscv-autovec-preference=fixed-vlmax\n   riscv-sim/-march=rv64gcv/-mabi=lp64d/-mcmodel=medlow/--param=riscv-autovec-lmul=m2\n   ```\n\n### LLVM / clang\n\nLLVM can be used in combination with the RISC-V GNU Compiler Toolchain\nto build RISC-V applications. To build LLVM with C and C++ support the\nconfigure flag `--enable-llvm` can be used.\n\nE.g. to build LLVM on top of a RV64 Linux toolchain the following commands\ncan be used:\n\n  ./configure --prefix=$RISCV --enable-llvm --enable-linux\n  make\n\nNote, that a combination of `--enable-llvm` and multilib configuration flags\nis not supported.\n\nBelow are examples how to build a rv64gc Linux/newlib toolchain with LLVM support,\nhow to use it to build a C and a C++ application using clang, and how to\nexecute the generated binaries using QEMU.\n\nBuild Linux toolchain and run examples:\n\n    # Build rv64gc toolchain with LLVM\n    ./configure --prefix=$RISCV --enable-llvm --enable-linux --with-arch=rv64gc --with-abi=lp64d\n    make -j$(nproc) all build-sim SIM=qemu\n    # Build C application with clang\n    $RISCV/bin/clang -march=rv64imafdc -o hello_world hello_world.c\n    $RISCV/bin/qemu-riscv64 -L $RISCV/sysroot ./hello_world\n    # Build C++ application with clang\n    $RISCV/bin/clang++ -march=rv64imafdc -stdlib=libc++ -o hello_world_cpp hello_world_cpp.cxx\n    $RISCV/bin/qemu-riscv64 -L $RISCV/sysroot ./hello_world_cpp\n\nBuild newlib toolchain and run examples (don't work with `--with-multilib-generator=`):\n\n    # Build rv64gc bare-metal toolchain with LLVM\n    ./configure --prefix=$RISCV --enable-llvm --disable-linux --with-arch=rv64gc --with-abi=lp64d\n    make -j$(nproc) all build-sim SIM=qemu\n    # Build C application with clang\n    $RISCV/bin/clang -march=rv64imafdc -o hello_world hello_world.c\n    $RISCV/bin/qemu-riscv64 -L $RISCV/sysroot ./hello_world\n    # Build C++ application with clang using static link\n    $RISCV/bin/clang++ -march=rv64imafdc -static -o hello_world_cpp hello_world_cpp.cxx\n    $RISCV/bin/qemu-riscv64 -L $RISCV/sysroot ./hello_world_cpp\n\n### Development\n\nThis section is only for developer or advanced user, or you want to build\ntoolchain with your own source tree.\n\n#### Update Source Tree\n\n`riscv-gnu-toolchain` contain stable but not latest source for each submodule,\nin case you want to using latest development tree, you can use following command\nto upgrade all submodule.\n\n    git submodule update --remote\n\nOr you can upgrade specific submodule only.\n\n    git submodule update --remote \u003ccomponent\u003e\n\nFor example, upgrade gcc only, you can using following command:\n\n    git submodule update --remote gcc\n\n#### How to Check Which Branch are Used for Specific submodule\n\nThe branch info has recorded in `.gitmodules` file, which can set or update via\n`git submodule add -b` or `git submodule set-branch`.\n\nHowever the only way to check which branch are using is to check `.gitmodules`\nfile, here is the example for `gcc`, it's using releases/gcc-12 branch, so\nit will has a section named `gcc` and has a field `branch` is\n`releases/gcc-12`.\n\n```\n[submodule \"gcc\"]\n        path = gcc\n        url = ../gcc.git\n        branch = releases/gcc-12\n```\n\n#### Use Source Tree Other Than `riscv-gnu-toolchain`\n\n`riscv-gnu-toolchain` also supports using out-of-tree source to build the toolchain.\nThere are several configure options for specifying the source tree of each\nsubmodule/component.\n\nFor example, if you have GCC sources in `$HOME/gcc`, use `--with-gcc-src` to build the toolchain using those sources:\n\n    ./configure ... --with-gcc-src=$HOME/gcc\n\nHere is the list of configure options for specifying alternative sources for the various submodules/components:\n\n    --with-binutils-src\n    --with-dejagnu-src\n    --with-gcc-src\n    --with-gdb-src\n    --with-glibc-src\n    --with-linux-headers-src\n    --with-llvm-src\n    --with-musl-src\n    --with-newlib-src\n    --with-pk-src\n    --with-qemu-src\n    --with-spike-src\n    --with-uclibc-src\n\n#### Build host GCC to check for compiler warnings\n\nGCC contributions have to meet several requirements to qualify for upstream\ninclusion.  Warning free compilation with a compiler build from the same\nsources is among them.  The flag `--enable-host-gcc` does exaclty that:\n\n* Initially a host GCC will be built\n* This host GCC is then used to build the cross compiler\n* The cross compiler will be built with `-Werror` to identify code issues\n\n### FAQ\n#### Ensuring Code Model Consistency\nIf parts of newlib are going to be replaced with an external library (such as with [libgloss-htif](https://github.com/ucb-bar/libgloss-htif) for Berkeley Host-Target Interface),\nyou should take care to ensure that both newlib and the external library are built using the same code model. For more information about RISC-V code models,\n[read this SiFive blog article](https://www.sifive.com/blog/all-aboard-part-4-risc-v-code-models).\n\nErrors that indicate a code model mismatch include \"relocation overflow\" or \"relocation truncated\" errors from the linker being unable to successfully relocate symbols in the executable.\n\nBy default, `riscv-gnu-toolchain` builds newlib with `-mcmodel=medlow`. You can use the alternative `medany` code model (as used in libgloss-htif) by passing `--with-cmodel=medany` to the configure script.\n","funding_links":[],"categories":["C","CPU RISC-V"],"sub_categories":["网络服务_其他"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friscv-collab%2Friscv-gnu-toolchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friscv-collab%2Friscv-gnu-toolchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friscv-collab%2Friscv-gnu-toolchain/lists"}