This has been tested with gcc trunk on openSUSE Tumbleweed on the HiFive Unleashed.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/cmake/config-ix.cmake | ||
---|---|---|
259 | Although 32-bit support for Linux on RISC-V has lagged, you can build and boot a 32-bit kernel and it will eventually be more mainstream. Is the reason for not adding RISCV32 here that it was only tested on the HiFive Unleashed? It's possible to get prebuilt 32-bit disk images (and patches to build them yourself) that can be tested with, for instance, QEMU. See for instance [1]. Also, I don't know how problematic it would be to add RISCV32 to the list without testing. |
compiler-rt/cmake/config-ix.cmake | ||
---|---|---|
259 | The riscv32 ABI isn't finalized yet. |
I have two comments/queries below.
I don't feel it's an issue that this doesn't support RISC-V 32, though the patch title and summary should be updated to reflect this, and a build requesting risc-v 32 should hard error.
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp | ||
---|---|---|
411 | What's the justification here? I'm not familiar with the sanitizer syscall interface, but it would be good to have a comment explaining why risc-v is the only architecture that doesn't use rename or renameat. | |
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h | ||
98 | Please can you confirm that this will cause build errors if __riscv_xlen is 32 (like it will in sanitizer_platform_limits_posix.cpp)? |
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp | ||
---|---|---|
411 | renameat is obsolete, renameat2 is the new generic default. | |
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h | ||
98 | A definition of struct_kernel_stat_sz and struct_kernel_stat64_sz is required. That's how you find out that this needs porting. |
@schwab Sorry there's been a delay reviewing this. I think it's probably fallen down the crack between "people who are familiar with RISC-V", and "people who are familiar with the sanitizers".
On the RISC-V side, I think @luismarques is your guy, so I've named him as a reviewer. Please also find someone from the sanitizers team who can review this work.
I had to revert this in rL375136. Due to some build failures. I need to investigate exactly what the issue is.
I now think it was unrelated, but I'm not sure. I now have a setup where I can build the sanitizers, I think, so I'm just about to test the patch myself before pushing to the builders.
I think I've found the error. Comment inline
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp | ||
---|---|---|
1980 | I'm getting compiler errors around these accesses. My sysroot thinks that __gregs isn't a field in this struct, it thinks the field is gregs (It's pointing to /opt/riscv-gcc-toolchain/sysroot/usr/include/bits/sigcontext.h:28:17 as the declaration for the gregs field. I think this is the version of that file on github: https://github.com/riscv/riscv-glibc/blob/06983fe/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h#L27 (that git version matches the one used by https://github.com/riscv/riscv-gnu-toolchain) |
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp | ||
---|---|---|
1980 | Don't use the obsolete riscv-glibc. The official glibc sources are on sourceware.org. |
Ok, It took several days of fighting crosstool-ng, but I finally have a riscv64-unknown-linux-gnu toolchain with glibc 2.30.
I'm happy this builds. I'm going to re-land the patch now. Sorry for the delay.
Hello,Can you tell me the resaon why it wasn't support for risc-v before ? Why not add the support for rv32 this time?
Just not one had yet put the work to explicitly support it, and be sure that was being done properly --- no deeper reason than that. Regarding riscv32, these is the sanitizer support for Linux, and Linux's RV32 support is being worked on. In particular, there are ABI issues that should be resolved now to avoid the year 2038 problem, and not cause breaking changes to address that at a later point.
Although 32-bit support for Linux on RISC-V has lagged, you can build and boot a 32-bit kernel and it will eventually be more mainstream. Is the reason for not adding RISCV32 here that it was only tested on the HiFive Unleashed? It's possible to get prebuilt 32-bit disk images (and patches to build them yourself) that can be tested with, for instance, QEMU. See for instance [1]. Also, I don't know how problematic it would be to add RISCV32 to the list without testing.
[1] https://bellard.org/tinyemu/buildroot.html (Download section, etc.)