diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml index dbc8e9190814..4255a189a9b2 100644 --- a/.gitlab/ci/build.yml +++ b/.gitlab/ci/build.yml @@ -156,11 +156,12 @@ build_clang_test_apps_esp32s3: extends: - .build_cmake_clang_template variables: - # For RISCV clang generates '.linker-options' sections of type 'llvm_linker_options' in asm files. - # See (https://llvm.org/docs/Extensions.html#linker-options-section-linker-options). - # Binutils gas ignores them with warning. - # TODO: LLVM-333, Use integrated assembler. - TEST_BUILD_OPTS_EXTRA: "--ignore-warning-str 'Warning: unrecognized section type'" + # https://reviews.llvm.org/D90108. + # GNU 'as' lets .weak override .globl since binutils-gdb + # https://github.com/bminor/binutils-gdb/commit/5ca547dc2399a0a5d9f20626d4bf5547c3ccfddd (1996) + # while MC lets the last directive win (PR38921). + # For RISCV chips we use integrated assembler by default, so suppress this warning to pass CI pipeline. + TEST_BUILD_OPTS_EXTRA: "--ignore-warning-str 'changed binding to STB_WEAK'" build_clang_test_apps_esp32c3: extends: diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S b/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S index b737e58d7c2a..5f32c613a00b 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S @@ -441,7 +441,7 @@ rtos_current_tcb: lw a0, pxCurrentTCBs #endif /* ( configNUM_CORES > 1 ) */ ret - .size, .-rtos_current_tcb + .size rtos_current_tcb, .-rtos_current_tcb /** diff --git a/components/riscv/vectors.S b/components/riscv/vectors.S index 058877f8ed69..d97ad7f83d47 100644 --- a/components/riscv/vectors.S +++ b/components/riscv/vectors.S @@ -21,7 +21,14 @@ #if ( SOC_CPU_COPROC_NUM > 0 ) /* Targets with coprocessors present a special CSR to get Illegal Instruction exception reason */ +#ifdef __clang__ + /* Clang does not support constant declared via `equ` as operand for csrrw + * TODO: LLVM-369 + */ + #define EXT_ILL_CSR 0x7F0 +#else .equ EXT_ILL_CSR, 0x7F0 +#endif /* EXT_ILL CSR reasons are stored as follows: * - Bit 0: FPU core instruction (Load/Store instructions NOT concerned) @@ -167,7 +174,6 @@ _panic_handler: la ra, _return_from_exception /* EXT_ILL CSR should contain the reason for the Illegal Instruction */ csrrw a0, EXT_ILL_CSR, zero - /* Hardware loop cannot be treated lazily, so we should never end here if a HWLP instruction is used */ #if SOC_CPU_HAS_PIE /* Check if the PIE bit is set. */ diff --git a/tools/cmake/toolchain-clang-esp32c2.cmake b/tools/cmake/toolchain-clang-esp32c2.cmake index 55771686e08e..3d7593a2d301 100644 --- a/tools/cmake/toolchain-clang-esp32c2.cmake +++ b/tools/cmake/toolchain-clang-esp32c2.cmake @@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" diff --git a/tools/cmake/toolchain-clang-esp32c3.cmake b/tools/cmake/toolchain-clang-esp32c3.cmake index 55771686e08e..3d7593a2d301 100644 --- a/tools/cmake/toolchain-clang-esp32c3.cmake +++ b/tools/cmake/toolchain-clang-esp32c3.cmake @@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" diff --git a/tools/cmake/toolchain-clang-esp32c5.cmake b/tools/cmake/toolchain-clang-esp32c5.cmake index 22bcacd1e799..0e01b55683f9 100644 --- a/tools/cmake/toolchain-clang-esp32c5.cmake +++ b/tools/cmake/toolchain-clang-esp32c5.cmake @@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" diff --git a/tools/cmake/toolchain-clang-esp32c6.cmake b/tools/cmake/toolchain-clang-esp32c6.cmake index 22bcacd1e799..0e01b55683f9 100644 --- a/tools/cmake/toolchain-clang-esp32c6.cmake +++ b/tools/cmake/toolchain-clang-esp32c6.cmake @@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" diff --git a/tools/cmake/toolchain-clang-esp32c61.cmake b/tools/cmake/toolchain-clang-esp32c61.cmake index 22bcacd1e799..0e01b55683f9 100644 --- a/tools/cmake/toolchain-clang-esp32c61.cmake +++ b/tools/cmake/toolchain-clang-esp32c61.cmake @@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imac_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" diff --git a/tools/cmake/toolchain-clang-esp32h2.cmake b/tools/cmake/toolchain-clang-esp32h2.cmake index 55771686e08e..3d7593a2d301 100644 --- a/tools/cmake/toolchain-clang-esp32h2.cmake +++ b/tools/cmake/toolchain-clang-esp32h2.cmake @@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" diff --git a/tools/cmake/toolchain-clang-esp32h4.cmake b/tools/cmake/toolchain-clang-esp32h4.cmake index 55771686e08e..3d7593a2d301 100644 --- a/tools/cmake/toolchain-clang-esp32h4.cmake +++ b/tools/cmake/toolchain-clang-esp32h4.cmake @@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imc_zicsr_zifencei -mabi=ilp32 \ ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" diff --git a/tools/cmake/toolchain-clang-esp32p4.cmake b/tools/cmake/toolchain-clang-esp32p4.cmake index b7121244bf14..6c4f94812597 100644 --- a/tools/cmake/toolchain-clang-esp32p4.cmake +++ b/tools/cmake/toolchain-clang-esp32p4.cmake @@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar) set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imafc_zicsr_zifencei -mabi=ilp32f -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imafc_zicsr_zifencei -mabi=ilp32f \ ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imafc_zicsr_zifencei -mabi=ilp32f -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imafc_zicsr_zifencei -mabi=ilp32f \ ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imafc_zicsr_zifencei -mabi=ilp32f -no-integrated-as \ +remove_duplicated_flags("--target=riscv32-esp-elf -march=rv32imafc_zicsr_zifencei -mabi=ilp32f \ ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"