diff options
| author | Frédéric Desbiens <[email protected]> | 2026-05-27 12:00:47 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-05-27 12:00:47 -0400 |
| commit | 6061c43f96dcaf6b5588861f247dae98493a9eee (patch) | |
| tree | 6da3441e562b4c52218347e5f3b6f315dd3afa90 | |
| parent | 4a7343159b9ed3e470524d83232e4797a0bdf637 (diff) | |
Removed clz.c workaround; use riscv32-unknown-elf toolchain (#538)
bsp/clz.c provided a weak __clzsi2 fallback to work around the missing
rv32 multilib in the riscv-collab riscv64-unknown-elf toolchain. Since
cmake/riscv32-unknown-elf-rv32imc.cmake now uses the dedicated riscv32-
unknown-elf-gcc toolchain (riscv-collab riscv32-elf release), which ships
a native rv32/ilp32 libgcc with all required helpers, the workaround is
no longer needed.
Remove bsp/clz.c and its entry in CMakeLists.txt.
Co-authored-by: Copilot <[email protected]>
| -rw-r--r-- | ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | ports/risc-v32/gnu/example_build/core_v_mcu/bsp/clz.c | 29 |
2 files changed, 0 insertions, 30 deletions
diff --git a/ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt b/ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt index 6946b347..662914d1 100644 --- a/ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt +++ b/ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt @@ -21,7 +21,6 @@ set(SRCS ${CORE_V_MCU_DIR}/crt0.S ${CORE_V_MCU_DIR}/vectors.S ${CORE_V_MCU_DIR}/tx_initialize_low_level.S - ${CORE_V_MCU_DIR}/bsp/clz.c ${CORE_V_MCU_DIR}/bsp/irq.c ${CORE_V_MCU_DIR}/bsp/timer_irq.c ${CORE_V_MCU_DIR}/bsp/fll.c diff --git a/ports/risc-v32/gnu/example_build/core_v_mcu/bsp/clz.c b/ports/risc-v32/gnu/example_build/core_v_mcu/bsp/clz.c deleted file mode 100644 index ef3cb23b..00000000 --- a/ports/risc-v32/gnu/example_build/core_v_mcu/bsp/clz.c +++ /dev/null @@ -1,29 +0,0 @@ -/* clz.c — portable fallback for __clzsi2 (count leading zeros, 32-bit) - * - * The riscv-collab bare-metal toolchain (riscv64-unknown-elf from /opt/riscv) - * is built without multilib and does not ship an rv32/ilp32 libgcc. As a - * result __clzsi2, which GCC emits for __builtin_clz() on targets without a - * hardware CLZ instruction, is missing at link time. - * - * This file provides a weak definition so that the build is self-contained - * with any RISC-V bare-metal toolchain. When a toolchain does ship the symbol - * in libgcc (e.g. the Ubuntu gcc-riscv64-unknown-elf package), the libgcc copy - * will take precedence over this weak one. - */ - -#include <stdint.h> - -__attribute__((weak)) -int __clzsi2(uint32_t x) -{ - if (x == 0U) - return 32; - - int n = 0; - if ((x & 0xFFFF0000U) == 0U) { n += 16; x <<= 16; } - if ((x & 0xFF000000U) == 0U) { n += 8; x <<= 8; } - if ((x & 0xF0000000U) == 0U) { n += 4; x <<= 4; } - if ((x & 0xC0000000U) == 0U) { n += 2; x <<= 2; } - if ((x & 0x80000000U) == 0U) { n += 1; } - return n; -} |
