Skip to content

Commit 991a9b3

Browse files
committed
esp: add march and mabi flags for all riscv chips
1 parent 52eb879 commit 991a9b3

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

esp32-led-blink-sdk/main/CMakeLists.txt

+22
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1+
2+
13
idf_component_register(
24
SRCS "Dummy.c"
35
INCLUDE_DIRS "."
46
)
57

8+
idf_build_get_property(target IDF_TARGET)
9+
idf_build_get_property(arch IDF_TARGET_ARCH)
10+
11+
if("${arch}" STREQUAL "xtensa")
12+
message(FATAL_ERROR "Not supported target: ${target}")
13+
endif()
14+
15+
if(${target} STREQUAL "esp32c2" OR ${target} STREQUAL "esp32c3")
16+
set(march_flag "rv32imc_zicsr_zifencei")
17+
set(mabi_flag "ilp32")
18+
elseif(${target} STREQUAL "esp32p4")
19+
set(march_flag "rv32imafc_zicsr_zifencei")
20+
set(mabi_flag "ilp32f")
21+
else()
22+
set(march_flag "rv32imac_zicsr_zifencei")
23+
set(mabi_flag "ilp32")
24+
endif()
25+
626
execute_process(COMMAND xcrun -f swiftc OUTPUT_VARIABLE SWIFTC OUTPUT_STRIP_TRAILING_WHITESPACE)
727

828
add_custom_command(
@@ -11,6 +31,8 @@ add_custom_command(
1131
${SWIFTC}
1232
-target riscv32-none-none-eabi
1333
-Xfrontend -function-sections -enable-experimental-feature Embedded -wmo -parse-as-library -Osize
34+
-Xcc -march=${march_flag} -Xcc -mabi=${mabi_flag}
35+
-Xlinker -march=${march_flag} -Xlinker -mabi=${mabi_flag}
1436
$$\( echo '$<TARGET_PROPERTY:__idf_main,INCLUDE_DIRECTORIES>' | tr '\;' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \)
1537
$$\( echo '${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}' | tr ' ' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \)
1638
-import-bridging-header ${CMAKE_CURRENT_LIST_DIR}/BridgingHeader.h

esp32-led-strip-sdk/main/CMakeLists.txt

+22
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1+
2+
13
idf_component_register(
24
SRCS "Dummy.c"
35
INCLUDE_DIRS "."
46
)
57

8+
idf_build_get_property(target IDF_TARGET)
9+
idf_build_get_property(arch IDF_TARGET_ARCH)
10+
11+
if("${arch}" STREQUAL "xtensa")
12+
message(FATAL_ERROR "Not supported target: ${target}")
13+
endif()
14+
15+
if(${target} STREQUAL "esp32c2" OR ${target} STREQUAL "esp32c3")
16+
set(march_flag "rv32imc_zicsr_zifencei")
17+
set(mabi_flag "ilp32")
18+
elseif(${target} STREQUAL "esp32p4")
19+
set(march_flag "rv32imafc_zicsr_zifencei")
20+
set(mabi_flag "ilp32f")
21+
else()
22+
set(march_flag "rv32imac_zicsr_zifencei")
23+
set(mabi_flag "ilp32")
24+
endif()
25+
626
execute_process(COMMAND xcrun -f swiftc OUTPUT_VARIABLE SWIFTC OUTPUT_STRIP_TRAILING_WHITESPACE)
727

828
add_custom_command(
@@ -11,6 +31,8 @@ add_custom_command(
1131
${SWIFTC}
1232
-target riscv32-none-none-eabi
1333
-Xfrontend -function-sections -enable-experimental-feature Embedded -wmo -parse-as-library -Osize
34+
-Xcc -march=${march_flag} -Xcc -mabi=${mabi_flag}
35+
-Xlinker -march=${march_flag} -Xlinker -mabi=${mabi_flag}
1436
$$\( echo '$<TARGET_PROPERTY:__idf_main,INCLUDE_DIRECTORIES>' | tr '\;' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \)
1537
$$\( echo '${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}' | tr ' ' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \)
1638
-import-bridging-header ${CMAKE_CURRENT_LIST_DIR}/BridgingHeader.h

0 commit comments

Comments
 (0)