This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 8461f0ea54 clang: Support compiling rt.profile library
8461f0ea54 is described below
commit 8461f0ea549fb3aa45df7e88d650eb4240ecf4e7
Author: wangmingrong1 <[email protected]>
AuthorDate: Mon Oct 28 15:26:15 2024 +0800
clang: Support compiling rt.profile library
1. Since the implementation of gcov has changed since clang17, versions
before clang17 need to use the libunwind.a file
Signed-off-by: wangmingrong1 <[email protected]>
---
libs/libbuiltin/Kconfig | 4 +
libs/libbuiltin/compiler-rt/CMakeLists.txt | 40 +++++++
.../compiler-rt/InstrProfilingPlatform.c | 129 +++++++++++++++++++++
libs/libbuiltin/compiler-rt/Make.defs | 33 ++++++
tools/nxstyle.c | 7 ++
5 files changed, 213 insertions(+)
diff --git a/libs/libbuiltin/Kconfig b/libs/libbuiltin/Kconfig
index eab6c96d1f..3db48a0c51 100644
--- a/libs/libbuiltin/Kconfig
+++ b/libs/libbuiltin/Kconfig
@@ -33,4 +33,8 @@ config COMPILER_RT_HAS_BFLOAT16
bool "Enable support for bfloat16 in Compiler-rt"
default n
+config COMPILER_RT_PROFILE
+ bool "Enable profiling support in Compiler-rt"
+ default n
+
endif # BUILTIN_COMPILER_RT
diff --git a/libs/libbuiltin/compiler-rt/CMakeLists.txt
b/libs/libbuiltin/compiler-rt/CMakeLists.txt
index d5620669d1..58fef0ae45 100644
--- a/libs/libbuiltin/compiler-rt/CMakeLists.txt
+++ b/libs/libbuiltin/compiler-rt/CMakeLists.txt
@@ -406,6 +406,46 @@ if(CONFIG_BUILTIN_COMPILER_RT)
list(APPEND RT_BUILTIN_SRCS floatundidf.c floatundisf.c floatundixf.c)
endif()
+ if(CONFIG_COMPILER_RT_PROFILE)
+
+ target_include_directories(
+ compiler-rt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile)
+
+ target_compile_options(
+ compiler-rt
+ PRIVATE -DCOMPILER_RT_HAS_UNAME
+ -Wno-cleardeprecated-pragma
+ -Wno-deprecated-pragma
+ -Wno-incompatible-pointer-types
+ -Wno-shadow
+ -Wno-strict-prototypes
+ -Wno-undef
+ -Wno-unknown-warning-option)
+
+ set(RT_PROFILE_SRCS
+ GCDAProfiling.c
+ InstrProfiling.c
+ InstrProfilingBuffer.c
+ InstrProfilingFile.c
+ InstrProfilingInternal.c
+ InstrProfilingMerge.c
+ InstrProfilingMergeFile.c
+ InstrProfilingNameVar.c
+ InstrProfilingUtil.c
+ InstrProfilingValue.c
+ InstrProfilingVersionVar.c
+ InstrProfilingWriter.c
+ InstrProfilingRuntime.cpp)
+
+ foreach(src ${RT_PROFILE_SRCS})
+ string(PREPEND src ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile/)
+ list(APPEND COMPILER_RT_SRCS ${src})
+ endforeach()
+
+ list(APPEND COMPILER_RT_SRCS InstrProfilingPlatform.c)
+
+ endif()
+
list(APPEND INCDIR
${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/builtins/${RT_BUILTIN_ARCH})
diff --git a/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c
b/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c
new file mode 100644
index 0000000000..8e466d600d
--- /dev/null
+++ b/libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c
@@ -0,0 +1,129 @@
+/****************************************************************************
+ * libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "InstrProfiling.h"
+#include "InstrProfilingInternal.h"
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+extern char __start__llvm_prf_names[];
+extern char __end__llvm_prf_names[];
+extern char __start__llvm_prf_data[];
+extern char __end__llvm_prf_data[];
+extern char __start__llvm_prf_cnts[];
+extern char __end__llvm_prf_cnts[];
+
+COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = 0;
+COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = 0;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+COMPILER_RT_VISIBILITY
+void __llvm_profile_register_function(void *Data_)
+{
+}
+
+COMPILER_RT_VISIBILITY
+void __llvm_profile_register_names_function(void *NamesStart,
+ uint64_t NamesSize)
+{
+}
+
+COMPILER_RT_VISIBILITY
+const __llvm_profile_data *__llvm_profile_begin_data(void)
+{
+ return &__start__llvm_prf_data;
+}
+
+COMPILER_RT_VISIBILITY
+const __llvm_profile_data *__llvm_profile_end_data(void)
+{
+ return &__end__llvm_prf_data;
+}
+
+COMPILER_RT_VISIBILITY
+const char *__llvm_profile_begin_names(void)
+{
+ return &__start__llvm_prf_names;
+}
+
+COMPILER_RT_VISIBILITY
+const char *__llvm_profile_end_names(void)
+{
+ return &__end__llvm_prf_names;
+}
+
+COMPILER_RT_VISIBILITY
+char *__llvm_profile_begin_counters(void)
+{
+ return &__start__llvm_prf_cnts;
+}
+
+COMPILER_RT_VISIBILITY
+char *__llvm_profile_end_counters(void)
+{
+ return &__end__llvm_prf_cnts;
+}
+
+COMPILER_RT_VISIBILITY
+char *__llvm_profile_begin_bitmap(void)
+{
+ return 0;
+}
+
+COMPILER_RT_VISIBILITY
+char *__llvm_profile_end_bitmap(void)
+{
+ return 0;
+}
+
+COMPILER_RT_VISIBILITY
+uint32_t *__llvm_profile_begin_orderfile(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;
+}
+
+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 d8d504eb95..bce8321c26 100644
--- a/libs/libbuiltin/compiler-rt/Make.defs
+++ b/libs/libbuiltin/compiler-rt/Make.defs
@@ -149,6 +149,36 @@ else
CSRCS += floatundidf.c floatundisf.c floatundixf.c
endif
+ifeq ($(CONFIG_COMPILER_RT_PROFILE),y)
+
+# Include paths
+FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile
+
+# Suppress specific warnings
+FLAGS += -Wno-cleardeprecated-pragma -Wno-deprecated-pragma
-Wno-incompatible-pointer-types
+FLAGS += -Wno-shadow -Wno-strict-prototypes -Wno-undef
-Wno-unknown-warning-option
+
+# Define compiler-specific macros
+FLAGS += -DCOMPILER_RT_HAS_UNAME
+
+# Disable code coverage analysis for the library
+FLAGS += -fno-profile-generate
+
+# Profile support source files
+CSRCS += GCDAProfiling.c InstrProfilingBuffer.c InstrProfiling.c
InstrProfilingFile.c InstrProfilingInternal.c
+CSRCS += InstrProfilingMerge.c InstrProfilingMergeFile.c
InstrProfilingNameVar.c
+CSRCS += InstrProfilingUtil.c InstrProfilingValue.c InstrProfilingVersionVar.c
InstrProfilingWriter.c
+CPPSRCS += InstrProfilingRuntime.cpp
+
+# Profile platform support
+CSRCS += InstrProfilingPlatform.c
+
+# Dependency and search paths
+DEPPATH += --dep-path compiler-rt/compiler-rt/lib/profile
+VPATH += :compiler-rt/compiler-rt/lib/profile
+
+endif
+
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH}
AFLAGS += $(FLAGS)
@@ -160,3 +190,6 @@ VPATH += :compiler-rt/compiler-rt/lib/builtins/${ARCH}
DEPPATH += --dep-path compiler-rt/compiler-rt/lib/builtins
VPATH += :compiler-rt/compiler-rt/lib/builtins
+
+DEPPATH += --dep-path compiler-rt
+VPATH += :compiler-rt
diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 68c8a0b0d0..9774849b4e 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -643,6 +643,13 @@ static const char *g_white_files[] =
"arm-acle-compat.h",
"arm_asm.h",
+ /* Skip Mixed case
+ * Ref:
+ * libs/libbuiltin/
+ */
+
+ "InstrProfilingPlatform.c",
+
/* Skip Mixed case
* arch/arm/src/phy62xx/uart.c:1229:13: error: Mixed case identifier found
*/