[Linux-v5.19-rc1] perf: Errors in util/unwind-libunwind-local.c with LLVM-14

From: Sedat Dilek
Date: Mon Jun 06 2022 - 15:33:54 EST


Hi,

with LLVM-14 version 14.0.4 and my kernel-config (attached) I see on
Debian/unstable AMD64 the below errors.
( This is independent of my tools/gnu11 patchset - -std=gnu89 shows
the same errors .)

[ Toolchain and misc settings ]
LLVM MVER ........ 14
Path settings ....
/opt/llvm-toolchain/bin:/opt/proxychains-ng/bin:/home/dileks/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Python version ... 3.10
make line ........ make V=1 -j4 HOSTCC=clang HOSTLD=ld.lld
HOSTAR=llvm-ar CC=clang LD=ld.lld AR=llvm-ar STRIP=llvm-strip

[...]
clang -Wp,-MD,util/.unwind-libunwind.o.d
-Wp,-MT,util/unwind-libunwind.o -Wbad-function-cast
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k
-Winit-self
-Wmissing-declarations -Wmissing-prototypes -Wno-system-headers
-Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes
-Wswitch-default -Wswitch-enum -
Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wshadow
-DHAVE_SYSCALL_TABLE_SUPPORT -DHAVE_ARCH_X86_64_SUPPORT
-Iarch/x86/include/generated -DHAVE_PERF_REGS_SUPPORT
-DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET -Werror -O3
-fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra
-std=gnu11 -fstack-protector-all -D_FORTIFY_SOURCE=2 -
D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
-I/home/dileks/src/linux-kernel/git/tools/lib/perf/include
-I/home/dileks/src/linux-kernel/git/tools/perf/uti
l/include -I/home/dileks/src/linux-kernel/git/tools/perf/arch/x86/include
-I/home/dileks/src/linux-kernel/git/tools/include/
-I/home/dileks/src/linux-kernel/git/tools/
arch/x86/include/uapi
-I/home/dileks/src/linux-kernel/git/tools/include/uapi
-I/home/dileks/src/linux-kernel/git/tools/arch/x86/include/
-I/home/dileks/src/linux-kerne
l/git/tools/arch/x86/
-I/home/dileks/src/linux-kernel/git/tools/perf/util
-I/home/dileks/src/linux-kernel/git/tools/perf
-I/home/dileks/src/linux-kernel/git/tools/lib/
-DHAVE_PTHREAD_ATTR_SETAFFINITY_NP -DHAVE_PTHREAD_BARRIER
-DHAVE_EVENTFD_SUPPORT -DHAVE_GET_CURRENT_DIR_NAME -DHAVE_GETTID
-DHAVE_FILE_HANDLE -DHAVE_DWARF_GETLOCATION
S_SUPPORT -DHAVE_GLIBC_SUPPORT -DHAVE_AIO_SUPPORT
-DHAVE_SCHED_GETCPU_SUPPORT -DHAVE_SETNS_SUPPORT -DHAVE_LIBELF_SUPPORT
-DHAVE_ELF_GETPHDRNUM_SUPPORT -DHAVE_GELF_GETN
OTE_SUPPORT -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT -DHAVE_DWARF_SUPPORT
-DHAVE_LIBBPF_SUPPORT -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
-DHAVE_LIBBPF_BPF_PROG_LOAD -DHAVE_LI
BBPF_BPF_OBJECT__NEXT_PROGRAM -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
-DHAVE_LIBBPF_BTF__RAW_DATA -DHAVE_LIBBPF_BPF_MAP_CREATE
-DHAVE_BPF_PROLOGUE -DHAVE_SDT_EVENT -DHAVE_J
ITDUMP -DHAVE_DWARF_UNWIND_SUPPORT -DNO_LIBUNWIND_DEBUG_FRAME
-DHAVE_LIBUNWIND_SUPPORT -DHAVE_LIBCRYPTO_SUPPORT -DHAVE_SLANG_SUPPORT
-DHAVE_LIBPERL_SUPPORT -Wno-compou
nd-token-split-by-macro -DHAVE_TIMERFD_SUPPORT
-DHAVE_LIBPYTHON_SUPPORT -DHAVE_LIBBFD_BUILDID_SUPPORT
-DHAVE_CPLUS_DEMANGLE_SUPPORT -DHAVE_LIBBFD_SUPPORT -DHAVE_ZLIB_S
UPPORT -DHAVE_LZMA_SUPPORT -DHAVE_ZSTD_SUPPORT -DHAVE_LIBCAP_SUPPORT
-DHAVE_BACKTRACE_SUPPORT -DHAVE_LIBNUMA_SUPPORT
-DHAVE_KVM_STAT_SUPPORT -DDISASM_FOUR_ARGS_SIGNATU
RE -DHAVE_PERF_READ_VDSO32 -DHAVE_PERF_READ_VDSOX32
-DHAVE_LIBBABELTRACE_SUPPORT -DHAVE_AUXTRACE_SUPPORT
-D"BUILD_STR(s)=#s" -c -o util/unwind-libunwind.o util/unwind-
libunwind.c
util/unwind-libunwind-local.c:186:6: error: variable 'ret' is used
uninitialized whenever 'if' condition is true
[-Werror,-Wsometimes-uninitialized]
if (!elf_section_by_name(elf, &ehdr, &shdr, name, NULL))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/unwind-libunwind-local.c:194:9: note: uninitialized use occurs here
return ret;
^~~
util/unwind-libunwind-local.c:186:2: note: remove the 'if' if its
condition is always false
if (!elf_section_by_name(elf, &ehdr, &shdr, name, NULL))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/unwind-libunwind-local.c:183:6: error: variable 'ret' is used
uninitialized whenever 'if' condition is true
[-Werror,-Wsometimes-uninitialized]
if (gelf_getehdr(elf, &ehdr) == NULL)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/unwind-libunwind-local.c:194:9: note: uninitialized use occurs here
return ret;
^~~
util/unwind-libunwind-local.c:183:2: note: remove the 'if' if its
condition is always false
if (gelf_getehdr(elf, &ehdr) == NULL)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/unwind-libunwind-local.c:177:9: note: initialize the variable
'ret' to silence this warning
int ret;
^
= 0
2 errors generated.

I had no deeper look into this.

If you need further information, please let me know.

Thanks.

Regards,
-Sedat-

P.S.: Noticed a lot of `diff -u` to header files at the beginning of my build.

Attachment: config-5.19.0-rc1-1-amd64-clang14-lto
Description: Binary data

Attachment: make-log_perf-python3.10-install_bin.txt.zst
Description: application/zstd

Attachment: make-log_perf-python3.10-install_bin.txt.zst.sha256
Description: Binary data

Attachment: patches.series
Description: Binary data