On Wed, Jul 06, 2022 at 03:25:51PM -0700, Dave Hansen wrote:
On 6/17/22 11:08, Nathan Chancellor wrote:
When clang is invoked without a '--target' flag, code is generated for the default target, which is usually the host (it is configurable via cmake). As a result, the has-stack-protector scripts will generate code for the default target but check for x86 specific segment registers, which cannot succeed if the default target is not x86.
I guess the real root cause here is the direct use of '$(CC)' without any other flags. Adding '$(CLANG_FLAGS)' seems like a pretty normal fix, like in scripts/Kconfig.include.
Right, also see the following commits for other areas where this was addressed.
58d746c119df ("efi/libstub: Add $(CLANG_FLAGS) to x86 flags") d5cbd80e302d ("x86/boot: Add $(CLANG_FLAGS) to compressed KBUILD_CFLAGS") 8abe7fc26ad8 ("x86/build: Propagate $(CLANG_FLAGS) to $(REALMODE_FLAGS)")
I suspect there's another one of these here:
arch/x86/um/vdso/Makefile: cmd_vdso = $(CC) -nostdlib -o $@
but I wouldn't be surprised if UML doesn't work with clang in the first place.
We have started testing UML with clang and it does work but I suspect there is little value to cross compiling a UML kernel, as it has to run in an x86 userland anyways, rather than through QEMU or other virtualization solutions. That is not something I plan to do anyways. If someone does and a fix similar to this one is needed, it can be done at that time.
Thank you for picking up this change!
Cheers, Nathan