-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix building with clang and lld #13046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
406859f
to
10e486d
Compare
Good change overall! This patch will help experimenting with clang builds on Linux. |
10e486d
to
f3bde98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Works on my end with both gcc/ld.bfd and clang/ld.lld when building against a kernel built with the same toolchain.
f3bde98
to
ec59f35
Compare
ec59f35
to
44abfec
Compare
@Peter-Levine I just tried out this patch with 5.15.21 LLVM=1 built kernel. What bothers me is that while |
@Peter-Levine would you also mind rebasing this PR on the latest version of the master branch, then force updating the PR. This should get us a cleaner CI run to make sure all is well before merging it. |
@Peter-Levine Please consider incorporating szubersk@d21dba8 into this PR. I just tested that commit and compilation passes for clang-built 5.15.21 kernel. |
Currently, $(CC), $(LD), and $(LLVM) variables aren't passed to kbuild while building modules. This causes modules to build with the default GNU GCC toolchain and prevents experimenting with other toolchains such as CLANG/LLVM. It can also lead to build failure if the CFLAGS/LDFLAGS passed are incompatible with gcc/ld. Pass $KERNEL_CC, $KERNEL_LD, and $KERNEL_LLVM as $(CC), $(LD), and $(LLVM), respectively, to kbuild for each that is defined in the environment. This should take care of the majority of alternative toolchain use cases. Signed-off-by: Peter Levine <plevine457@gmail.com>
Authored by: Damian Szuberski <szuberskidamian@gmail.com> Signed-off-by: Peter Levine <plevine457@gmail.com>
44abfec
to
450e1dd
Compare
@szubersk PR is incorporated. |
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Authored-by: Damian Szuberski <szuberskidamian@gmail.com> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes #13046
Currently, $(CC), $(LD), and $(LLVM) variables aren't passed to kbuild while building modules. This causes modules to build with the default GNU GCC toolchain and prevents experimenting with other toolchains such as CLANG/LLVM. It can also lead to build failure if the CFLAGS/LDFLAGS passed are incompatible with gcc/ld. Pass $KERNEL_CC, $KERNEL_LD, and $KERNEL_LLVM as $(CC), $(LD), and $(LLVM), respectively, to kbuild for each that is defined in the environment. This should take care of the majority of alternative toolchain use cases. Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Authored-by: Damian Szuberski <szuberskidamian@gmail.com> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
Currently, $(CC), $(LD), and $(LLVM) variables aren't passed to kbuild while building modules. This causes modules to build with the default GNU GCC toolchain and prevents experimenting with other toolchains such as CLANG/LLVM. It can also lead to build failure if the CFLAGS/LDFLAGS passed are incompatible with gcc/ld. Pass $KERNEL_CC, $KERNEL_LD, and $KERNEL_LLVM as $(CC), $(LD), and $(LLVM), respectively, to kbuild for each that is defined in the environment. This should take care of the majority of alternative toolchain use cases. Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Authored-by: Damian Szuberski <szuberskidamian@gmail.com> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
Currently, $(CC), $(LD), and $(LLVM) variables aren't passed to kbuild while building modules. This causes modules to build with the default GNU GCC toolchain and prevents experimenting with other toolchains such as CLANG/LLVM. It can also lead to build failure if the CFLAGS/LDFLAGS passed are incompatible with gcc/ld. Pass $KERNEL_CC, $KERNEL_LD, and $KERNEL_LLVM as $(CC), $(LD), and $(LLVM), respectively, to kbuild for each that is defined in the environment. This should take care of the majority of alternative toolchain use cases. Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Authored-by: Damian Szuberski <szuberskidamian@gmail.com> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
The needed patch made its way upstream but we need a small amount of logic in the ebuild to accommodate it fully. Bug: openzfs/zfs#13046 Closes: https://bugs.gentoo.org/814194 Thanks-to: Peter Levine <plevine457@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
Currently, $(CC), $(LD), and $(LLVM) variables aren't passed to kbuild while building modules. This causes modules to build with the default GNU GCC toolchain and prevents experimenting with other toolchains such as CLANG/LLVM. It can also lead to build failure if the CFLAGS/LDFLAGS passed are incompatible with gcc/ld. Pass $KERNEL_CC, $KERNEL_LD, and $KERNEL_LLVM as $(CC), $(LD), and $(LLVM), respectively, to kbuild for each that is defined in the environment. This should take care of the majority of alternative toolchain use cases. Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Authored-by: Damian Szuberski <szuberskidamian@gmail.com> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
Currently, $(CC), $(LD), and $(LLVM) variables aren't passed to kbuild while building modules. This causes modules to build with the default GNU GCC toolchain and prevents experimenting with other toolchains such as CLANG/LLVM. It can also lead to build failure if the CFLAGS/LDFLAGS passed are incompatible with gcc/ld. Pass $KERNEL_CC, $KERNEL_LD, and $KERNEL_LLVM as $(CC), $(LD), and $(LLVM), respectively, to kbuild for each that is defined in the environment. This should take care of the majority of alternative toolchain use cases. Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Authored-by: Damian Szuberski <szuberskidamian@gmail.com> Signed-off-by: Peter Levine <plevine457@gmail.com> Closes openzfs#13046
The needed patch made its way upstream but we need a small amount of logic in the ebuild to accommodate it fully. Bug: openzfs/zfs#13046 Closes: https://bugs.gentoo.org/814194 Thanks-to: Peter Levine <plevine457@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
Explicitly pass CC and LD when building modules to prevent kbuild from defaulting to gcc and ld.bfd.
Motivation and Context
Fixes 10107
Description
When building
sys-fs/zfs-kmod-9999
on Gentoo Linux, configure fails with:config.log shows:
build/conftest/build.log shows:
The offending code is from config/kernel.m4:
kbuild doesn't parse CC, LD, et al., from the environment but expects the to be explicitly passed to
make
.Similarly, the build fails to compile, with
The offending code is from module/Makefile.in:
Again, this is resolved by explicitly passing
CC
andLD
.How Has This Been Tested?
Tested using
/etc/portage/patches/sys-fs/zfs-kmod-9999/zfs-kmod-9999-clang.patch
:and
/etc/portage/patches/sys-fs/zfs-kmod-9999/zfs-kmod-9999-clang2.patch
:then
ebuild /var/db/repos/local/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild merge
Types of changes
Checklist:
Signed-off-by
.