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

Compiling your own kernel module πŸ—οΈ #2919

Open
peter-power-594 opened this issue May 24, 2023 · 7 comments
Open

Compiling your own kernel module πŸ—οΈ #2919

peter-power-594 opened this issue May 24, 2023 · 7 comments
Labels
enhancement New feature or request in progress The issue is being processed ROME/rolling OpenMandriva ROME

Comments

@peter-power-594
Copy link

peter-power-594 commented May 24, 2023

Ladies & Gentlemen from OM,

I 'm trying to use DKMS with OpenMandriva ROME 23 latest version to build the module to add keyboard / trackpad / audio support for my macbook air 2020. (Apple Intel with T2 chip)
The repo used is the following : https://github.com/t2linux/apple-bce-drv (Branch AUR)

When I was on the OM 4.3x Rock I was able to build it with success πŸ’ͺ I published my log a few weeks ago :
https://french-touch.de-14h09.tk/keyboard-and-trackpad-for-a-linux-macbook-with-the-t2-security-chip-97f0019c39c7
I guess it was using gcc11 at this time ?

Now with the rome edition, looks like everything was switch to clang and got some issues. When compiling with GCC, it's complaining to not understand "clangish" stuff and if tried manually with clang, it's complaining about "gccish" stuff πŸ˜’

Here is the log :

[pierre@concorde src]$ sudo dkms install apple-bce/0.1

Creating symlink /var/lib/dkms/apple-bce/0.1/source ->
                 /usr/src/apple-bce-0.1

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j4 KERNELRELEASE=6.2.6-desktop-1omv2390...(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.2.6-desktop-1omv2390 (x86_64)
Consult /var/lib/dkms/apple-bce/0.1/build/make.log for more information.
[pierre@concorde src]$ cat /var/lib/dkms/apple-bce/0.1/build/make.log
DKMS make.log for apple-bce-0.1 for kernel 6.2.6-desktop-1omv2390 (x86_64)
mar. 23 mai 2023 10:19:08 JST
make -C /lib/modules/6.2.6-desktop-1omv2390/source M=/var/lib/dkms/apple-bce/0.1/build modules
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: OpenMandriva 15.0.7-3 clang version 15.0.7 (/builddir/build/BUILD/llvm-project-15.0.7.src/clang c5b761db9d28a8cbbafbaa455d57066c5a0e42bc)
  You are using:           gcc (GCC) 12.2.0 20220819 (OpenMandriva)
  CC [M]  /var/lib/dkms/apple-bce/0.1/build/apple_bce.o
  CC [M]  /var/lib/dkms/apple-bce/0.1/build/mailbox.o
  CC [M]  /var/lib/dkms/apple-bce/0.1/build/queue.o
  CC [M]  /var/lib/dkms/apple-bce/0.1/build/queue_dma.o
gcc: erreur: option Β« -Qunused-arguments Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -Qunused-arguments Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -Qunused-arguments Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -Qunused-arguments Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -mretpoline-external-thunk Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -mretpoline-external-thunk Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -mretpoline-external-thunk Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -mretpoline-external-thunk Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -fsplit-lto-unit Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -fsplit-lto-unit Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -fsplit-lto-unit Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -fsplit-lto-unit Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -Wformat-invalid-specifier Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -Wformat-invalid-specifier Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -Wformat-invalid-specifier Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -Wformat-invalid-specifier Β» non reconnue sur la ligne de commande
gcc: erreur: option Β« -Wformat-insufficient-args Β» non reconnue sur la ligne de commande
make[2]: *** [scripts/Makefile.build:252: /var/lib/dkms/apple-bce/0.1/build/apple_bce.o] エラー 1
make[2]: *** Attente des tΓ’ches non terminΓ©es....
gcc: erreur: option Β« -Wformat-insufficient-args Β» non reconnue sur la ligne de commande
make[2]: *** [scripts/Makefile.build:252: /var/lib/dkms/apple-bce/0.1/build/mailbox.o] エラー 1
gcc: erreur: option Β« -Wformat-insufficient-args Β» non reconnue sur la ligne de commande
make[2]: *** [scripts/Makefile.build:252: /var/lib/dkms/apple-bce/0.1/build/queue.o] エラー 1
gcc: erreur: option Β« -Wformat-insufficient-args Β» non reconnue sur la ligne de commande
make[2]: *** [scripts/Makefile.build:252: /var/lib/dkms/apple-bce/0.1/build/queue_dma.o] エラー 1
make[1]: *** [Makefile:2021: /var/lib/dkms/apple-bce/0.1/build] エラー 2
make: *** [Makefile:22: all] エラー 2

I have no idea what need to be patched.
Is there an existing config / switch to make it build with GCC instead of clang ?
Or files need to be adjusted manually one by one ?

Thank you in advance for your help.

PS: No urge, at work I’m using an external usb keyboard so it’s fine,
but at home or remotely I can't use the laptop anymore without an external keyboard 🀑

@peter-power-594 peter-power-594 added enhancement New feature or request new New bug submitted labels May 24, 2023
@tpgxyz
Copy link
Member

tpgxyz commented May 25, 2023

Hi @peter-power-594 thanks for your report.
Well we stop building kernel with gcc, so this means no gcc kernel-devel. As you may have noticed dkms tries to compile that external module with gcc, and this compiler finds flags from kernel-devel that are unknow to it. You may try to pass -Wno-error= to your CFLAGS or MY_CFLAGS with some values.

Other way is to try to compile that external module with LLVM/clang, which may lead to fixing the code of that external module :)

@peter-power-594
Copy link
Author

Thank you for your reply @tpgxyz, in this case I'm gonna try to ask for help on the original git repository.

@peter-power-594
Copy link
Author

@tpgxyz Guess what ? It's working ! ! !
Following this talk :
dell/dkms#124 (comment)

By customizing a bit the dkms file with :

make CC=clang CXX=clang++ LD=ld.lld AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJSIZE=llvm-size STRIP=llvm-strip

The build succeeded ! The keyboard and audio is working right now it's amazingly cooooll !
The trackpad did not work, looks like a patch is needed, using an external mouse even outside so it's ok for me.

@omakuta
Copy link
Collaborator

omakuta commented May 26, 2023

This issue has been mentioned on OpenMandriva forum. There might be relevant details there:

https://forum.openmandriva.org/t/use-dkms-with-openmandriva-rome-23/4927/3

@peter-power-594
Copy link
Author

Following the dkms-broadcom example and other packages, I tried to created the spec file :
https://github.com/peter-power-594/om-apple-bce/blob/dev/dkms-apple-bce.spec

Followed a few tutorials online but couldn't figure out how to test it.
Like emulating the source fetch + compiling, etc....

When you can, poke me :-) Cheers

Peter

@rugyada rugyada added ROME/rolling OpenMandriva ROME and removed new New bug submitted labels Sep 23, 2023
@benbullard79 benbullard79 added the in progress The issue is being processed label Sep 26, 2023
@benbullard79
Copy link

Following the dkms-broadcom example and other packages, I tried to created the spec file : https://github.com/peter-power-594/om-apple-bce/blob/dev/dkms-apple-bce.spec

Followed a few tutorials online but couldn't figure out how to test it. Like emulating the source fetch + compiling, etc....

When you can, poke me :-) Cheers

Peter

Hope you get poked and this gets resolved soon.

@peter-power-594
Copy link
Author

The original repo has been updated, patches are not needed anymore.
Only the dkms file is missing to make the process smoother.
I updated my README for now : https://github.com/peter-power-594/apple-bce-drv

My spec file won't work by the way :-P, I will catch up later for the cooking part!
The most important is I can use my keyboard so I can work ! ! !

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in progress The issue is being processed ROME/rolling OpenMandriva ROME
Projects
None yet
Development

No branches or pull requests

5 participants