Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Xcc flags that fixes crash on ESP32-C3. #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions smart-light/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ foreach(dir ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
string(CONCAT SWIFT_INCLUDES ${SWIFT_INCLUDES} "-I${dir} ")
endforeach()

# Set device-specific march/mabi flags
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "esp32c2" OR ${target} STREQUAL "esp32c3")
set(march_flag "rv32imc_zicsr_zifencei")
set(mabi_flag "ilp32")
elseif(${target} STREQUAL "esp32p4")
set(march_flag "rv32imafc_zicsr_zifencei")
set(mabi_flag "ilp32f")
else()
set(march_flag "rv32imac_zicsr_zifencei")
set(mabi_flag "ilp32")
endif()

# Swift compiler flags to build in Embedded Swift mode, optimize for size, choose the right ISA, ABI, C++ language standard, etc.
target_compile_options(${COMPONENT_LIB} PUBLIC "$<$<COMPILE_LANGUAGE:Swift>:SHELL:
-target riscv32-none-none-eabi
Expand All @@ -46,6 +59,8 @@ target_compile_options(${COMPONENT_LIB} PUBLIC "$<$<COMPILE_LANGUAGE:Swift>:SHEL
-Xcc -D_GLIBCXX_HAVE_POSIX_SEMAPHORE
-Xcc -D_GLIBCXX_USE_POSIX_SEMAPHORE
-Xcc -D_POSIX_READER_WRITER_LOCKS
-Xcc -march=${march_flag}
-Xcc -mabi=${mabi_flag}

-pch-output-dir /tmp
-Xfrontend -enable-single-module-llvm-emission
Expand Down