error: asm/asm-offsets.h: No such file or directory

While building compcache 0.6.2 on Ubuntu Lucid Lynx (10.04) with 64-bit Linux kernel 2.6.32-305-ec2, I saw this error.

ubuntu@ip-10-218-39-204:/tmp/compcache-0.6.2$ make
make -C "/lib/modules/2.6.32-305-ec2/build" M=/tmp/compcache-0.6.2 modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-305-ec2'
  CC [M]  /tmp/compcache-0.6.2/ramzswap_drv.o
In file included from /usr/src/linux-headers-2.6.32-305-ec2/arch/x86/include/asm/unistd.h:5,
                 from include/linux/unistd.h:7,
                 from /usr/src/linux-headers-2.6.32-305-ec2/arch/x86/include/asm/seccomp_64.h:4,
                 from /usr/src/linux-headers-2.6.32-305-ec2/arch/x86/include/asm/seccomp.h:4,
                 from include/linux/seccomp.h:8,
                 from include/linux/sched.h:80,
                 from include/linux/blkdev.h:6,
                 from /tmp/compcache-0.6.2/ramzswap_drv.c:21:
/usr/src/linux-headers-2.6.32-305-ec2/arch/x86/include/asm/unistd_64.h:693:29: error: asm/asm-offsets.h: No such file or directory

I believe this is an error in the 64-bit 2.6.32 kernel, so you would see this on other distributions (e.g., Gentoo, Slackware) and while compiling other kernel modules (e.g., VMWare, OpenAFS, drbd8). The good news is there is an easy fix.

Edit unistd_64.h. To find the right file depending on your kernel, use this command (assuming you want to use vim).

sudo vim /usr/src/linux-headers-`uname -r`/arch/x86/include/asm/unistd_64.h

Then find the spot that looks like this (which is line 693 according to the build error above):

#ifndef COMPILE_OFFSETS
#include <asm/asm-offsets.h>
#define NR_syscalls (__NR_syscall_max + 1)
#endif

Then change asm/ to asm-x86/ so it looks like this:

#include <asm-x86/asm-offsets.h>

Then save, exit the editor, and try compiling again.

UPDATE From the comment link, Anders Kaseorg gives a simpler fix (slightly modified):

sudo ln -nsf /usr/src/linux-headers-`uname -r`/include/asm-x86 /usr/src/linux-headers-`uname -r`/include/asm

8 thoughts on “error: asm/asm-offsets.h: No such file or directory

  1. Pingback: Compcache on Ubuntu on Amazon EC2 « Heuristic Andrew

  2. Anders: Thanks for filing the bug and for the cross reference. I usually file bug reports, but sometimes there are only so many hours in a day 🙂

  3. This worked for me since I dont have asm-x86 directory under include/ on a standard Ubuntu 10.10 desktop x86 installation –

    sudo ln -s /lib/modules/2.6.35-22-generic/build/arch/x86/include/asm asm

  4. Pingback: Cómo instalar paso a paso Asterisk 1.8 sobre Ubuntu Server | el mundo según Linux

  5. Thanks a lot, it really heped me to install drbd source module.
    In my case “asm” was a sym link to 64 bit directory but name of that 64 bit directory was differet on disk, this means asm was pointing to non existent directory. I make the link corrent and it worked.

Leave a comment