change(build): Use integrated assembler with Clang for RISCV chips

This commit is contained in:
Alexey Gerenkov 2024-05-14 20:40:33 +03:00
parent 64203d1403
commit 9ca231e76e
11 changed files with 38 additions and 31 deletions

View File

@ -156,11 +156,12 @@ build_clang_test_apps_esp32s3:
extends: extends:
- .build_cmake_clang_template - .build_cmake_clang_template
variables: variables:
# For RISCV clang generates '.linker-options' sections of type 'llvm_linker_options' in asm files. # https://reviews.llvm.org/D90108.
# See (https://llvm.org/docs/Extensions.html#linker-options-section-linker-options). # GNU 'as' lets .weak override .globl since binutils-gdb
# Binutils gas ignores them with warning. # https://github.com/bminor/binutils-gdb/commit/5ca547dc2399a0a5d9f20626d4bf5547c3ccfddd (1996)
# TODO: LLVM-333, Use integrated assembler. # while MC lets the last directive win (PR38921).
TEST_BUILD_OPTS_EXTRA: "--ignore-warning-str 'Warning: unrecognized section type'" # 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: build_clang_test_apps_esp32c3:
extends: extends:

View File

@ -441,7 +441,7 @@ rtos_current_tcb:
lw a0, pxCurrentTCBs lw a0, pxCurrentTCBs
#endif /* ( configNUM_CORES > 1 ) */ #endif /* ( configNUM_CORES > 1 ) */
ret ret
.size, .-rtos_current_tcb .size rtos_current_tcb, .-rtos_current_tcb
/** /**

View File

@ -21,7 +21,14 @@
#if ( SOC_CPU_COPROC_NUM > 0 ) #if ( SOC_CPU_COPROC_NUM > 0 )
/* Targets with coprocessors present a special CSR to get Illegal Instruction exception reason */ /* 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 .equ EXT_ILL_CSR, 0x7F0
#endif
/* EXT_ILL CSR reasons are stored as follows: /* EXT_ILL CSR reasons are stored as follows:
* - Bit 0: FPU core instruction (Load/Store instructions NOT concerned) * - Bit 0: FPU core instruction (Load/Store instructions NOT concerned)
@ -167,7 +174,6 @@ _panic_handler:
la ra, _return_from_exception la ra, _return_from_exception
/* EXT_ILL CSR should contain the reason for the Illegal Instruction */ /* EXT_ILL CSR should contain the reason for the Illegal Instruction */
csrrw a0, EXT_ILL_CSR, zero csrrw a0, EXT_ILL_CSR, zero
/* Hardware loop cannot be treated lazily, so we should never end here if a HWLP instruction is used */ /* Hardware loop cannot be treated lazily, so we should never end here if a HWLP instruction is used */
#if SOC_CPU_HAS_PIE #if SOC_CPU_HAS_PIE
/* Check if the PIE bit is set. */ /* Check if the PIE bit is set. */

View File

@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar)
set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_RANLIB llvm-ranlib)
set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) 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}" ${CMAKE_C_FLAGS}"
UNIQ_CMAKE_C_FLAGS) UNIQ_CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
CACHE STRING "C Compiler Base Flags" CACHE STRING "C Compiler Base Flags"
FORCE) 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}" ${CMAKE_CXX_FLAGS}"
UNIQ_CMAKE_CXX_FLAGS) UNIQ_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
CACHE STRING "C++ Compiler Base Flags" CACHE STRING "C++ Compiler Base Flags"
FORCE) 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}" ${CMAKE_ASM_FLAGS}"
UNIQ_CMAKE_ASM_FLAGS) UNIQ_CMAKE_ASM_FLAGS)
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"

View File

@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar)
set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_RANLIB llvm-ranlib)
set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) 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}" ${CMAKE_C_FLAGS}"
UNIQ_CMAKE_C_FLAGS) UNIQ_CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
CACHE STRING "C Compiler Base Flags" CACHE STRING "C Compiler Base Flags"
FORCE) 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}" ${CMAKE_CXX_FLAGS}"
UNIQ_CMAKE_CXX_FLAGS) UNIQ_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
CACHE STRING "C++ Compiler Base Flags" CACHE STRING "C++ Compiler Base Flags"
FORCE) 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}" ${CMAKE_ASM_FLAGS}"
UNIQ_CMAKE_ASM_FLAGS) UNIQ_CMAKE_ASM_FLAGS)
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"

View File

@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar)
set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_RANLIB llvm-ranlib)
set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) 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}" ${CMAKE_C_FLAGS}"
UNIQ_CMAKE_C_FLAGS) UNIQ_CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
CACHE STRING "C Compiler Base Flags" CACHE STRING "C Compiler Base Flags"
FORCE) 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}" ${CMAKE_CXX_FLAGS}"
UNIQ_CMAKE_CXX_FLAGS) UNIQ_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
CACHE STRING "C++ Compiler Base Flags" CACHE STRING "C++ Compiler Base Flags"
FORCE) 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}" ${CMAKE_ASM_FLAGS}"
UNIQ_CMAKE_ASM_FLAGS) UNIQ_CMAKE_ASM_FLAGS)
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"

View File

@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar)
set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_RANLIB llvm-ranlib)
set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) 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}" ${CMAKE_C_FLAGS}"
UNIQ_CMAKE_C_FLAGS) UNIQ_CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
CACHE STRING "C Compiler Base Flags" CACHE STRING "C Compiler Base Flags"
FORCE) 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}" ${CMAKE_CXX_FLAGS}"
UNIQ_CMAKE_CXX_FLAGS) UNIQ_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
CACHE STRING "C++ Compiler Base Flags" CACHE STRING "C++ Compiler Base Flags"
FORCE) 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}" ${CMAKE_ASM_FLAGS}"
UNIQ_CMAKE_ASM_FLAGS) UNIQ_CMAKE_ASM_FLAGS)
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"

View File

@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar)
set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_RANLIB llvm-ranlib)
set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) 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}" ${CMAKE_C_FLAGS}"
UNIQ_CMAKE_C_FLAGS) UNIQ_CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
CACHE STRING "C Compiler Base Flags" CACHE STRING "C Compiler Base Flags"
FORCE) 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}" ${CMAKE_CXX_FLAGS}"
UNIQ_CMAKE_CXX_FLAGS) UNIQ_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
CACHE STRING "C++ Compiler Base Flags" CACHE STRING "C++ Compiler Base Flags"
FORCE) 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}" ${CMAKE_ASM_FLAGS}"
UNIQ_CMAKE_ASM_FLAGS) UNIQ_CMAKE_ASM_FLAGS)
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"

View File

@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar)
set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_RANLIB llvm-ranlib)
set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) 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}" ${CMAKE_C_FLAGS}"
UNIQ_CMAKE_C_FLAGS) UNIQ_CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
CACHE STRING "C Compiler Base Flags" CACHE STRING "C Compiler Base Flags"
FORCE) 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}" ${CMAKE_CXX_FLAGS}"
UNIQ_CMAKE_CXX_FLAGS) UNIQ_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
CACHE STRING "C++ Compiler Base Flags" CACHE STRING "C++ Compiler Base Flags"
FORCE) 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}" ${CMAKE_ASM_FLAGS}"
UNIQ_CMAKE_ASM_FLAGS) UNIQ_CMAKE_ASM_FLAGS)
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"

View File

@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar)
set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_RANLIB llvm-ranlib)
set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) 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}" ${CMAKE_C_FLAGS}"
UNIQ_CMAKE_C_FLAGS) UNIQ_CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
CACHE STRING "C Compiler Base Flags" CACHE STRING "C Compiler Base Flags"
FORCE) 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}" ${CMAKE_CXX_FLAGS}"
UNIQ_CMAKE_CXX_FLAGS) UNIQ_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
CACHE STRING "C++ Compiler Base Flags" CACHE STRING "C++ Compiler Base Flags"
FORCE) 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}" ${CMAKE_ASM_FLAGS}"
UNIQ_CMAKE_ASM_FLAGS) UNIQ_CMAKE_ASM_FLAGS)
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"

View File

@ -11,21 +11,21 @@ set(CMAKE_AR llvm-ar)
set(CMAKE_RANLIB llvm-ranlib) set(CMAKE_RANLIB llvm-ranlib)
set(CMAKE_OBJDUMP riscv32-esp-elf-clang-objdump) 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}" ${CMAKE_C_FLAGS}"
UNIQ_CMAKE_C_FLAGS) UNIQ_CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}"
CACHE STRING "C Compiler Base Flags" CACHE STRING "C Compiler Base Flags"
FORCE) 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}" ${CMAKE_CXX_FLAGS}"
UNIQ_CMAKE_CXX_FLAGS) UNIQ_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}"
CACHE STRING "C++ Compiler Base Flags" CACHE STRING "C++ Compiler Base Flags"
FORCE) 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}" ${CMAKE_ASM_FLAGS}"
UNIQ_CMAKE_ASM_FLAGS) UNIQ_CMAKE_ASM_FLAGS)
set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}"