Skip to content

Add initial big-endian support#1812

Merged
cmuellner merged 4 commits intoriscv-collab:masterfrom
aleksapaunovic-htec:be-fixes-ready
Mar 12, 2026
Merged

Add initial big-endian support#1812
cmuellner merged 4 commits intoriscv-collab:masterfrom
aleksapaunovic-htec:be-fixes-ready

Conversation

@aleksapaunovic-htec
Copy link
Contributor

This series adds initial big-endian support:

  • Add --with-endian flag.
  • GCC currently doesn't support RVV in big-endian mode. Therefore, we remove the rv64gcv-lp64d multilib option when building the Linux toolchain.

We are working on upstreaming GDB and GCC changes as well. The GDB changes are required for running big-endian tests, as QEMU currently has no big-endian support.

Copy link
Collaborator

@cmuellner cmuellner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for providing this PR!

Besides the issue with the linux headers, I have two more comments:

  • We should probaby add at least one CI/CD job to build a BE toolchain
  • What is the status of the GCC testsuite when building a BE toolchain?

#ifndef _ASM_RISCV_BYTEORDER_H
#define _ASM_RISCV_BYTEORDER_H

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All linux headers are copied without modification as we don't want downstream changes here.
If we add such non-upstream changes, then there is a risk of breaking the BE build each time we update the linux headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I will be removing the commit for now. We will try upstreaming this in the future.

@aleksapaunovic-htec
Copy link
Contributor Author

Hi Christoph,

* We should probaby add at least one CI/CD job to build a BE toolchain

Agreed!

* What is the status of the GCC testsuite when building a BE toolchain?

A lot of the tests implicitly depend on RVV being supported in the compiler, generating a lot of noise when running tests. We have been going through the logs over the last few days, and this appears to be the major difference between BE and LE runs. Actually confirming and fixing this will probably take some time though.

Thank you for taking the time to review this PR!

@aleksapaunovic-htec
Copy link
Contributor Author

Last week, we sent the v2 of the GCC patch series mentioned above. We tried solving the lack of RVV support and subsequent self-test failures by disabling self-tests within the GCC codebase. However, the maintainers prefer a workaround to disable self-tests in the config. Therefore, I added a commit that should address this issue.

Also, we received a comment regarding our usage of gdb-sim for testing. Although we did manage to run the majority of non-RVV-related tests on gdb-sim, it seems that QEMU is the preferred tool for RISC-V testing. We will be focusing on that in the future.
Current GCC testsuite fixes rely on marking RVV-dependent tests as 'unsupported', which I hope we will be able to upstream in the future (or, more optimistically, that we will have a working RVV extension in the future).

djtodoro and others added 4 commits February 25, 2026 16:11
GCC currently does not support the RISC-V Vector Extension
on big-endian builds, which causes the stage1 self-tests to fail.
Disabling them is a temporary fix, until we get RVV working on
big-endian systems.
@aleksapaunovic-htec
Copy link
Contributor Author

@cmuellner Do you have any additional comments on these changes?

P.S. I noticed we had a minor conflict in the README, so I fixed that and rebased the series.

@cmuellner
Copy link
Collaborator

Looks fine now. Let's see what the CI/CD results are.
If everything is fine, we can land this.

Copy link
Collaborator

@cmuellner cmuellner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cmuellner cmuellner merged commit 98c8ec4 into riscv-collab:master Mar 12, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants