Manjaro编译内核驱动报错:无法生成ORC元数据求助
Hey there, I know how frustrating it is when compilation issues block your kernel driver learning progress—let's get this sorted out for you.
First, Break Down the Issue
The error about missing ORC metadata tools is a bit misleading on Arch-based distros like Manjaro: the Debian/Ubuntu package names (libelf-dev, etc.) don't match Manjaro's. Even though you have libelf installed, you might be missing either the correct kernel headers or the full development components needed for kernel module compilation.
Step 1: Install Matching Kernel Headers for Your 4.15.18-1 Kernel
Manjaro uses version-specific kernel header packages. For your 4.15.18-1-MANJARO kernel, install the exact headers it needs:
sudo pacman -S linux415-headers
This ensures the /usr/lib/modules/4.15.18-1-MANJARO/build directory links to a complete, valid set of kernel headers.
Step 2: Fix the Kernel Build Symlink (If Broken)
Updates sometimes mess up the build symlink. Check where it points:
ls -l /usr/lib/modules/4.15.18-1-MANJARO/build
If it doesn't link to /usr/src/linux-4.15.18-1-MANJARO, recreate it:
sudo ln -sf /usr/src/linux-4.15.18-1-MANJARO /usr/lib/modules/4.15.18-1-MANJARO/build
Step 3: Reinstall Libelf to Restore Development Files
Even though pacman -Q shows libelf is installed, some critical development files might be corrupted or missing. Reinstall the package to fix this:
sudo pacman -S --reinstall libelf
This will restore files like /usr/include/libelf.h and /usr/lib/libelf.so that are required for generating ORC metadata.
Step 4: Workaround for the 4.17 Kernel's asm goto Issue
If you want to experiment with the 4.17 kernel later, the asm goto error comes from newer GCC versions being incompatible with that kernel's code. Install GCC 8 (which works with 4.17) and specify it during compilation:
sudo pacman -S gcc8 CC=gcc8 make
After following these steps, run your make command again—it should resolve the ORC metadata error and let you get back to your kernel driver programming.
内容的提问来源于stack exchange,提问作者user2807536

