-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
cross compiling for RISCV32 fails as compiler flags are not supplied by board but must be in target.cmake #17743
Comments
@SebastianBoe can you help here? |
Hi, a patch to this effect submitted as a PR would be welcome. Although perhaps it should be applied in zephyr/arch/riscv32/CMakeLists.txt to be consistent with how the -mabi and -march is set in ARM. |
Is this still an issue with the recent qemu_riscv64 merge we now set these flags: https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/compiler/gcc/target.cmake#L72 |
Thanks. There is still an issue, though it appears to be specific to cross compiling with the GCC 8.2.0 packaged in SiFive FreedomStudio-4.7.2.2019-05.0-win32. The above change to target.cmake uses -mabi=ilp32 -march=rv32ima however SiFive doesn't have a GCC library for rv32ima. (It does have rv32i, rv32im, rv32imac, rv32imafc...) |
Does Pull Request #23265 solve this? |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
I still see this issue when using the SiFive GNU Embedded Toolchain v2020.12.8 and release v2.7.1. Please reopen this issue. |
Closing -- please reopen if it reproduces on an officially supported toolchain |
Describe the bug
When cross-compiling the Zephyr hello world sample on Windows 10 using Freedom Studio 4.7.2 2019-03, which includes riscv64-unknown-elf-gcc-8.2.0-2019.02.0, for a SiFive HiFive1 rev B board, ninja reports compiler warnings on pointer/int conversion and the link step fails due to ABI incompatibility. This is because the compiler flags needed for RISCV32 are not being supplied to gcc. Freedom Studio's gcc can compile for either 64 or 32 but defaults to 64 I had thought that would be set for the board, but the board file was being loaded too late and was not taking effect.
Similarly, changing zephyr/arch/riscv/CMakeLists.txt did not seem to address the issue either. I believe this is because zephyr/cmake/compiler/gcc/target.cmake has
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
to determine the gcc directory for TOOLCHAIN_LIBS, but zephyr/arch/riscv/CMakeLists.txt is not parsed until later.
I was able to work around this issue by changing the zephyr/cmake/compiler/gcc/target.cmake file and adding at about line 72, after the other two architecture specific compiler flag sections, and before the reference to TOOLCHAIN_C_FLAGS:
To Reproduce
Steps to reproduce the behavior:
set CROSS_COMPILE=C:/.../FreedomStudio-4.7.2.2019-03-4/SiFive/toolchain/riscv64-unknown-elf-gcc-8.2.0-2019.02.0/bin/riscv64-unknown-elf-
target emulation
elf64-littleriscv' does not match
elf32-littleriscv'Expected behavior
Compiles to an ELF file for RISCV32.
Impact
Would prefer if those compiler flags were in target.cmake in Zephyr for RISCV32, similar to ARM architecture.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: