Building kernel 5.3.1 with LLVM/clang 9.0.0 on riscv64
Building kernel 5.3.1-desktop-3omv4000
+ KernelVer=5.3.1-desktop-3omv4000
+ printf '%s\n' 'Building kernel 5.3.1-desktop-3omv4000'
+ ARCH=riscv
+ /usr/bin/make -O -j32 'LD=ld.lld --icf=none --no-gc-sections' 'HOSTLD=ld.lld --icf=none --no-gc-sections' all HOSTCC=clang HOSTCXX=clang++ CC=clang CXX=clang++ 'CFLAGS=-Os -fomit-frame-pointer -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -march=rv64imafdc -mabi=lp64d -O3' 'LDFLAGS=-Os -fomit-frame-pointer -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -march=rv64imafdc -mabi=lp64d -O3 -Wl,-O2 ' OBJCOPY=llvm-objcopy AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJDUMP=llvm-objdump HOSTAR=llvm-ar
BUILDSTDERR: make[2]: *** Deleting file 'scripts/basic/fixdep'
HOSTCC scripts/basic/fixdep
BUILDSTDERR: Hard-float 'd' ABI can't be used for a target that doesn't support the D instruction set extension (ignoring target-abi)
BUILDSTDERR: Hard-float 'd' ABI can't be used for a target that doesn't support the D instruction set extension (ignoring target-abi)
BUILDSTDERR: /lib/ld-linux-riscv64-lp64.so.1: No such file or directory
BUILDSTDERR: make[2]: *** [scripts/Makefile.host:90: scripts/basic/fixdep] Error 255
BUILDSTDERR: make[1]: *** [Makefile:505: scripts_basic] Error 2
BUILDSTDERR: make: *** [Makefile:678: include/config/auto.conf.cmd] Error 2
BUILDSTDERR: make: *** [include/config/auto.conf.cmd] Deleting file 'include/config/tristate.conf'
BUILDSTDERR: error: Bad exit status from /var/tmp/rpm-tmp.PEe51G (%build)
RPM build errors:
RISC-V just moved out of experimental in 9.0.0, I am sure there is a long list of things that need to be improved before it can compile the kernel. lowRISC mentioned that they eventually want to build the kernel with Clang which means we'll have some folks getting the stuff supported that we need in LLVM.
@tpgxyz do you have more build logs than those lines, or steps to reproduce this issue? It looks like somewhere is not passing -march correctly. I work on LLVM at @lowRISC and would be happy to help you get this working.
@lenary Yes i have more build logs here https://abf.openmandriva.org/openmandriva/kernel-release-clang/build_lists#?page=1&per_page=25&ownership=everything
Looks like our CFLAGS are not passed when running make on configs
+ CC=/usr/bin/gcc
+ export CC
+ CXX=/usr/bin/g++
+ export CXX
+ CFLAGS='-Os -fomit-frame-pointer -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -march=rv64imafdc -mabi=lp64d -O3'
+ export CFLAGS
+ CXXFLAGS='-Os -fomit-frame-pointer -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -march=rv64imafdc -mabi=lp64d -O3'
+ export CXXFLAGS
+ FFLAGS='-Os -fomit-frame-pointer -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -march=rv64imafdc -mabi=lp64d -O3'
+ export FFLAGS
+ FCFLAGS='-Os -fomit-frame-pointer -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -march=rv64imafdc -mabi=lp64d -O3'
+ export FCFLAGS
+ LDFLAGS='-Os -fomit-frame-pointer -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -march=rv64imafdc -mabi=lp64d -O3 -Wl,-O2 '
+ export LDFLAGS
+ CROSSCOMPILE='--target=riscv64-openmandriva-linux-gnu --build=riscv64-openmandriva-linux-gnu'
+ export CROSSCOMPILE
+ make V=1 ARCH=riscv CC=clang HOSTCC=clang HOSTCXX=clang++ CXX=clang++ OBJCOPY=llvm-objcopy AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJDUMP=llvm-objdump HOSTAR=llvm-ar defconfig common.config common-desktop.config
set -e; \
for i in defconfig common.config common-desktop.config; do \
/usr/bin/make -f ./Makefile $i; \
done
/usr/bin/make -f ./scripts/Makefile.build obj=scripts/basic
clang -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -o scripts/basic/fixdep scripts/basic/fixdep.c
BUILDSTDERR: Hard-float 'd' ABI can't be used for a target that doesn't support the D instruction set extension (ignoring target-abi)
BUILDSTDERR: Hard-float 'd' ABI can't be used for a target that doesn't support the D instruction set extension (ignoring target-abi)
BUILDSTDERR: /lib/ld-linux-riscv64-lp64.so.1: No such file or directory
BUILDSTDERR: make[2]: *** [scripts/Makefile.host:90: scripts/basic/fixdep] Error 255
BUILDSTDERR: make[2]: *** Deleting file 'scripts/basic/fixdep'
BUILDSTDERR: make[1]: *** [Makefile:505: scripts_basic] Error 2
BUILDSTDERR: make: *** [Makefile:330: __build_one_by_one] Error 2
BUILDSTDERR: error: Bad exit status from /var/tmp/rpm-tmp.KPcoj5 (%build)
Yeah, I think you've diagnosed the right issue - you need to be passing -march and -mabi everywhere, or the compiler will choose a default that may not match the default of the sysroot/libraries you have built.
@lenary How to pass these to Kbuild ?
KCFLAGS maybe? There seems to be kbuild info here: https://www.kernel.org/doc/Documentation/kbuild/kbuild.rst (I'm no kbuild expert, but this turned up after a quick google)
Please keep in mind, that it's not possible to compile RISC-V kernel with Clang 9.0.0 without patching.
You will need to apply this patch: https://github.com/ClangBuiltLinux/linux/issues/76#issuecomment-564017088 and remove the following lines:
https://github.com/ClangBuiltLinux/linux/blob/43a2898631a8beee66c1d64c1e860f43d96b2e91/arch/riscv/mm/init.c#L369-L371
https://github.com/ClangBuiltLinux/linux/blob/43a2898631a8beee66c1d64c1e860f43d96b2e91/arch/riscv/include/asm/bug.h#L47-L58
closing this; let's follow up with individual bug reports tagged with the riscv label.
Most helpful comment
RISC-V just moved out of experimental in 9.0.0, I am sure there is a long list of things that need to be improved before it can compile the kernel. lowRISC mentioned that they eventually want to build the kernel with Clang which means we'll have some folks getting the stuff supported that we need in LLVM.