yf13 commented on PR #11579: URL: https://github.com/apache/nuttx/pull/11579#issuecomment-1905135371
@anchao it seems still not fine with stock toolchain here. Here are the version I am using compared with the version on master: ``` $ $ git diff b46ee08230 diff --git a/arch/risc-v/src/cmake/Toolchain.cmake b/arch/risc-v/src/cmake/Toolchain.cmake index a8abb18460..1263c107ac 100644 --- a/arch/risc-v/src/cmake/Toolchain.cmake +++ b/arch/risc-v/src/cmake/Toolchain.cmake @@ -271,27 +271,27 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG) # These models can't cover all implementation of RISCV, but it's enough for # most cases. - set(PLATFORM_FLAGS) + set(LLVM_CPUFLAGS) if(CONFIG_ARCH_RV32) if(${ARCHCPUEXTFLAGS} STREQUAL imc) - list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20) + list(APPEND LLVM_CPUFLAGS -mcpu=sifive-e20) elseif(${ARCHCPUEXTFLAGS} STREQUAL imac) - list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31) + list(APPEND LLVM_CPUFLAGS -mcpu=sifive-e31) elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc) - list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76) + list(APPEND LLVM_CPUFLAGS -mcpu=sifive-e76) endif() else() if(${ARCHCPUEXTFLAGS} STREQUAL imac) - list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51) + list(APPEND LLVM_CPUFLAGS -mcpu=sifive-s51) elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc) - list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54) + list(APPEND LLVM_CPUFLAGS -mcpu=sifive-u54) endif() endif() - list(APPEND PLATFORM_FLAGS ${ARCHCPUFLAGS}) + list(APPEND LLVM_CPUFLAGS ${ARCHCPUFLAGS}) - add_compile_options(${PLATFORM_FLAGS}) + add_compile_options(${LLVM_CPUFLAGS}) endif() diff --git a/arch/risc-v/src/cmake/platform.cmake b/arch/risc-v/src/cmake/platform.cmake index 79893f8388..404371d390 100644 --- a/arch/risc-v/src/cmake/platform.cmake +++ b/arch/risc-v/src/cmake/platform.cmake @@ -21,8 +21,10 @@ get_directory_property(NUTTX_EXTRA_FLAGS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_OPTIONS) +separate_arguments(LIBPRT_CFLAGS NATIVE_COMMAND ${CMAKE_C_FLAGS}) + execute_process( - COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS} + COMMAND ${CMAKE_C_COMPILER} ${LIBPRT_CFLAGS} ${NUTTX_EXTRA_FLAGS} --print-libgcc-file-name OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE extra_library) @@ -31,7 +33,7 @@ list(APPEND EXTRA_LIB ${extra_library}) if(NOT CONFIG_LIBM) execute_process( - COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS} + COMMAND ${CMAKE_C_COMPILER} ${LIBPRT_CFLAGS} ${NUTTX_EXTRA_FLAGS} --print-file-name=libm.a OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE extra_library) @@ -40,7 +42,7 @@ endif() if(CONFIG_LIBSUPCXX) execute_process( - COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS} + COMMAND ${CMAKE_C_COMPILER} ${LIBPRT_CFLAGS} ${NUTTX_EXTRA_FLAGS} --print-file-name=libsupc++.a OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE extra_library) @@ -49,7 +51,7 @@ endif() if(CONFIG_ARCH_COVERAGE) execute_process( - COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS} + COMMAND ${CMAKE_C_COMPILER} ${LIBPRT_CFLAGS} ${NUTTX_EXTRA_FLAGS} --print-file-name=libgcov.a OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE extra_library) ``` These changes are following what you suggested, but stock toolchain still doesn't work here: ``` $ rm -rf * && cmake -S ~/Projects/Nuttx/nuttx/ -DBOARD_CONFIG=rv-virt/nsh64 -- Initializing NuttX -- Board: rv-virt -- Config: nsh64 -- Appdir: /home/yf/Projects/Nuttx/nuttx/../apps -- The C compiler identification is GNU 10.2.0 -- The CXX compiler identification is GNU 10.2.0 -- The ASM compiler identification is GNU -- Found assembler: /usr/bin/riscv64-unknown-elf-gcc riscv64-unknown-elf-gcc: error: unrecognized command-line option '-mcpu=sifive-u54' riscv64-unknown-elf-gcc: error: unrecognized command-line option '-mcpu=sifive-u54' -- Configuring done -- Generating done -- Build files have been written to: /home/yf/tmp/aaa ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org