Skip to content

Add RISC-V target detection#156

Open
carlosqwqqwq wants to merge 1 commit into
aklomp:masterfrom
carlosqwqqwq:riscv-base64
Open

Add RISC-V target detection#156
carlosqwqqwq wants to merge 1 commit into
aklomp:masterfrom
carlosqwqqwq:riscv-base64

Conversation

@carlosqwqqwq

Copy link
Copy Markdown

Why

base64 did not recognize RISC-V explicitly in its CMake target detection, so riscv configurations could depend on generic fallback behavior and unclear SIMD exclusion. This patch makes the baseline RISC-V path explicit while keeping the existing portable codec path.

What changed

  • Detect RISC-V targets in the CMake architecture probe through __riscv and __riscv_xlen.
  • Recognize riscv64, rv64, riscv32, rv32, and generic riscv* values from CMAKE_SYSTEM_PROCESSOR.
  • Generate BASE64_TARGET_RISCV for RISC-V CMake configurations.
  • Keep RISC-V builds on the existing portable codec path, with SSE, AVX, AVX-512, NEON32, and NEON64 disabled.

Verification

  • Ran native CMake configuration with tests and CLI enabled: cmake -S . -B build-codex-native -DBASE64_BUILD_TESTS=ON -DBASE64_BUILD_CLI=ON -DBASE64_WERROR=OFF.
  • Built the native project successfully with cmake --build build-codex-native --parallel 2.
  • Ran ctest --test-dir build-codex-native --output-on-failure; both test_base64 and benchmark passed.
  • Ran simulated RISC-V CMake configuration with CMAKE_SYSTEM_NAME=Linux, CMAKE_SYSTEM_PROCESSOR=riscv64, and CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY.
  • Built the simulated RISC-V portable static library successfully with cmake --build build-codex-riscv64-4 --parallel 2.
  • Checked generated config.h: BASE64_TARGET_RISCV=1; BASE64_WITH_SSSE3, BASE64_WITH_SSE41, BASE64_WITH_SSE42, BASE64_WITH_AVX, BASE64_WITH_AVX2, BASE64_WITH_AVX512, BASE64_WITH_NEON32, and BASE64_WITH_NEON64 were all 0.
  • Checked compile_commands.json: no -mavx, -mssse3, -msse4, -mfpu=neon, -march=arm, or /arch:AVX flags were present.

Notes

This is a conservative CMake portability patch. It does not add RVV codecs or RISC-V-specific Base64 SIMD acceleration. A real riscv64 cross-build or hardware run was not performed on the local Windows host because no RISC-V toolchain is available here.

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.

1 participant