Skip to content
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

allow zenpower to build with clang #11

Open
mrturcot opened this issue Dec 28, 2022 · 2 comments
Open

allow zenpower to build with clang #11

mrturcot opened this issue Dec 28, 2022 · 2 comments
Assignees
Labels

Comments

@mrturcot
Copy link

Hey, so I use clang to compile my kernel

cat /proc/version
Linux version 6.1.1-gentoo-filthy (root@GentooRig) (clang version 15.0.6, LLD 15.0.6) #1 SMP PREEMPT_DYNAMIC Wed Dec 28 12:17:33 PST 2022

This module fails to build while im using a clang-kernel. I have added zenpower to my clang-env as defined in portage/env & portage/package.env. (my clang-env https://github.com/mrturcot/Gentoo-Stuff/blob/master/portage/env/compiler-clang) It still tries uses GCC to build.... Can we detect the toolchain used to build kernel and use the necessary compiler to build module?

Similar issue that was resolved I had with xone kernel module https://gitlab.com/src_prepare/src_prepare-overlay/-/issues/43

ISSUE

warning: the compiler differs from the one used to build the kernel
  The kernel was built by: clang version 15.0.6
  You are using:           gcc (Gentoo 11.3.1_p20221209 p3) 11.3.1 20221209

Build Log

 ❯ emerge -1av sys-kernel/zenpower::dev1990-overlay

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N    ~] sys-kernel/zenpower-0.1.12::dev1990-overlay  USE="-dist-kernel" 0 KiB

Total: 1 package (1 new), Size of downloads: 0 KiB

Would you like to merge these packages? [Yes/No] 

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sys-kernel/zenpower-0.1.12::dev1990-overlay
 * zenpower-0.1.12.tar.gz BLAKE2B SHA512 size ;-) ...                                                                                                                  [ ok ]
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     6.1.1-gentoo-filthy
 * Checking for suitable kernel configuration options ...                                                                                                              [ ok ]
>>> Unpacking source...
>>> Unpacking zenpower-0.1.12.tar.gz to /var/tmp/portage/sys-kernel/zenpower-0.1.12/work
>>> Source unpacked in /var/tmp/portage/sys-kernel/zenpower-0.1.12/work
>>> Preparing source in /var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12 ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12 ...
ln: failed to create symbolic link 'Module.symvers': File exists
 * Preparing zenpower module
make -j12 HOSTCC=clang 'LDFLAGS=-m elf_x86_64' modules 
make[1]: Entering directory '/usr/src/linux-6.1.1-gentoo'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: clang version 15.0.6
  You are using:           x86_64-pc-linux-gnu-gcc (Gentoo 11.3.1_p20221209 p3) 11.3.1 20221209
  CC [M]  /var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12/zenpower.o
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-Qunused-arguments’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-mretpoline-external-thunk’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-fsplit-lto-unit’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-Wformat-invalid-specifier’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-Wformat-insufficient-args’
make[2]: *** [scripts/Makefile.build:250: /var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12/zenpower.o] Error 1
make[1]: *** [Makefile:1992: /var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12] Error 2
make[1]: Leaving directory '/usr/src/linux-6.1.1-gentoo'
make: *** [Makefile:27: modules] Error 2
 * ERROR: sys-kernel/zenpower-0.1.12::dev1990-overlay failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=sys-kernel/zenpower-0.1.12::dev1990-overlay'`,
 * the complete build log and the output of `emerge -pqv '=sys-kernel/zenpower-0.1.12::dev1990-overlay'`.
 * The complete build log is located at '/var/log/portage/sys-kernel:zenpower-0.1.12:20221228-202346.log'.
 * For convenience, a symlink to the build log is located at '/var/tmp/portage/sys-kernel/zenpower-0.1.12/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-kernel/zenpower-0.1.12/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12'
 * S: '/var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12'

>>> Failed to emerge sys-kernel/zenpower-0.1.12, Log file:

>>>  '/var/log/portage/sys-kernel:zenpower-0.1.12:20221228-202346.log'

 * Messages for package sys-kernel/zenpower-0.1.12:
 * Log file: /var/log/portage/sys-kernel:zenpower-0.1.12:20221228-202346.log

 * Package:    sys-kernel/zenpower-0.1.12:0
 * Repository: dev1990-overlay
 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU
 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     6.1.1-gentoo-filthy
 * Checking for suitable kernel configuration options ...
 * Preparing zenpower module
 * ERROR: sys-kernel/zenpower-0.1.12::dev1990-overlay failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=sys-kernel/zenpower-0.1.12::dev1990-overlay'`,
 * the complete build log and the output of `emerge -pqv '=sys-kernel/zenpower-0.1.12::dev1990-overlay'`.
 * The complete build log is located at '/var/log/portage/sys-kernel:zenpower-0.1.12:20221228-202346.log'.
 * For convenience, a symlink to the build log is located at '/var/tmp/portage/sys-kernel/zenpower-0.1.12/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-kernel/zenpower-0.1.12/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12'
 * S: '/var/tmp/portage/sys-kernel/zenpower-0.1.12/work/zenpower-0.1.12'
@dev-0x7C6 dev-0x7C6 self-assigned this Dec 29, 2022
@dev-0x7C6 dev-0x7C6 added the bug label Dec 29, 2022
@dev-0x7C6
Copy link
Owner

Hi,

I'm using inherit linux-info linux-mod which are standard eclasses to handle kernel module compilation, probably they should be extended in future to support clang toolchain. I'll try to fix ebuild, but unfortunately this will be blind attempt, since I don't have clang environment.

@mrturcot
Copy link
Author

Okay! Maybe I should file a bug there also? But I think this will suffice for now. It's a fairly simple issue correct?

I'll be happy to test if/when ready. Best regards

Repository owner deleted a comment from tim-tepia Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants