Skip to content

[BUG] Make fails to build on CachyOS (clang) #363

@jutraim

Description

@jutraim

Problem Description
Self build from github, make fails to build.
Both lenovolegionlinux and lenovolegionlinux-git package fails to build the actual module silently.
Paru fails to build the actual module silently.

Model and Debug Info
Installation type: github, cachyos package. aur git package.
Distribution: CachyOS (Latest as of now)
Model name: Lenovo Legion 5 Pro 16IAH7H
CPU model: 12th Gen Intel(R) Core(TM) i7-12700H (20) @ 4.70 z
GPU model: NVIDIA GeForce RTX 3070 Mobile / Max-Q [Discrete]
GPU model: Intel Iris Xe Graphics @ 1.40 GHz [Integrated]
Keyboard backlight: I don't care
Light in lid or logo: Yes
Light at IO-Ports at back: Yes

This is the log for manual build from github (because the package fails silently):

~/LenovoLegionLinux/kernel_module heads/main
❯ make
make -C /lib/modules/6.17.6-2-cachyos/build M=/home/username/LenovoLegionLinux/kernel_module modules
make[1]: Entering directory '/usr/lib/modules/6.17.6-2-cachyos/build'
make[2]: Entering directory '/home/username/LenovoLegionLinux/kernel_module'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: clang version 21.1.4
  You are using:           gcc (GCC) 15.2.1 20250813
  CC [M]  legion-laptop.o
gcc: error: unrecognized command-line option ‘-mretpoline-external-thunk’
gcc: error: unrecognized command-line option ‘-fsplit-lto-unit’
make[4]: *** [/usr/lib/modules/6.17.6-2-cachyos/build/scripts/Makefile.build:287: legion-laptop.o] Error 1
make[3]: *** [/usr/lib/modules/6.17.6-2-cachyos/build/Makefile:2016: .] Error 2
make[2]: *** [/usr/lib/modules/6.17.6-2-cachyos/build/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory '/home/username/LenovoLegionLinux/kernel_module'
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/usr/lib/modules/6.17.6-2-cachyos/build'
make: *** [Makefile:13: all] Error 2

Tried forcing clang

~/LenovoLegionLinux/kernel_module heads/main
❯ make CC=clang
make -C /lib/modules/6.17.6-2-cachyos/build M=/home/username/LenovoLegionLinux/kernel_module modules
make[1]: Entering directory '/usr/lib/modules/6.17.6-2-cachyos/build'
make[2]: Entering directory '/home/username/LenovoLegionLinux/kernel_module'
  CC [M]  legion-laptop.o
legion-laptop.c:5047:6: warning: unused variable 'err' [-Wunused-variable]
 5047 |         int err;
      |             ^~~
legion-laptop.c:5926:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true
      [-Wsometimes-uninitialized]
 5926 |         if (!priv->adev) {
      |             ^~~~~~~~~~~
legion-laptop.c:5952:9: note: uninitialized use occurs here
 5952 |         return err;
      |                ^~~
legion-laptop.c:5926:2: note: remove the 'if' if its condition is always false
 5926 |         if (!priv->adev) {
      |         ^~~~~~~~~~~~~~~~~~
 5927 |                 dev_info(dev, "Could not get ACPI handle\n");
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 5928 |                 goto err_acpi_init;
      |                 ~~~~~~~~~~~~~~~~~~~
 5929 |         }
      |         ~
legion-laptop.c:5920:9: note: initialize the variable 'err' to silence this warning
 5920 |         int err;
      |                ^
      |                 = 0
legion-laptop.c:1856:16: warning: unused function 'ecram_memoryio_write' [-Wunused-function]
 1856 | static ssize_t ecram_memoryio_write(const struct ecram_memoryio *ec_memoryio,
      |                ^~~~~~~~~~~~~~~~~~~~
3 warnings generated.
ld: unrecognised emulation mode: llvm
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386pep i386pe elf64bpf
make[4]: *** [/usr/lib/modules/6.17.6-2-cachyos/build/scripts/Makefile.build:287: legion-laptop.o] Error 1
make[4]: *** Deleting file 'legion-laptop.o'
make[3]: *** [/usr/lib/modules/6.17.6-2-cachyos/build/Makefile:2016: .] Error 2
make[2]: *** [/usr/lib/modules/6.17.6-2-cachyos/build/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory '/home/username/LenovoLegionLinux/kernel_module'
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/usr/lib/modules/6.17.6-2-cachyos/build'
make: *** [Makefile:13: all] Error 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions