Linux: missing gcov support

Created on 26 Apr 2018  路  14Comments  路  Source: ClangBuiltLinux/linux

Report from QC:

xyz.c:(.text+0x1804): undefined reference to `llvm_gcda_emit_function'

xyz.c:(.text+0x1814): undefined reference to `llvm_gcda_emit_arcs'

xyz.c:(.text+0x1834): undefined reference to `llvm_gcda_emit_function'

xyz.c:(.text+0x1844): undefined reference to `llvm_gcda_emit_arcs'

xyz.c:(.text+0x1848): undefined reference to `llvm_gcda_summary_info'

xyz.c:(.text+0x1858): undefined reference to `llvm_gcda_end_file'

xyz.o: In function `__llvm_gcov_init':

xyz.c:(.text+0x1a28): undefined reference to `llvm_gcov_init'
[BUG] linux [FIXED][LINUX] 5.2

All 14 comments

As Nick mentioned in the email thread, this came up before. Linking in 'compiler_rt' should resolve the missing symbols.

https://groups.google.com/forum/#!topic/llvm-dev/4AlWT2VrkMk

Here's the first patch needed: https://lkml.org/lkml/2018/4/26/974

will need another for the missing symbols.

Temp patches have been created to add kernel helper functions for runtime support of gcov in the kernel. QC is testing, but they could use more polish before trying to upstream. Will try to get around to it with more time.

Pushed patches to https://github.com/ClangBuiltLinux/linux/tree/gcov. Still testing.

CONFIG_GCOV_KERNEL=y
CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
CONFIG_GCOV_PROFILE_ALL=y
# CONFIG_GCOV_FORMAT_4_7 is not set
CONFIG_GCOV_FORMAT_CLANG=y
$ mount -t debugfs none /sys/kernel/debug
$ ls /sys/kernel/debug/gcov/<path/to/>*.gcda
$ qemu-system-aarch64 -kernel arch/arm64/boot/Image -machine virt -cpu cortex-a57 -hda /android1/buildroot/output/images/rootfs.ext2 -append "console=ttyAMA0 earlyprintk=ttyAMA0 root=/dev/vda"  -serial mon:stdio -m 512 -nographic -redir tcp:2222::22 &
$ scp -P 2222 <user>@localhost:/path/to/*.gcda .
$ llvm-cov gcov -f -b *.gcda

@vo4 just sent patches upstream:

reopening until this hits mainline.

馃憤 馃帀 This was the last topic I have seen to reach allyesconfig on x86 from the kernel side. Now, only asm-goto needs to get into clang-9. 馃憤

Tri's fix for CONFIG_MODULES=n was just accepted. Will post link once I can find it.

For context, the gcov patches got backed out due to a 0day bot report.

Btw, how are cross-tree patches are handled in linux? CONFIG_MODULES=n fix will probably be in modules tree. Should we ask akpm to take gcov patches into mm tree?

Btw, how are cross-tree patches are handled in linux?

Good question; it would be great not to have to wait for the modules patch to hit mainline. Would you responding to the thread w/ Jessice cc'ing akpm and ask them?

Btw, how are cross-tree patches are handled in linux?

Usually, maintainer A gives their "Acked-by" and maintainer B carries the patch. In this instance, Andrew should probably carry the modules patch with Jessica's ack since the gcov series is bigger.

Was this page helpful?
0 / 5 - 0 ratings