This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e8ec8447324264cc4e2c244b99d900cfea769a5b Author: wangmingrong1 <[email protected]> AuthorDate: Mon Nov 2 18:42:50 2026 +0800 build(compiler-rt): support the LLVM 21 profile API in InstrProfilingPlatform The profile runtime gained VTable and coverage-init sections in LLVM 19/20 and dropped the orderfile section in LLVM 21, so a single set of stubs cannot build against every supported compiler-rt version. Guard the stubs with the section macros from InstrProfData.inc: - INSTR_PROF_ORDERFILE_COMMON keeps __llvm_profile_begin_orderfile() for LLVM 17..20, where it is still referenced; - INSTR_PROF_VTAB_COMMON adds the begin/end vtables and vtabnames stubs, used from LLVM 19 on; - INSTR_PROF_COVINIT_COMMON adds the begin/end covinit stubs, used from LLVM 20 on. All of them return NULL/0 as NuttX does not use these features, but the symbols must exist to satisfy the linker when building with CONFIG_COVERAGE_COMPILER_RT=y. Also leave compiler-rt's own InstrProfilingPlatformOther.c out of the build, with make and with CMake: from LLVM 18.1.8 on it does not compile here (BitmapFirst and BitmapLast are undeclared), and every function it defines is defined by InstrProfilingPlatform.c as well. Assisted-by: Kiro:claude-opus-5-5 Signed-off-by: wangmingrong1 <[email protected]> --- libs/libbuiltin/compiler-rt/CMakeLists.txt | 1 + .../compiler-rt/InstrProfilingPlatform.c | 46 +++++++++++++++++++++- libs/libbuiltin/compiler-rt/Make.defs | 3 +- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/libs/libbuiltin/compiler-rt/CMakeLists.txt b/libs/libbuiltin/compiler-rt/CMakeLists.txt index a3aa7c731ff..11b4a7712b5 100644 --- a/libs/libbuiltin/compiler-rt/CMakeLists.txt +++ b/libs/libbuiltin/compiler-rt/CMakeLists.txt @@ -194,6 +194,7 @@ if(CONFIG_COVERAGE_COMPILER_RT) set(RT_PROFILE_SRCS InstrProfilingPlatform.c) file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile/*.c) + list(FILTER SRCSTMP EXCLUDE REGEX "InstrProfilingPlatformOther\\.c$") list(APPEND RT_PROFILE_SRCS ${SRCSTMP}) file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile/*.cpp) diff --git a/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c b/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c index 3c505143119..e34a6310776 100644 --- a/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c +++ b/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c @@ -122,24 +122,66 @@ char *__llvm_profile_end_bitmap(void) return 0; } +COMPILER_RT_VISIBILITY +ValueProfNode *__llvm_profile_begin_vnodes(void) +{ + return 0; +} + +COMPILER_RT_VISIBILITY +ValueProfNode *__llvm_profile_end_vnodes(void) +{ + return 0; +} + +#if defined(INSTR_PROF_ORDERFILE_COMMON) COMPILER_RT_VISIBILITY uint32_t *__llvm_profile_begin_orderfile(void) { return 0; } +#endif +#if defined(INSTR_PROF_VTAB_COMMON) COMPILER_RT_VISIBILITY -ValueProfNode *__llvm_profile_begin_vnodes(void) +const VTableProfData *__llvm_profile_begin_vtables(void) { return 0; } COMPILER_RT_VISIBILITY -ValueProfNode *__llvm_profile_end_vnodes(void) +const VTableProfData *__llvm_profile_end_vtables(void) { return 0; } +COMPILER_RT_VISIBILITY +const char *__llvm_profile_begin_vtabnames(void) +{ + return 0; +} + +COMPILER_RT_VISIBILITY +const char *__llvm_profile_end_vtabnames(void) +{ + return 0; +} +#endif + +#if defined(INSTR_PROF_COVINIT_COMMON) +COMPILER_RT_VISIBILITY +const __llvm_gcov_init_func_struct *__llvm_profile_begin_covinit(void) +{ + return 0; +} + +COMPILER_RT_VISIBILITY +const __llvm_gcov_init_func_struct *__llvm_profile_end_covinit(void) +{ + return 0; +} +#endif + COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) { return 0; diff --git a/libs/libbuiltin/compiler-rt/Make.defs b/libs/libbuiltin/compiler-rt/Make.defs index 6d2fdabc5e1..52e8354fd39 100644 --- a/libs/libbuiltin/compiler-rt/Make.defs +++ b/libs/libbuiltin/compiler-rt/Make.defs @@ -158,7 +158,8 @@ ifeq ($(CONFIG_HOST_MACOS),y) FLAGS += -D__APPLE__ endif -CSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.c) +CSRCS += $(filter-out %/InstrProfilingPlatformOther.c, \ + $(wildcard compiler-rt/compiler-rt/lib/profile/*.c)) CPPSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.cpp) CSRCS += InstrProfilingPlatform.c
