-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add support to build a host GCC for building the toolchain #1423
Conversation
A significant amount of users of this project are using it for toolchain development. These users need to ensure that their code is warning free before submitting it upstream. Let's support this use case by adding a configure flag '--enable-host-gcc', which does exactly that: * build a host GCC before building other components * setting PATH such that this new GCC is used to build the cross toolchain * enable -Werror for the GCC build This patch was tested on a Fedora 39 machine (GCC 13), with the following modification in a GCC source file: #if __GNUC__ == 13 #error Host compiler in use! #endif This fails when building without the new flag and does not fail when building with latest upstream/master (GCC 14 prerelease). The '--enable-werror-always' was tested with a warning that showed up recently in upstream GCC. Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Hi @cmuellner - can you expand on why and when this (building the host GCC compiler from scratch) is necessary? It's not clear to me and it seems very onerous - building the RISC-V toolchain already takes quite a long time in many cases (and a looooong time when it's LLVM!). Why won't just getting a recent (e.g. GCC 13 at the time of writing) host GCC toolchain suffice? |
For upstream contributions to GCC a bootstrap build and executing all tests of the regression test suite is a must (see https://gcc.gnu.org/contribute.html). Bootstrapping means building a stage 1 compiler, which then builds the actual GCC. Really performant RISC-V CPUs are still rare (and often used for work other than simple QA checks). Therefore, these builds/tests are usually run on x86_64/QEMU (system or user-mode emulation), but that takes several hours to complete. Cross-compiling is a solution for that issue because we avoid QEMU for everything except executing the test binaries. And the way this is done in this PR is close to a bootstrap build. Using a "recent" GCC is insufficient because there might be a change in the warning behavior of GCC in every commit. The trigger for all this was a patch from somebody that was reviewed and approved by a maintainer, which I picked up for final testing and pushing. I did not run a bootstrap build because I was too impatient (and did not want to block my machine for several hours), but only a |
Hi @cmuellner - thanks for the thorough explanation. Much appreciated. |
@kito-cheng ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, That's really useful!
A significant amount of users of this project are using it for toolchain development. These users need to ensure that their code is warning free before submitting it upstream. Let's support this use case by adding a configure flag '--enable-host-gcc', which does exactly that:
This patch was tested on a Fedora 39 machine (GCC 13), with the following modification in a GCC source file:
This fails when building without the new flag and does not fail when building with latest upstream/master (GCC 14 prerelease).
The '--enable-werror-always' was tested with a warning that showed up recently in upstream GCC.