forked from apache/nuttx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clang: support gcov ARM LLVM clang supports code coverage detection t…
…ools 1. Create a libbuiltin folder under libs for building toolchain related libraries such as libgcc and compiler rt 2. The code coverage tool for LLVM clang requires the use of the profile library in the compiler rt under LLVM, which needs to be built-in into the kernel code 3. Porting the compiler rt library for LLVM 4. Implement InstrProfilingPlatformNX.c on the NX platform Signed-off-by: wangmingrong1 <[email protected]>
- Loading branch information
Showing
14 changed files
with
424 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/compiler-rt/compiler-rt | ||
*.o | ||
.depend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# For a description of the syntax of this configuration file, | ||
# see the file kconfig-language.txt in the NuttX tools repository. | ||
# | ||
|
||
comment "Toolchains Library Support" | ||
|
||
config TOOLCHAINS_BUILTIN | ||
bool "Builtin toolchains support" | ||
default n | ||
---help--- | ||
Choose to compile libraries related to toolchains into the OS | ||
|
||
config BUILTIN_COMPILER_RT | ||
bool "Builtin LLVM Compiler-rt" | ||
depends on ARM_TOOLCHAIN_CLANG | ||
select TOOLCHAINS_BUILTIN | ||
default y | ||
---help--- | ||
Compile the LLVM Compiler-rt library into the OS. | ||
|
||
if BUILTIN_COMPILER_RT | ||
|
||
config COMPILER_RT_VERSION | ||
string "Select LLVM Compiler-rt version" | ||
depends on BUILTIN_COMPILER_RT | ||
default "15.0.2" | ||
|
||
endif # COMPILER_RT_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
############################################################################ | ||
# libs/libbuiltin/Makefile | ||
# | ||
# 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. | ||
# | ||
########################################################################### | ||
|
||
include $(TOPDIR)/Make.defs | ||
|
||
ifeq ($(CONFIG_BUILTIN_COMPILER_RT),y) | ||
include compiler-rt/Make.defs | ||
endif | ||
|
||
BIN ?= libbuiltin$(LIBEXT) | ||
BINDIR ?= bin | ||
|
||
KBIN = libkbuiltin$(LIBEXT) | ||
KBINDIR = kbin | ||
|
||
AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT))) | ||
COBJS = $(addprefix $(BINDIR)$(DELIM), $(CSRCS:.c=$(OBJEXT))) | ||
CXXOBJS = $(addprefix $(BINDIR)$(DELIM), $(CXXSRCS:.cxx=$(OBJEXT))) | ||
CPPOBJS = $(addprefix $(BINDIR)$(DELIM), $(CPPSRCS:.cpp=$(OBJEXT))) | ||
|
||
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(CPPSRCS) | ||
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS) $(CPPOBJS) | ||
|
||
all: $(OBJS) | ||
$(call ARCHIVE, $(BIN), $(OBJS)) | ||
|
||
.PHONY: depend clean distclean context $(LIBBUILTIN) | ||
|
||
$(AOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.S | ||
$(call ASSEMBLE, $<, $@) | ||
|
||
$(COBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.c | ||
$(call COMPILE, $<, $@) | ||
|
||
$(CXXOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.cxx | ||
$(call COMPILEXX, $<, $@) | ||
|
||
$(CPPOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.cpp | ||
$(call COMPILEXX, $<, $@) | ||
|
||
context:: | ||
|
||
.depend: $(LIBBUILTIN) | ||
$(Q) touch $@ | ||
|
||
depend: .depend | ||
|
||
$(BIN): depend | ||
$(Q) $(MAKE) all EXTRAFLAGS="$(EXTRAFLAGS)" | ||
|
||
# C library for the kernel phase of the two-pass kernel build | ||
|
||
ifneq ($(BIN),$(KBIN)) | ||
$(KBIN): $(OBJS) | ||
$(Q) $(MAKE) $(KBIN) BIN=$(KBIN) BINDIR=$(KBINDIR) EXTRAFLAGS="$(EXTRAFLAGS)" | ||
endif | ||
|
||
clean: | ||
$(call DELFILE, $(BIN)) | ||
$(Q) $(MAKE) -C bin clean | ||
$(Q) $(MAKE) -C kbin clean | ||
|
||
distclean: clean | ||
$(Q) $(MAKE) -C bin distclean | ||
$(Q) $(MAKE) -C kbin distclean | ||
$(call DELFILE, .depend) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
############################################################################ | ||
# libs/libbuiltin/bin/Makefile | ||
# | ||
# 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. | ||
# | ||
########################################################################### | ||
|
||
include $(TOPDIR)/Make.defs | ||
|
||
all: | ||
.PHONY: clean distclean | ||
|
||
# Clean Targets: | ||
|
||
clean: | ||
$(call DELFILE, *.o) | ||
|
||
# Deep clean -- removes all traces of the configuration | ||
|
||
distclean: clean | ||
$(call DELFILE, *.dep) | ||
$(call DELFILE, .depend) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/**************************************************************************** | ||
* libs/libbuiltin/compiler-rt/InstrProfilingPlatformNX.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_vnds[]; | ||
extern char __end__llvm_prf_vnds[]; | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
############################################################################ | ||
# libs/libbuiltin/compiler-rt/Make.defs | ||
# | ||
# 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. | ||
# | ||
############################################################################ | ||
|
||
include $(TOPDIR)/Make.defs | ||
|
||
LIBBUILTIN += compiler-rt | ||
|
||
ifeq ($(wildcard compiler-rt/compiler-rt/lib),) | ||
compiler-rt-$(CONFIG_COMPILER_RT_VERSION).src.tar.xz: | ||
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(CONFIG_COMPILER_RT_VERSION),$@) | ||
|
||
compiler-rt/compiler-rt: compiler-rt-$(CONFIG_COMPILER_RT_VERSION).src.tar.xz | ||
$(Q) tar -xf $< | ||
$(Q) mv compiler-rt-$(CONFIG_COMPILER_RT_VERSION).src $@ | ||
$(call DELDIR, $<) | ||
|
||
compiler-rt: compiler-rt/compiler-rt | ||
endif | ||
|
||
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/include | ||
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile | ||
FLAGS += -Wno-strict-prototypes -Wno-shadow -Wno-cleardeprecated-pragma | ||
FLAGS += -Wno-deprecated-pragma -Wno-undef -Wno-incompatible-pointer-types | ||
FLAGS += -Wno-unknown-warning-option -Wno-deprecated-pragma | ||
FLAGS += -DCOMPILER_RT_HAS_UNAME | ||
|
||
CFLAGS += $(FLAGS) | ||
CXXFLAGS += $(FLAGS) | ||
|
||
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 | ||
|
||
CSRCS += InstrProfilingPlatformNX.c | ||
|
||
DEPPATH += --dep-path compiler-rt/compiler-rt/lib/profile | ||
VPATH += :compiler-rt/compiler-rt/lib/profile | ||
|
||
DEPPATH += --dep-path compiler-rt | ||
VPATH += :compiler-rt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
############################################################################ | ||
# libs/libbuiltin/kbin/Makefile | ||
# | ||
# 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. | ||
# | ||
########################################################################### | ||
|
||
include $(TOPDIR)/Make.defs | ||
|
||
all: | ||
.PHONY: clean distclean | ||
|
||
# Clean Targets: | ||
|
||
clean: | ||
$(call DELFILE, *.o) | ||
|
||
# Deep clean -- removes all traces of the configuration | ||
|
||
distclean: clean | ||
$(call DELFILE, *.dep) | ||
$(call DELFILE, .depend) |
Oops, something went wrong.