On 12/10/20 5:10 PM, Andrew Delgadillo wrote:
On Thu, Dec 10, 2020 at 3:08 PM Nick Desaulniers ndesaulniers@google.com wrote:
On Thu, Dec 3, 2020 at 2:10 PM Andrew Delgadillo adelg@google.com wrote:
lib.mk defaults to gcc when CC is not set. When building selftests as part of a kernel compilation, MAKEFLAGS is cleared to allow implicit build rules to be used. This has the side-effect of clearing the CC variable, which will cause selftests to be built with gcc regardless of if we are using gcc or clang. To remedy this, propagate the CC variable when clearing makeflags to ensure the correct compiler is used.
Signed-off-by: Andrew Delgadillo adelg@google.com
Hi Andrew, thanks for the patch. Can you walk me through how to build the selftests?
Documentation/dev-tools/kselftest.rst says: $ make -C tools/testing/selftests
And if I do: $ make CC=clang defconfig $ make CC=clang -C tools/testing/selftests -j
I observe a spew of errors. If I apply your patch and rerun the above, I see what looks like the same spew of errors. Am I "holding it wrong" or could the docs use a refresh?
Hi Nick, sure thing!
I also see a slew of errors when building with make -C tools/testing/selftests. However, that is not the problem I am trying to solve. I believe we are seeing errors building that way because it is missing some make variables that are normally set up when building from the kernel's top level makefile.
Both options are supported and should work.
make -C tools/testing/selftests make kselftest
That being said, I use gcc. Can you send the errors you are seeing? It is possible, a few tests aren't building and need to be fixed for clang and gcc.
thanks, -- Shuah