mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 05:08:41 +08:00
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 <wangmingrong1@xiaomi.com>
This commit is contained in:
parent
761ee81956
commit
8461f0ea54
5 changed files with 213 additions and 0 deletions
|
@ -33,4 +33,8 @@ config COMPILER_RT_HAS_BFLOAT16
|
||||||
bool "Enable support for bfloat16 in Compiler-rt"
|
bool "Enable support for bfloat16 in Compiler-rt"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
config COMPILER_RT_PROFILE
|
||||||
|
bool "Enable profiling support in Compiler-rt"
|
||||||
|
default n
|
||||||
|
|
||||||
endif # BUILTIN_COMPILER_RT
|
endif # BUILTIN_COMPILER_RT
|
||||||
|
|
|
@ -406,6 +406,46 @@ if(CONFIG_BUILTIN_COMPILER_RT)
|
||||||
list(APPEND RT_BUILTIN_SRCS floatundidf.c floatundisf.c floatundixf.c)
|
list(APPEND RT_BUILTIN_SRCS floatundidf.c floatundisf.c floatundixf.c)
|
||||||
endif()
|
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
|
list(APPEND INCDIR
|
||||||
${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/builtins/${RT_BUILTIN_ARCH})
|
${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/builtins/${RT_BUILTIN_ARCH})
|
||||||
|
|
||||||
|
|
129
libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c
Normal file
129
libs/libbuiltin/compiler-rt/InstrProfilingPlatform.c
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -149,6 +149,36 @@ else
|
||||||
CSRCS += floatundidf.c floatundisf.c floatundixf.c
|
CSRCS += floatundidf.c floatundisf.c floatundixf.c
|
||||||
endif
|
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}
|
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH}
|
||||||
|
|
||||||
AFLAGS += $(FLAGS)
|
AFLAGS += $(FLAGS)
|
||||||
|
@ -160,3 +190,6 @@ VPATH += :compiler-rt/compiler-rt/lib/builtins/${ARCH}
|
||||||
|
|
||||||
DEPPATH += --dep-path compiler-rt/compiler-rt/lib/builtins
|
DEPPATH += --dep-path compiler-rt/compiler-rt/lib/builtins
|
||||||
VPATH += :compiler-rt/compiler-rt/lib/builtins
|
VPATH += :compiler-rt/compiler-rt/lib/builtins
|
||||||
|
|
||||||
|
DEPPATH += --dep-path compiler-rt
|
||||||
|
VPATH += :compiler-rt
|
||||||
|
|
|
@ -643,6 +643,13 @@ static const char *g_white_files[] =
|
||||||
"arm-acle-compat.h",
|
"arm-acle-compat.h",
|
||||||
"arm_asm.h",
|
"arm_asm.h",
|
||||||
|
|
||||||
|
/* Skip Mixed case
|
||||||
|
* Ref:
|
||||||
|
* libs/libbuiltin/
|
||||||
|
*/
|
||||||
|
|
||||||
|
"InstrProfilingPlatform.c",
|
||||||
|
|
||||||
/* Skip Mixed case
|
/* Skip Mixed case
|
||||||
* arch/arm/src/phy62xx/uart.c:1229:13: error: Mixed case identifier found
|
* arch/arm/src/phy62xx/uart.c:1229:13: error: Mixed case identifier found
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue