You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "yf13 (via GitHub)" <gi...@apache.org> on 2024/01/22 08:59:21 UTC
[PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
yf13 opened a new pull request, #11579:
URL: https://github.com/apache/nuttx/pull/11579
## Summary
Ubuntu stock toolchain complains about current CMake scripts as in issue#11573. This patch revises risc-v/cmake logic so that users of stock toolchain can enjoy CMake build system.
The change doesn't affect XPack toolchain uses.
## Impact
risc-v cmake toolchain users
## Testing
checked with `rv-virt/nsh(64` for both XPack and stock toolchain.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461755662
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
Review Comment:
a second thought, please just replace the PLATFORM_FLAGS to LLVM_CPUTYPE, which will solve your issue
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #11579:
URL: https://github.com/apache/nuttx/pull/11579
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#issuecomment-1905082178
> 1. Changes in `Toolchain.cmake`: a) remove the GCC_VERSION guard, b) replacing PLATFORM_FLAGS to LLVM_CPUTYPE.
> 2. Changes in `platform.cmake`: remove the GCC_VERSION guard to revert back to original.
changes 1 is correct, regarding changes 2, it should be that cmake cannot recognize the string type of `CMAKE_C_FLAGS`. You can perform `separate_arguments()` before executing gcc commands:
```
diff --git a/arch/risc-v/src/cmake/platform.cmake b/arch/risc-v/src/cmake/platform.cmake
index 79893f8388..e1c0e4047a 100644
--- a/arch/risc-v/src/cmake/platform.cmake
+++ b/arch/risc-v/src/cmake/platform.cmake
@@ -21,17 +21,20 @@
get_directory_property(NUTTX_EXTRA_FLAGS DIRECTORY ${CMAKE_SOURCE_DIR}
COMPILE_OPTIONS)
+separate_arguments(CMAKE_C_FLAG_ARGS NATIVE_COMMAND ${CMAKE_C_FLAGS})
+
execute_process(
- COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
+ COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-libgcc-file-name
OUTPUT_STRIP_TRAILING_WHITESPACE
+ COMMAND_ECHO STDOUT
OUTPUT_VARIABLE extra_library)
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} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libm.a
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_library)
@@ -40,7 +43,7 @@ endif()
if(CONFIG_LIBSUPCXX)
execute_process(
- COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
+ COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libsupc++.a
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_library)
@@ -49,7 +52,7 @@ endif()
if(CONFIG_ARCH_COVERAGE)
execute_process(
- COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
+ COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_library)
@@ -58,5 +61,4 @@ endif()
nuttx_add_extra_library(${EXTRA_LIB})
-separate_arguments(CMAKE_C_FLAG_ARGS NATIVE_COMMAND ${CMAKE_C_FLAGS})
set(PREPROCES ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} -E -P -x c)
```
In addition, please also apply relevant changes to arm/arm64 architecture.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461722873
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
Review Comment:
emm... It seems that risc-v does not add clang-related build rules. This part is only supported in arm.
https://github.com/apache/nuttx/blob/2ec36fa7bd945f4cb3613bdb558f297874db3217/arch/arm/src/cmake/Toolchain.cmake#L46-L57
already, forget it, let us merge this PR.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461818193
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
+ if(CONFIG_ARCH_RV32)
+ if(${ARCHCPUEXTFLAGS} STREQUAL imc)
+ list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
Review Comment:
@anchao sorry for late response, I was away.
Did you mean that we only replace PLATFORM_FLAGS with LLVM_CPUTYPE in Toolchains.cmake and no need for the change in platform.cmake?
I will give it a test here locally, if you share how to use Clang, I can also give Clang a check.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461702600
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
Review Comment:
Thanks for pointing it out, will check.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461702600
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
Review Comment:
@anchao thanks for pointing it out, I will check.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461592590
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
Review Comment:
This will break clang based toolchain, maybe you can refer to the Makefile base and just add these options to LLVM_CPUTYPE attribute:
https://github.com/apache/nuttx/blob/master/arch/risc-v/src/common/Toolchain.defs#L235-L257
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461702600
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
Review Comment:
@anchao how to rewrite the rule to support both CLANG and GCC12+ explicitly? Which MACRO depicts CLANG toolchain now?
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#issuecomment-1903984040
@anchao, I did a few changes but none can pass local check with Stock and Xpack gcc toolchains here.
1) Changes on `Toolchain.cmake`: a) remove the GCC_VERSION guard, b) replaceing the PLATFORM_FLAGS to LLVM_CPUTYPE in that file.
2) Channegs on `platform.cmake`: remove the GCC_VERSION guard
With these two changes, the stock toolchain complains about the CMAKE_C_FLAGS added in `platform.cmake`.
When I skipped 2) and only keep change 1), both stock toolchain and XPack works here for `rv-virt/nsh`. But stock toolchain failed with `rv-virt/nsh64` with `riscv64-unknown-elf-gcc: error: unrecognized command-line option '-mcpu=sifive-u54'`
So it seems things are not better than my original change.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "yf13 (via GitHub)" <gi...@apache.org>.
yf13 commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461818193
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
+ if(CONFIG_ARCH_RV32)
+ if(${ARCHCPUEXTFLAGS} STREQUAL imc)
+ list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
Review Comment:
@anchao sorry for late response, I was away.
Did you mean that we only replace PLATFORM_FLAGS with LLVM_CPUTYPE in Toolchains.cmake and no need for the change in platform.cmake?
I will give it a test here locally, if you share how to use Clang, I can also give it a check.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "yf13 (via GitHub)" <gi...@apache.org>.
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#issuecomment-1905202146
@yf13 add LLVM_CPUTYPE to the compile option is unnecessary, please revert the following changes and keep LLVM_CPUTYPE usage with makefile base.
```
- list(APPEND PLATFORM_FLAGS ${ARCHCPUFLAGS})
+ list(APPEND LLVM_CPUFLAGS ${ARCHCPUFLAGS})
- add_compile_options(${PLATFORM_FLAGS})
+ add_compile_options(${LLVM_CPUFLAGS})
```
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461758819
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
+ if(CONFIG_ARCH_RV32)
+ if(${ARCHCPUEXTFLAGS} STREQUAL imc)
+ list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
Review Comment:
```suggestion
list(APPEND LLVM_CPUTYPE -mcpu=sifive-e20)
```
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461755905
##########
arch/risc-v/src/cmake/platform.cmake:
##########
@@ -21,8 +21,20 @@
get_directory_property(NUTTX_EXTRA_FLAGS DIRECTORY ${CMAKE_SOURCE_DIR}
COMPILE_OPTIONS)
+# Ubuntu gcc-riscv64-unknown-elf toolchain complains when ${CMAKE_C_FLAGS} used
Review Comment:
revert
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
Review Comment:
a second thought, please just please PLATFORM_FLAGS to LLVM_CPUTYPE, which will solve your issue
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] risc-v/cmake: add support for Ubuntu stock toolchain [nuttx]
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #11579:
URL: https://github.com/apache/nuttx/pull/11579#discussion_r1461722873
##########
arch/risc-v/src/cmake/Toolchain.cmake:
##########
@@ -273,19 +273,24 @@ if(${CONFIG_RISCV_TOOLCHAIN} STREQUAL GNU_RVG)
set(PLATFORM_FLAGS)
- if(CONFIG_ARCH_RV32)
- if(${ARCHCPUEXTFLAGS} STREQUAL imc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e20)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e31)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-e76)
- endif()
- else()
- if(${ARCHCPUEXTFLAGS} STREQUAL imac)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-s51)
- elseif(${ARCHCPUEXTFLAGS} STREQUAL imafdc)
- list(APPEND PLATFORM_FLAGS -mcpu=sifive-u54)
+ # Ubuntu gcc-riscv64-unknown-elf complains about options below so only use
+ # them for higher version toolchain
+
+ if(GCC_VERSION GREATER_EQUAL 12)
Review Comment:
emm... It seems that risc-v does not add clang-related build rules. This part is only supported in arm.
https://github.com/apache/nuttx/blob/2ec36fa7bd945f4cb3613bdb558f297874db3217/arch/arm/src/cmake/Toolchain.cmake#L46-L57
alright, forget it, let us merge this PR.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org