gcov: add Clang support
cover gcov: add Clang support
This patch series adds Clang supoprt for gcov.
Patch 1 refactors existing code in preparation for Clang support. Patches 2-3 implement necessary LLVM runtime hooks and gcov kernel interfaces. Patch 4 simplifies config selection.
Greg Hackmann (2):
gcov: clang: move common gcc code into gcc_base.c
gcov: clang support
Nick Desaulniers (1):
gcov: clang: link/unlink profiling data set.
Tri Vo (1):
gcov: clang: pick GCC vs Clang format depending on compiler
kernel/gcov/Kconfig | 9 + kernel/gcov/Makefile | 5 +- kernel/gcov/base.c | 78 +----- kernel/gcov/clang.c | 554 +++++++++++++++++++++++++++++++++++++++++ kernel/gcov/gcc_base.c | 79 ++++++ kernel/gcov/gcov.h | 3 + 6 files changed, 650 insertions(+), 78 deletions(-) create mode 100644 kernel/gcov/clang.c create mode 100644 kernel/gcov/gcc_base.c
--
2.20.1.97.g81188d93c3-goog
PATCH 1/4 gcov: clang: move common gcc code into gcc_base.c
From: Greg Hackmann <[email protected]>
base.c contains a few callbacks specific to GCC's gcov implementation. Move these into their own module in preparation for clang support.
--- kernel/gcov/Makefile | 4 +-- kernel/gcov/base.c | 78 ++--------------------------------------- kernel/gcov/gcc_base.c | 79 ++++++++++++++++++++++++++++++++++++++++++ kernel/gcov/gcov.h | 3 ++ 4 files changed, 86 insertions(+), 78 deletions(-) create mode 100644 kernel/gcov/gcc_base.c
kernel/gcov/Makefile +2 -2
@@ -2,5 +2,5 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' obj-y := base.o fs.o -obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o -obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o +obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_base.o gcc_3_4.o +obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_base.o gcc_4_7.o
kernel/gcov/base.c +2 -76
84 lines not on this page · raw message
kernel/gcov/gcc_base.c new file +79 -0
79 lines not on this page · raw message
kernel/gcov/gcov.h +3 -0
@@ -83,4 +83,7 @@ struct gcov_link { };extern const struct gcov_link gcov_link[]; +extern int gcov_events_enabled; +extern struct mutex gcov_lock; +#endif /* GCOV_H */
Signature · 1 line
2.20.1.97.g81188d93c3-goog
Peter Oberparleiter
maintainerRe: [PATCH 1/4] gcov: clang: move common gcc code into gcc_base.c
Quoted 4 lines · Tri Vo
From: Greg Hackmann <[email protected]>
base.ccontains a few callbacks specific to GCC's gcov implementation. Move these into their own module in preparation for clang support.
Minor nitpick: at least in commit messages, a consistent capitalization of "Clang" would be preferable.
Quoted 4 lines
kernel/gcov/Makefile +0
-0
[...]
kernel/gcov/Makefile
Quoted 10 lines
kernel/gcov/Makefile +2
-5-void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_icall_topn); +int gcov_events_enabled; +DEFINE_MUTEX(gcov_lock); void __gcov_exit(void) {
Unless __gcov_exit() is required by Clang, it should also be moved.
kernel/gcov/gcc_base.c line 4
Quoted 10 lines
kernel/gcov/gcc_base.c new file +4
-0@@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/kernel.h> +#include <linux/mutex.h>
linux/export.h should be included for the EXPORT_SYMBOL() macro.
Signature · 2 lines
Peter Oberparleiter Linux on Z Development - IBM Germany
PATCH 2/4 gcov: clang support
In reply to Tri VoFrom: Greg Hackmann <[email protected]>
LLVM uses profiling data that's deliberately similar to GCC, but has a very different way of exporting that data. LLVM calls llvm_gcov_init() once per module, and provides a couple of callbacks that we can use to ask for more data.
We care about the "writeout" callback, which in turn calls back into compiler-rt/this module to dump all the gathered coverage data to disk:
llvm_gcda_start_file()
llvm_gcda_emit_function()
llvm_gcda_emit_arcs()
llvm_gcda_emit_function()
llvm_gcda_emit_arcs()
[... repeats for each function ...]
llvm_gcda_summary_info()
llvm_gcda_end_file()
This design is much more stateless and unstructured than gcc's, and is intended to run at process exit. This forces us to keep some local state about which module we're dealing with at the moment. On the other hand, it also means we don't depend as much on how LLVM represents profiling data internally.
See LLVM's lib/Transforms/Instrumentation/GCOVProfiling.cpp for more details on how this works, particularly GCOVProfiler::emitProfileArcs(), GCOVProfiler::insertCounterWriteout(), and GCOVProfiler::insertFlush().
--- kernel/gcov/Kconfig | 5 + kernel/gcov/Makefile | 1 + kernel/gcov/clang.c | 531 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 537 insertions(+) create mode 100644 kernel/gcov/clang.c
kernel/gcov/Kconfig +5 -0
@@ -71,6 +71,11 @@ config GCOV_FORMAT_4_7 ---help--- Select this option to use the format defined by GCC 4.7. +config GCOV_FORMAT_CLANG + bool "Clang format" + ---help--- + Select this option to use the format defined by Clang. + endchoice endmenu
kernel/gcov/Makefile +1 -0
@@ -4,3 +4,4 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' obj-y := base.o fs.o obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_base.o gcc_3_4.o obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_base.o gcc_4_7.o +obj-$(CONFIG_GCOV_FORMAT_CLANG) += clang.o
kernel/gcov/clang.c new file +531 -0
531 lines not on this page · raw message
Signature · 1 line
2.20.1.97.g81188d93c3-goog
Peter Oberparleiter
maintainerRe: [PATCH 2/4] gcov: clang support
Quoted 35 lines · Tri Vo
From: Greg Hackmann <[email protected]>
LLVM uses profiling data that's deliberately similar to GCC, but has a very different way of exporting that data. LLVM calls
llvm_gcov_init()once per module, and provides a couple of callbacks that we can use to ask for more data.We care about the "writeout" callback, which in turn calls back into compiler-rt/this module to dump all the gathered coverage data to disk:
llvm_gcda_start_file()
llvm_gcda_emit_function()
llvm_gcda_emit_arcs()
llvm_gcda_emit_function()
llvm_gcda_emit_arcs()
[... repeats for each function ...]
llvm_gcda_summary_info()
llvm_gcda_end_file()This design is much more stateless and unstructured than gcc's, and is intended to run at process exit. This forces us to keep some local state about which module we're dealing with at the moment. On the other hand, it also means we don't depend as much on how LLVM represents profiling data internally.
See LLVM's
lib/Transforms/Instrumentation/GCOVProfiling.cppfor more details on how this works, particularlyGCOVProfiler::emitProfileArcs(),GCOVProfiler::insertCounterWriteout(), andGCOVProfiler::insertFlush().Signed-off-by Greg Hackmann <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>Signed-off-by Tri Vo <[email protected]>Tested-by Trilok Soni <[email protected]>Tested-by Prasad Sodagudi <[email protected]>Tested-by Tri Vo <[email protected]>
Quoted 6 lines
--- kernel/gcov/Kconfig | 5 + kernel/gcov/Makefile | 1 + kernel/gcov/clang.c | 531 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 537 insertions(+) create mode 100644 kernel/gcov/clang.c
Please consider adding a short section detailing usage differences between GCC and Clang coverage to the GCOV documentation at
Documentation/dev-tools/gcov.rst
Quoted 5 lines
kernel/gcov/clang.c new file +0
-0
[...]
Quoted 10 lines
kernel/gcov/clang.c new file +10
-0+/** +* gcov_info_add - add up profiling data +* @dest: profiling data set to which data is added +* @source: profiling data set which is added +* +* Adds profiling counts of @source to @dest. +*/ +void gcov_info_add (struct gcov_info *dst,struct gcov_info *src) +{ +struct gcov_fn_info *dfn_ptr;
kernel/gcov/clang.c line 246
Quoted 10 lines
kernel/gcov/clang.c new file +10
-0+struct gcov_fn_info *sfn_ptr =list_first_entry_or_null (&src->functions, + struct gcov_fn_info, head); + +list_for_each_entry (dfn_ptr, &dst->functions, head) { +u32 i; + +for (i =0 ; i < sfn_ptr->num_counters; i++) + dfn_ptr->counters[i] += sfn_ptr->counters[i]; + +if (!list_is_last (&sfn_ptr->head, &src->functions))
This check seems wrong - both dst and src should contain the same amount of functions and counters per function (the GCC support is based on the same assumption).
Even if not, the next iteration would try to add counters for different functions which would be incorrect and could cause access violations due to differing values for num_counters.
kernel/gcov/clang.c line 259
Quoted 13 lines
kernel/gcov/clang.c new file +13
-0+ sfn_ptr =list_next_entry (sfn_ptr, head); + } +} + +static struct gcov_fn_info *gcov_fn_info_dup (struct gcov_fn_info *fn) +{ +struct gcov_fn_info *fn_dup =kmemdup (fn,sizeof (*fn), +GFP_KERNEL ); +if (!fn_dup) +return NULL ; +INIT_LIST_HEAD (&fn_dup->head); + + fn_dup->name =kstrdup (fn->name,GFP_KERNEL );
Since struct gcov_fn_info does not define a member named 'name', this should fail during compilation. I saw that this is fixed with the next patch, but this really needs to be merged into this one.
kernel/gcov/clang.c line 265
Quoted 6 lines
kernel/gcov/clang.c new file +6
-0+if (!fn_dup->name) + goto err_name; + + fn_dup->counters =kmemdup (fn->counters, + fn->num_counters *sizeof (fn->counters[0 ]), +GFP_KERNEL );
Please consider using vmalloc() here (like the GCC support does) because the number of counters can be quite large and there might be situations where the required amount of physically contiguous memory is not available at run-time.
Quoted 19 lines
kernel/gcov/clang.c new file +19
-0+if (!fn_dup->counters) + goto err_counters; + +return fn_dup; + +err_counters: +kfree (fn_dup->name); +err_name: +kfree (fn_dup); +return NULL ; +} + +/** +* gcov_info_dup - duplicate profiling data set +* @info: profiling data set to duplicate +* +* Return newly allocated duplicate on success, %NULL on error. +*/ +struct gcov_info *gcov_info_dup (struct gcov_info *info)
kernel/gcov/clang.c line 294
Quoted 10 lines
kernel/gcov/clang.c new file +10
-0+{ +struct gcov_info *dup; +struct gcov_fn_info *fn, *tmp; + + dup =kmemdup (info,sizeof (*dup),GFP_KERNEL ); +if (!dup) +return NULL ; +INIT_LIST_HEAD (&dup->head); +INIT_LIST_HEAD (&dup->functions); + dup->filename =kstrdup (info->filename,GFP_KERNEL );
To be consistent, please also check for a failed allocation here.
kernel/gcov/clang.c
Quoted 2 lines
kernel/gcov/clang.c new file +2
-0+ +list_for_each_entry_safe (fn, tmp, &info->functions, head) {
It should not be necessary to use the _safe variant here as info->functions is not modified during traversal.
Signature · 2 lines
Peter Oberparleiter Linux on Z Development - IBM Germany
PATCH 3/4 gcov: clang: link/unlink profiling data set.
In reply to Tri VoFrom: Nick Desaulniers <[email protected]>
gcov.h defines an interface to access gcov_info data.
Add Clang implementation of gcov_info_link/gcov_info_unlink interfaces.
--- kernel/gcov/clang.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)
kernel/gcov/clang.c +28 -5
@@ -77,6 +77,7 @@ struct gcov_fn_info {u32 num_counters;u64 *counters; +const char *function_name; };static struct gcov_info *current_info;
@@ -124,7 +125,7 @@ void llvm_gcda_emit_function(u32 ident, const char *function_name,if (!info) {pr_warn_ratelimited ("failed to allocate gcov function info for %s\n" , - function_name); + function_name ?:"UNKNOWN" );return ; }
@@ -133,6 +134,8 @@ void llvm_gcda_emit_function(u32 ident, const char *function_name, info->checksum = func_checksum; info->use_extra_checksum = use_extra_checksum; info->cfg_checksum = cfg_checksum; +if (function_name) + info->function_name =kstrdup (function_name,GFP_KERNEL );list_add_tail (&info->head, ¤t_info->functions); }
@@ -193,6 +196,26 @@ struct gcov_info *gcov_info_next(struct gcov_info *info)return list_next_entry (info, head); } +/** +* gcov_info_link - link/add profiling data set to the list +* @info: profiling data set +*/ +void gcov_info_link (struct gcov_info *info) +{ +list_add_tail (&info->head, &clang_gcov_list); +} + +/** +* gcov_info_unlink - unlink/remove profiling data set from the list +* @prev: previous profiling data set +* @info: profiling data set +*/ +void gcov_info_unlink (struct gcov_info *prev,struct gcov_info *info) +{ +if (prev) +list_del (&prev->head); +} +/* Symbolic links to be created for each profiling data file. */ const struct gcov_link gcov_link[] = { {OBJ_TREE ,"gcno" },/* Link to .gcno file in $(objtree). */
@@ -256,8 +279,8 @@ static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)return NULL ;INIT_LIST_HEAD (&fn_dup->head); - fn_dup->name =kstrdup (fn->name,GFP_KERNEL ); -if (!fn_dup->name) + fn_dup->function_name =kstrdup (fn->function_name,GFP_KERNEL ); +if (!fn_dup->function_name) goto err_name; fn_dup->counters = kmemdup(fn->counters,
@@ -269,7 +292,7 @@ static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)return fn_dup; err_counters: -kfree (fn_dup->name); +kfree (fn_dup->function_name); err_name:kfree (fn_dup);return NULL ;
@@ -317,7 +340,7 @@ void gcov_info_free(struct gcov_info *info)struct gcov_fn_info *fn, *tmp;list_for_each_entry_safe (fn, tmp, &info->functions, head) { -kfree (fn->name); +kfree (fn->function_name);kfree (fn->counters);list_del (&fn->head);kfree (fn);
Signature · 1 line
2.20.1.97.g81188d93c3-goog
Peter Oberparleiter
maintainerRe: [PATCH 3/4] gcov: clang: link/unlink profiling data set.
Quoted 6 lines · Tri Vo
From: Nick Desaulniers <[email protected]>
gcov.hdefines an interface to accessgcov_infodata.Add Clang implementation of gcov_info_link/gcov_info_unlink interfaces.
Quoted 8 lines
Signed-off-by Nick Desaulniers <[email protected]>Signed-off-by Tri Vo <[email protected]>Tested-by Trilok Soni <[email protected]>Tested-by Prasad Sodagudi <[email protected]>Tested-by Tri Vo <[email protected]>--- kernel/gcov/clang.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)
Please merge this patch into patch 2 as it fixes a number of problems in that patch.
Quoted 5 lines
kernel/gcov/clang.c +0
-0
[...]
kernel/gcov/clang.c struct gcov_info *gcov_info_next(struct gcov_info *info) · line 216
Quoted 9 lines
kernel/gcov/clang.c +9
-0+/** +* gcov_info_unlink - unlink/remove profiling data set from the list +* @prev: previous profiling data set +* @info: profiling data set +*/ +void gcov_info_unlink (struct gcov_info *prev,struct gcov_info *info) +{ +if (prev) +list_del (&prev->head);
This is incorrect - gcov_info_unlink should remove info from the list, not its predecessor prev.
Signature · 2 lines
Peter Oberparleiter Linux on Z Development - IBM Germany
PATCH 4/4 gcov: clang: pick GCC vs Clang format depending on compiler
In reply to Tri VoClang gcov format is only supported by Clang compiler, and Clang compiler only supports Clang format.
We set gcov format to depend on which compiler (GCC or Clang) is used.
Automatic format detection behavior is preserved because:
If GCC is used, one of the GCC gcov formats is selected. If Clang is used, Clang gcov format is selected.
--- kernel/gcov/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)
kernel/gcov/Kconfig +4 -0
@@ -60,6 +60,8 @@ choice In such a case, change this option to adjust the format used in the kernel accordingly. + Select Clang gcov format if building with Clang compiler. + config GCOV_FORMAT_3_4 bool "GCC 3.4 format" depends on CC_IS_GCC && GCC_VERSION < 40700
@@ -68,11 +70,13 @@ config GCOV_FORMAT_3_4 config GCOV_FORMAT_4_7 bool "GCC 4.7 format" + depends on CC_IS_GCC ---help--- Select this option to use the format defined by GCC 4.7. config GCOV_FORMAT_CLANG bool "Clang format" + depends on CC_IS_CLANG ---help--- Select this option to use the format defined by Clang.
Signature · 1 line
2.20.1.97.g81188d93c3-goog
Re: [PATCH 4/4] gcov: clang: pick GCC vs Clang format depending on compiler
Quoted 11 lines · Tri Vo
Clang gcov format is only supported by Clang compiler, and Clang compiler only supports Clang format.
We set gcov format to depend on which compiler (GCC or Clang) is used.
Automatic format detection behavior is preserved because:
If GCC is used, one of the GCC gcov formats is selected. If Clang is used, Clang gcov format is selected.Signed-off-by Tri Vo <[email protected]>
Thanks for sending the series Tri. I think this config change on the end is a nice little touch!
Quoted 34 lines
--- kernel/gcov/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)kernel/gcov/Kconfig +4
-1@@ -60,6 +60,8 @@ choice In such a case, change this option to adjust the format used in the kernel accordingly. + Select Clang gcov format if building with Clang compiler. + config GCOV_FORMAT_3_4 bool "GCC 3.4 format" depends on CC_IS_GCC && GCC_VERSION < 40700@@ -68,11 +70,13 @@ config GCOV_FORMAT_3_4 config GCOV_FORMAT_4_7 bool "GCC 4.7 format" + depends on CC_IS_GCC ---help--- Select this option to use the format defined by GCC 4.7. config GCOV_FORMAT_CLANG bool "Clang format" + depends on CC_IS_CLANG ---help--- Select this option to use the format defined by Clang. --2.20.1.97.g81188d93c3-goog
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH 4/4] gcov: clang: pick GCC vs Clang format depending on compiler
In reply to Tri VoQuoted 3 lines · Tri Vo
Clang gcov format is only supported by Clang compiler, and Clang compiler only supports Clang format.
If so, what is the point of putting GCOV_FORMAT_CLANG into the choice menu?
You can choose the format only when you are using GCC.
I think the following is more sensible:
if GCOV_KERNEL
config GCOV_PROFILE_ALL
....
choice
prompt "Specify GCOV format for GCC"
depends on CC_IS_GCC
...
config GCOV_FORMAT_3_4
bool "GCC 3.4 format"
depends on GCC_VERSION < 40700
...
config GCOV_FORMAT_4_7
bool "GCC 4.7 format"
...
endchoice
config GCOV_FORMAT_CLANG
def_bool CC_IS_CLANG
endif
Or, you can delete GCOV_FORMAT_CLANG
if you write the Makefile like follows:
obj-y := base.o fs.o obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_base.o gcc_3_4.o obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_base.o gcc_4_7.o
obj-$(CONFIG_CC_IS_CLANG) += clang.o
Quoted 41 lines
We set gcov format to depend on which compiler (GCC or Clang) is used.
Automatic format detection behavior is preserved because:
If GCC is used, one of the GCC gcov formats is selected. If Clang is used, Clang gcov format is selected.Signed-off-by Tri Vo <[email protected]>--- kernel/gcov/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)kernel/gcov/Kconfig +4
-1@@ -60,6 +60,8 @@ choice In such a case, change this option to adjust the format used in the kernel accordingly. + Select Clang gcov format if building with Clang compiler. + config GCOV_FORMAT_3_4 bool "GCC 3.4 format" depends on CC_IS_GCC && GCC_VERSION < 40700@@ -68,11 +70,13 @@ config GCOV_FORMAT_3_4 config GCOV_FORMAT_4_7 bool "GCC 4.7 format" + depends on CC_IS_GCC ---help--- Select this option to use the format defined by GCC 4.7. config GCOV_FORMAT_CLANG bool "Clang format" + depends on CC_IS_CLANG ---help--- Select this option to use the format defined by Clang. --2.20.1.97.g81188d93c3-goog
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH 4/4] gcov: clang: pick GCC vs Clang format depending on compiler
Quoted 53 lines · Masahiro Yamada
Quoted 3 lines · Tri Vo
Clang gcov format is only supported by Clang compiler, and Clang compiler only supports Clang format.
If so, what is the point of putting
GCOV_FORMAT_CLANGinto the choice menu?You can choose the format only when you are using GCC.
I think the following is more sensible:
if
GCOV_KERNELconfig
GCOV_PROFILE_ALL....choice
prompt "Specify GCOV format for GCC"
depends onCC_IS_GCC
...config
GCOV_FORMAT_3_4
bool "GCC 3.4 format"
depends onGCC_VERSION< 40700
...config
GCOV_FORMAT_4_7
bool "GCC 4.7 format"
...endchoice
config
GCOV_FORMAT_CLANG
def_boolCC_IS_CLANGendif
Or, you can delete
GCOV_FORMAT_CLANG
if you write theMakefilelike follows:
Quoted 4 lines
obj-y := base.o fs.o obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_base.o gcc_3_4.o obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_base.o gcc_4_7.o
obj-$(CONFIG_CC_IS_CLANG) += clang.o
Thanks for the suggestion! It is more sensible than the current approach. I'll send an update.
Quoted 11 lines · Tri Vo
This patch series adds Clang supoprt for gcov.
Patch 1 refactors existing code in preparation for Clang support. Patches 2-3 implement necessary LLVM runtime hooks and gcov kernel interfaces. Patch 4 simplifies config selection.
Greg Hackmann (2):
gcov: clang: move common gcc code intogcc_base.c
gcov: clang support
Quoted 5 lines
Nick Desaulniers (1):
gcov: clang: link/unlink profiling data set.Tri Vo (1):
gcov: clang: pick GCC vs Clang format depending on compiler
Thanks for sending Tri! Doesn't the output format require llvm-cov, or no?
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 13 lines · Nick Desaulniers
Quoted 11 lines · Tri Vo
This patch series adds Clang supoprt for gcov.
Patch 1 refactors existing code in preparation for Clang support. Patches 2-3 implement necessary LLVM runtime hooks and gcov kernel interfaces. Patch 4 simplifies config selection.
Greg Hackmann (2):
gcov: clang: move common gcc code intogcc_base.c
gcov: clang support
Quoted 7 lines
Quoted 5 lines
Nick Desaulniers (1):
gcov: clang: link/unlink profiling data set.Tri Vo (1):
gcov: clang: pick GCC vs Clang format depending on compilerThanks for sending Tri! Doesn't the output format require llvm-cov, or no?
Yes, .gcda files generated by a Clang-built kernel could only be parsed by llvm-cov, but not gcc gcov (at least in my local tests).
llvm-cov documentation also indicates that GCC and LLVM gcov tools are not necessarily compatible. "[llvm-cov] is compatible with the gcov tool from version 4.2 of GCC and may also be compatible with some later versions of gcov."
https://llvm.org/docs/CommandGuide/llvm-cov.html
Quoted 24 lines · Tri Vo
Quoted 13 lines · Nick Desaulniers
Quoted 11 lines · Tri Vo
This patch series adds Clang supoprt for gcov.
Patch 1 refactors existing code in preparation for Clang support. Patches 2-3 implement necessary LLVM runtime hooks and gcov kernel interfaces. Patch 4 simplifies config selection.
Greg Hackmann (2):
gcov: clang: move common gcc code intogcc_base.c
gcov: clang supportQuoted 7 lines
Quoted 5 lines
Nick Desaulniers (1):
gcov: clang: link/unlink profiling data set.Tri Vo (1):
gcov: clang: pick GCC vs Clang format depending on compilerThanks for sending Tri! Doesn't the output format require llvm-cov, or no?
Quoted 8 lines
Yes, .gcda files generated by a Clang-built kernel could only be parsed by llvm-cov, but not gcc gcov (at least in my local tests).
llvm-cov documentation also indicates that GCC and LLVM gcov tools are not necessarily compatible. "[llvm-cov] is compatible with the gcov tool from version 4.2 of GCC and may also be compatible with some later versions of gcov."
https://llvm.org/docs/CommandGuide/llvm-cov.html
Thanks, that's good to know for folks looking to help test. Note to reviewers that we're actively using this patch set on arm64 devices.
Signature · 2 lines
Thanks, ~Nick Desaulniers