Skip to content

Updates to RISC-V compiler selection (prefer gcc-riscv32-pico-elf and maximum -march opts)#2921

Open
kilograham wants to merge 4 commits intodevelopfrom
riscv-compiler
Open

Updates to RISC-V compiler selection (prefer gcc-riscv32-pico-elf and maximum -march opts)#2921
kilograham wants to merge 4 commits intodevelopfrom
riscv-compiler

Conversation

@kilograham
Copy link
Copy Markdown
Contributor

Make gcc-riscv32-pico-elf the preferred compiler, and add support for trying different compiler flags until supported ones are found (we try more aggressive -march for RISC-V then less aggressive)

… trying different compiler flags until supported ones are found (we try more aggressive -march for RISC-V then less aggressive)
@kilograham kilograham added this to the 2.2.1 milestone May 1, 2026
@kilograham kilograham requested review from Wren6991 and will-v-pi May 1, 2026 23:39
Comment thread cmake/preload/toolchains/util/find_compiler.cmake Outdated
Comment thread cmake/preload/toolchains/util/find_compiler.cmake Outdated
Comment thread cmake/preload/toolchains/util/find_compiler.cmake Outdated
@will-v-pi
Copy link
Copy Markdown
Contributor

You can fix the bazel checks by adding */empty.c to the IGNORED_FILE_PATTERNS in tools/check_source_files_in_bazel_build.py - unfortunately cmake/** doesn't work because match doesn't support the recursive wildcard, and full_match was only added in python 3.13

set(NULL_DEVICE "/dev/null")
endif()
foreach(flags IN LISTS ${common_lang_flags_var_list})
separate_arguments(COMPILER_CMD NATIVE_COMMAND "${compiler_path} ${flags} -x c -c ${CMAKE_CURRENT_LIST_DIR}/empty.c -o ${NULL_DEVICE}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The path needs quoting as it may contain spaces, which then throws the error:

riscv32-unknown-elf-gcc.exe: fatal error: cannot specify '-o' with '-c', '-S' or '-E' with multiple files
Suggested change
separate_arguments(COMPILER_CMD NATIVE_COMMAND "${compiler_path} ${flags} -x c -c ${CMAKE_CURRENT_LIST_DIR}/empty.c -o ${NULL_DEVICE}")
separate_arguments(COMPILER_CMD NATIVE_COMMAND "${compiler_path} ${flags} -x c -c \"${CMAKE_CURRENT_LIST_DIR}/empty.c\" -o ${NULL_DEVICE}")

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