clang-17: selftests: vdso_standalone_test_x86.c:(.text+0x1e6): undefined reference to `memcpy'

From: Naresh Kamboju
Date: Mon Aug 21 2023 - 09:33:20 EST


Recently we have updated toolchain clang-17 version.

While building selftests vdso following warnings / errors noticed on the
Linux next with clang-17. but pass with gcc-13.

Reported-by: Linux Kernel Functional Testing <lkft@xxxxxxxxxx>

make[4]: Entering directory 'tools/testing/selftests/vDSO'
clang --target=x86_64-linux-gnu -fintegrated-as
-Werror=unknown-warning-option -Werror=ignored-optimization-argument
-Werror=option-ignored -Werror=unused-command-line-argument
--target=x86_64-linux-gnu -fintegrated-as -std=gnu99 -nostdlib
-fno-asynchronous-unwind-tables -fno-stack-protector \
vdso_standalone_test_x86.c parse_vdso.c \
-o /vDSO/vdso_standalone_test_x86
vdso_standalone_test_x86.c:73:16: warning: unknown attribute
'externally_visible' ignored [-Wunknown-attributes]
73 | __attribute__((externally_visible)) void c_main(void **stack)
| ^~~~~~~~~~~~~~~~~~
1 warning generated.
parse_vdso.c:65:9: warning: using the result of an assignment as a
condition without parentheses [-Wparentheses]
65 | if (g = h & 0xf0000000)
| ~~^~~~~~~~~~~~~~~~
parse_vdso.c:65:9: note: place parentheses around the assignment to
silence this warning
65 | if (g = h & 0xf0000000)
| ^
| ( )
parse_vdso.c:65:9: note: use '==' to turn this assignment into an
equality comparison
65 | if (g = h & 0xf0000000)
| ^
| ==
parse_vdso.c:206:22: warning: passing 'const char *' to parameter of
type 'const unsigned char *' converts between pointers to integer
types where one is of the unique plain 'char' type and the other is
not [-Wpointer-sign]
206 | ver_hash = elf_hash(version);
| ^~~~~~~
parse_vdso.c:59:52: note: passing argument to parameter 'name' here
59 | static unsigned long elf_hash(const unsigned char *name)
| ^
parse_vdso.c:207:46: warning: passing 'const char *' to parameter of
type 'const unsigned char *' converts between pointers to integer
types where one is of the unique plain 'char' type and the other is
not [-Wpointer-sign]
207 | ELF(Word) chain = vdso_info.bucket[elf_hash(name) %
vdso_info.nbucket];
| ^~~~
parse_vdso.c:59:52: note: passing argument to parameter 'name' here
59 | static unsigned long elf_hash(const unsigned char *name)
| ^
3 warnings generated.
/usr/bin/x86_64-linux-gnu-ld: /tmp/vdso_standalone_test_x86-31b09f.o:
in function `c_main':
vdso_standalone_test_x86.c:(.text+0x1e6): undefined reference to `memcpy'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: Leaving directory 'tools/testing/selftests/vDSO'

Links:
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2UHhSg0TPLhjp9Uq9EFceoQd0VL/
- https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230821/testrun/19213783/suite/kselftest-vDSO/test/shardfile-vDSO/details/

Steps to reproduce:
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2UHhSg0TPLhjp9Uq9EFceoQd0VL/tuxmake_reproducer.sh

tuxmake --runtime podman --target-arch x86_64 --toolchain clang-17
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2UHhSg0TPLhjp9Uq9EFceoQd0VL/config
LLVM=1 LLVM_IAS=1 debugkernel cpupower headers kernel kselftest
modules


--
Linaro LKFT
https://lkft.linaro.org