dtaht / sch_cake

Out of tree build for the new cake qdisc
100 stars 35 forks source link

Difficulty compiling on Ubuntu 18.04 Server #110

Closed AOEUPL-PHE closed 6 years ago

AOEUPL-PHE commented 6 years ago

Using master branch ddf4c95145. Fresh install of Ubuntu 18.04 server with kernel headers installed, with build-essentials installed.

First Error: Kernel does not support PIC mode.

make

make -C /lib/modules/4.15.0-38-generic/build SUBDIRS=/tmp/sch_cake modules LDFLAGS_MODULE="--build-id=0xddf4c95145f2fbcca16f19e01f3195d213ca760b" CFLAGS_MODULE="-DCAKE_VERSION=\\\"ddf4c95145f2fbcca16f19e01f3195d213ca760b\\\""
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-38-generic'
  CC [M]  /tmp/sch_cake/sch_cake.o
cc1: error: code model kernel does not support PIC mode
scripts/Makefile.build:339: recipe for target '/tmp/sch_cake/sch_cake.o' failed
make[2]: *** [/tmp/sch_cake/sch_cake.o] Error 1
Makefile:1551: recipe for target '_module_/tmp/sch_cake' failed
make[1]: *** [_module_/tmp/sch_cake] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-38-generic'
Makefile:8: recipe for target 'default' failed
make: *** [default] Error 2

First Error Workaround

Added EXTRA_CFLAGS += $(CFLAGS_EXTRA) -fno-pie to the makefile under the VERSION line.

Second Error

make

make -C /lib/modules/4.15.0-38-generic/build SUBDIRS=/tmp/sch_cake modules LDFLAGS_MODULE="--build-id=0xddf4c95145f2fbcca16f19e01f3195d213ca760b" CFLAGS_MODULE="-DCAKE_VERSION=\\\"ddf4c95145f2fbcca16f19e01f3195d213ca760b\\\""
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-38-generic'
  CC [M]  /tmp/sch_cake/sch_cake.o
In file included from ./include/linux/list.h:5:0,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/linux/types.h:17:9: error: unknown type name ‘__kernel_ino_t’
 typedef __kernel_ino_t  ino_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:18:9: error: unknown type name ‘__kernel_mode_t’
 typedef __kernel_mode_t  mode_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:21:9: error: unknown type name ‘__kernel_off_t’
 typedef __kernel_off_t  off_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:22:9: error: unknown type name ‘__kernel_pid_t’
 typedef __kernel_pid_t  pid_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:23:9: error: unknown type name ‘__kernel_daddr_t’
 typedef __kernel_daddr_t daddr_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:25:9: error: unknown type name ‘__kernel_suseconds_t’
 typedef __kernel_suseconds_t suseconds_t;
         ^~~~~~~~~~~~~~~~~~~~
./include/linux/types.h:26:9: error: unknown type name ‘__kernel_timer_t’
 typedef __kernel_timer_t timer_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:27:9: error: unknown type name ‘__kernel_clockid_t’
 typedef __kernel_clockid_t clockid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:32:9: error: unknown type name ‘__kernel_uid32_t’
 typedef __kernel_uid32_t uid_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:33:9: error: unknown type name ‘__kernel_gid32_t’
 typedef __kernel_gid32_t gid_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:34:9: error: unknown type name ‘__kernel_uid16_t’
 typedef __kernel_uid16_t        uid16_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:35:9: error: unknown type name ‘__kernel_gid16_t’
 typedef __kernel_gid16_t        gid16_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:41:9: error: unknown type name ‘__kernel_old_uid_t’
 typedef __kernel_old_uid_t old_uid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:42:9: error: unknown type name ‘__kernel_old_gid_t’
 typedef __kernel_old_gid_t old_gid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:46:9: error: unknown type name ‘__kernel_loff_t’
 typedef __kernel_loff_t  loff_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:55:9: error: unknown type name ‘__kernel_size_t’
 typedef __kernel_size_t  size_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:60:9: error: unknown type name ‘__kernel_ssize_t’
 typedef __kernel_ssize_t ssize_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:65:9: error: unknown type name ‘__kernel_ptrdiff_t’
 typedef __kernel_ptrdiff_t ptrdiff_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:70:9: error: unknown type name ‘__kernel_time_t’
 typedef __kernel_time_t  time_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:75:9: error: unknown type name ‘__kernel_clock_t’
 typedef __kernel_clock_t clock_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:80:9: error: unknown type name ‘__kernel_caddr_t’
 typedef __kernel_caddr_t caddr_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:199:2: error: unknown type name ‘__kernel_daddr_t’
  __kernel_daddr_t f_tfree;
  ^~~~~~~~~~~~~~~~
./include/linux/types.h:200:2: error: unknown type name ‘__kernel_ino_t’
  __kernel_ino_t  f_tinode;
  ^~~~~~~~~~~~~~
In file included from ./include/linux/list.h:9:0,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/linux/kernel.h:6:10: fatal error: stdarg.h: No such file or directory
 #include <stdarg.h>
          ^~~~~~~~~~
compilation terminated.
scripts/Makefile.build:339: recipe for target '/tmp/sch_cake/sch_cake.o' failed
make[2]: *** [/tmp/sch_cake/sch_cake.o] Error 1
Makefile:1551: recipe for target '_module_/tmp/sch_cake' failed
make[1]: *** [_module_/tmp/sch_cake] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-38-generic'
Makefile:10: recipe for target 'default' failed
make: *** [default] Error 2

Second Error Workaround

Changed my custom EXTRA_CFLAGS line to read

EXTRA_CFLAGS += $(CFLAGS_EXTRA) -fno-pie -I/usr/lib/gcc/x86_64-linux-gnu/7/include/

Third error

make

make -C /lib/modules/4.15.0-38-generic/build SUBDIRS=/tmp/sch_cake modules LDFLAGS_MODULE="--build-id=0xddf4c95145f2fbcca16f19e01f3195d213ca760b" CFLAGS_MODULE="-DCAKE_VERSION=\\\"ddf4c95145f2fbcca16f19e01f3195d213ca760b\\\""
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-38-generic'
  CC [M]  /tmp/sch_cake/sch_cake.o
In file included from ./include/linux/list.h:5:0,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/linux/types.h:17:9: error: unknown type name ‘__kernel_ino_t’
 typedef __kernel_ino_t  ino_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:18:9: error: unknown type name ‘__kernel_mode_t’
 typedef __kernel_mode_t  mode_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:21:9: error: unknown type name ‘__kernel_off_t’
 typedef __kernel_off_t  off_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:22:9: error: unknown type name ‘__kernel_pid_t’
 typedef __kernel_pid_t  pid_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:23:9: error: unknown type name ‘__kernel_daddr_t’
 typedef __kernel_daddr_t daddr_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:25:9: error: unknown type name ‘__kernel_suseconds_t’
 typedef __kernel_suseconds_t suseconds_t;
         ^~~~~~~~~~~~~~~~~~~~
./include/linux/types.h:26:9: error: unknown type name ‘__kernel_timer_t’
 typedef __kernel_timer_t timer_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:27:9: error: unknown type name ‘__kernel_clockid_t’
 typedef __kernel_clockid_t clockid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:32:9: error: unknown type name ‘__kernel_uid32_t’
 typedef __kernel_uid32_t uid_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:33:9: error: unknown type name ‘__kernel_gid32_t’
 typedef __kernel_gid32_t gid_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:34:9: error: unknown type name ‘__kernel_uid16_t’
 typedef __kernel_uid16_t        uid16_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:35:9: error: unknown type name ‘__kernel_gid16_t’
 typedef __kernel_gid16_t        gid16_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:41:9: error: unknown type name ‘__kernel_old_uid_t’
 typedef __kernel_old_uid_t old_uid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:42:9: error: unknown type name ‘__kernel_old_gid_t’
 typedef __kernel_old_gid_t old_gid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:46:9: error: unknown type name ‘__kernel_loff_t’
 typedef __kernel_loff_t  loff_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:55:9: error: unknown type name ‘__kernel_size_t’
 typedef __kernel_size_t  size_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:60:9: error: unknown type name ‘__kernel_ssize_t’
 typedef __kernel_ssize_t ssize_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:65:9: error: unknown type name ‘__kernel_ptrdiff_t’
 typedef __kernel_ptrdiff_t ptrdiff_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:70:9: error: unknown type name ‘__kernel_time_t’
 typedef __kernel_time_t  time_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:75:9: error: unknown type name ‘__kernel_clock_t’
 typedef __kernel_clock_t clock_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:80:9: error: unknown type name ‘__kernel_caddr_t’
 typedef __kernel_caddr_t caddr_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:199:2: error: unknown type name ‘__kernel_daddr_t’
  __kernel_daddr_t f_tfree;
  ^~~~~~~~~~~~~~~~
./include/linux/types.h:200:2: error: unknown type name ‘__kernel_ino_t’
  __kernel_ino_t  f_tinode;
  ^~~~~~~~~~~~~~
In file included from ./include/linux/kernel.h:7:0,
                 from ./include/linux/list.h:9,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/linux/linkage.h:8:10: fatal error: asm/linkage.h: No such file or directory
 #include <asm/linkage.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
scripts/Makefile.build:339: recipe for target '/tmp/sch_cake/sch_cake.o' failed
make[2]: *** [/tmp/sch_cake/sch_cake.o] Error 1
Makefile:1551: recipe for target '_module_/tmp/sch_cake' failed
make[1]: *** [_module_/tmp/sch_cake] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-38-generic'
Makefile:10: recipe for target 'default' failed
make: *** [default] Error 2

Third error workaround

ln -s /usr/src/linux-headers-4.15.0-38-generic/include/asm-generic /usr/src/linux-headers-4.15.0-38-generic/include/asm

I don't really know what I'm doing here, I think there is a more fundamental problem that I'm missing, and it may be related to how ubuntu handles kernel headers.

Anyway. Let's continue.

Fourth Error

make -C /lib/modules/4.15.0-38-generic/build SUBDIRS=/tmp/sch_cake modules LDFLAGS_MODULE="--build-id=0xddf4c95145f2fbcca16f19e01f3195d213ca760b" CFLAGS_MODULE="-DCAKE_VERSION=\\\"ddf4c95145f2fbcca16f19e01f3195d213ca760b\\\""
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-38-generic'
  CC [M]  /tmp/sch_cake/sch_cake.o
In file included from ./include/linux/list.h:5:0,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/linux/types.h:17:9: error: unknown type name ‘__kernel_ino_t’
 typedef __kernel_ino_t  ino_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:18:9: error: unknown type name ‘__kernel_mode_t’
 typedef __kernel_mode_t  mode_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:21:9: error: unknown type name ‘__kernel_off_t’
 typedef __kernel_off_t  off_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:22:9: error: unknown type name ‘__kernel_pid_t’
 typedef __kernel_pid_t  pid_t;
         ^~~~~~~~~~~~~~
./include/linux/types.h:23:9: error: unknown type name ‘__kernel_daddr_t’
 typedef __kernel_daddr_t daddr_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:25:9: error: unknown type name ‘__kernel_suseconds_t’
 typedef __kernel_suseconds_t suseconds_t;
         ^~~~~~~~~~~~~~~~~~~~
./include/linux/types.h:26:9: error: unknown type name ‘__kernel_timer_t’
 typedef __kernel_timer_t timer_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:27:9: error: unknown type name ‘__kernel_clockid_t’
 typedef __kernel_clockid_t clockid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:32:9: error: unknown type name ‘__kernel_uid32_t’
 typedef __kernel_uid32_t uid_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:33:9: error: unknown type name ‘__kernel_gid32_t’
 typedef __kernel_gid32_t gid_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:34:9: error: unknown type name ‘__kernel_uid16_t’
 typedef __kernel_uid16_t        uid16_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:35:9: error: unknown type name ‘__kernel_gid16_t’
 typedef __kernel_gid16_t        gid16_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:41:9: error: unknown type name ‘__kernel_old_uid_t’
 typedef __kernel_old_uid_t old_uid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:42:9: error: unknown type name ‘__kernel_old_gid_t’
 typedef __kernel_old_gid_t old_gid_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:46:9: error: unknown type name ‘__kernel_loff_t’
 typedef __kernel_loff_t  loff_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:55:9: error: unknown type name ‘__kernel_size_t’
 typedef __kernel_size_t  size_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:60:9: error: unknown type name ‘__kernel_ssize_t’
 typedef __kernel_ssize_t ssize_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:65:9: error: unknown type name ‘__kernel_ptrdiff_t’
 typedef __kernel_ptrdiff_t ptrdiff_t;
         ^~~~~~~~~~~~~~~~~~
./include/linux/types.h:70:9: error: unknown type name ‘__kernel_time_t’
 typedef __kernel_time_t  time_t;
         ^~~~~~~~~~~~~~~
./include/linux/types.h:75:9: error: unknown type name ‘__kernel_clock_t’
 typedef __kernel_clock_t clock_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:80:9: error: unknown type name ‘__kernel_caddr_t’
 typedef __kernel_caddr_t caddr_t;
         ^~~~~~~~~~~~~~~~
./include/linux/types.h:199:2: error: unknown type name ‘__kernel_daddr_t’
  __kernel_daddr_t f_tfree;
  ^~~~~~~~~~~~~~~~
./include/linux/types.h:200:2: error: unknown type name ‘__kernel_ino_t’
  __kernel_ino_t  f_tinode;
  ^~~~~~~~~~~~~~
In file included from ./include/asm-generic/bitops/atomic.h:9:0,
                 from ./include/asm/bitops.h:33,
                 from ./include/linux/bitops.h:38,
                 from ./include/linux/kernel.h:11,
                 from ./include/linux/list.h:9,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/asm/spinlock.h:9:2: error: #error need an architecture specific asm/spinlock.h
 #error need an architecture specific asm/spinlock.h
  ^~~~~
In file included from ./include/asm/bitops.h:33:0,
                 from ./include/linux/bitops.h:38,
                 from ./include/linux/kernel.h:11,
                 from ./include/linux/list.h:9,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/asm-generic/bitops/atomic.h:19:8: error: unknown type name ‘arch_spinlock_t’
 extern arch_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
        ^~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:19:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__lock_aligned’
 extern arch_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
                                                        ^~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h: In function ‘set_bit’:
./include/asm-generic/bitops/atomic.h:24:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
  ^
./include/asm-generic/bitops/atomic.h:72:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:17:29: error: ‘__atomic_hash’ undeclared (first use in this function); did you mean ‘__atomic_load’?
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
                             ^
./include/asm-generic/bitops/atomic.h:24:23: note: in expansion of macro ‘ATOMIC_HASH’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
                       ^~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:72:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:17:29: note: each undeclared identifier is reported only once for each function it appears in
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
                             ^
./include/asm-generic/bitops/atomic.h:24:23: note: in expansion of macro ‘ATOMIC_HASH’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
                       ^~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:72:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:26:2: error: implicit declaration of function ‘arch_spin_lock’ [-Werror=implicit-function-declaration]
  arch_spin_lock(s);   \
  ^
./include/asm-generic/bitops/atomic.h:72:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:30:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l);  \
  ^
./include/asm-generic/bitops/atomic.h:74:2: note: in expansion of macro ‘_atomic_spin_unlock_irqrestore’
  _atomic_spin_unlock_irqrestore(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:31:2: error: implicit declaration of function ‘arch_spin_unlock’; did you mean ‘clear_bit_unlock’? [-Werror=implicit-function-declaration]
  arch_spin_unlock(s);    \
  ^
./include/asm-generic/bitops/atomic.h:74:2: note: in expansion of macro ‘_atomic_spin_unlock_irqrestore’
  _atomic_spin_unlock_irqrestore(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h: In function ‘clear_bit’:
./include/asm-generic/bitops/atomic.h:24:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
  ^
./include/asm-generic/bitops/atomic.h:93:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:17:29: error: ‘__atomic_hash’ undeclared (first use in this function); did you mean ‘__atomic_load’?
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
                             ^
./include/asm-generic/bitops/atomic.h:24:23: note: in expansion of macro ‘ATOMIC_HASH’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
                       ^~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:93:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:30:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l);  \
  ^
./include/asm-generic/bitops/atomic.h:95:2: note: in expansion of macro ‘_atomic_spin_unlock_irqrestore’
  _atomic_spin_unlock_irqrestore(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h: In function ‘change_bit’:
./include/asm-generic/bitops/atomic.h:24:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
  ^
./include/asm-generic/bitops/atomic.h:114:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:17:29: error: ‘__atomic_hash’ undeclared (first use in this function); did you mean ‘__atomic_load’?
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
                             ^
./include/asm-generic/bitops/atomic.h:24:23: note: in expansion of macro ‘ATOMIC_HASH’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
                       ^~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:114:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:30:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l);  \
  ^
./include/asm-generic/bitops/atomic.h:116:2: note: in expansion of macro ‘_atomic_spin_unlock_irqrestore’
  _atomic_spin_unlock_irqrestore(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h: In function ‘test_and_set_bit’:
./include/asm-generic/bitops/atomic.h:24:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
  ^
./include/asm-generic/bitops/atomic.h:135:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:17:29: error: ‘__atomic_hash’ undeclared (first use in this function); did you mean ‘__atomic_load’?
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
                             ^
./include/asm-generic/bitops/atomic.h:24:23: note: in expansion of macro ‘ATOMIC_HASH’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
                       ^~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:135:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:30:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l);  \
  ^
./include/asm-generic/bitops/atomic.h:138:2: note: in expansion of macro ‘_atomic_spin_unlock_irqrestore’
  _atomic_spin_unlock_irqrestore(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h: In function ‘test_and_clear_bit’:
./include/asm-generic/bitops/atomic.h:24:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
  ^
./include/asm-generic/bitops/atomic.h:159:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:17:29: error: ‘__atomic_hash’ undeclared (first use in this function); did you mean ‘__atomic_load’?
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
                             ^
./include/asm-generic/bitops/atomic.h:24:23: note: in expansion of macro ‘ATOMIC_HASH’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
                       ^~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:159:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:30:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l);  \
  ^
./include/asm-generic/bitops/atomic.h:162:2: note: in expansion of macro ‘_atomic_spin_unlock_irqrestore’
  _atomic_spin_unlock_irqrestore(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h: In function ‘test_and_change_bit’:
./include/asm-generic/bitops/atomic.h:24:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
  ^
./include/asm-generic/bitops/atomic.h:182:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:17:29: error: ‘__atomic_hash’ undeclared (first use in this function); did you mean ‘__atomic_load’?
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
                             ^
./include/asm-generic/bitops/atomic.h:24:23: note: in expansion of macro ‘ATOMIC_HASH’
  arch_spinlock_t *s = ATOMIC_HASH(l); \
                       ^~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:182:2: note: in expansion of macro ‘_atomic_spin_lock_irqsave’
  _atomic_spin_lock_irqsave(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bitops/atomic.h:30:2: error: unknown type name ‘arch_spinlock_t’
  arch_spinlock_t *s = ATOMIC_HASH(l);  \
  ^
./include/asm-generic/bitops/atomic.h:185:2: note: in expansion of macro ‘_atomic_spin_unlock_irqrestore’
  _atomic_spin_unlock_irqrestore(p, flags);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/uapi/linux/kernel.h:5:0,
                 from ./include/linux/cache.h:5,
                 from ./include/linux/printk.h:9,
                 from ./include/linux/kernel.h:14,
                 from ./include/linux/list.h:9,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/uapi/linux/sysinfo.h: At top level:
./include/uapi/linux/sysinfo.h:9:2: error: unknown type name ‘__kernel_long_t’
  __kernel_long_t uptime;  /* Seconds since boot */
  ^~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:10:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t loads[3]; /* 1, 5, and 15 minute load averages */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:11:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t totalram; /* Total usable main memory size */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:12:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t freeram; /* Available memory size */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:13:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t sharedram; /* Amount of shared memory */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:14:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t bufferram; /* Memory used by buffers */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:15:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t totalswap; /* Total swap space size */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:16:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t freeswap; /* swap space still available */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:19:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t totalhigh; /* Total high memory size */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:20:2: error: unknown type name ‘__kernel_ulong_t’
  __kernel_ulong_t freehigh; /* Available high memory size */
  ^~~~~~~~~~~~~~~~
./include/uapi/linux/sysinfo.h:22:22: error: ‘__kernel_ulong_t’ undeclared here (not in a function); did you mean ‘__kernel_dev_t’?
  char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)]; /* Padding: libc5 uses this.. */
                      ^~~~~~~~~~~~~~~~
                      __kernel_dev_t
In file included from ./include/linux/list.h:9:0,
                 from ./include/linux/module.h:9,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/linux/kernel.h:466:5: warning: conflicting types for built-in function ‘snprintf’ [-Wbuiltin-declaration-mismatch]
 int snprintf(char *buf, size_t size, const char *fmt, ...);
     ^~~~~~~~
./include/linux/kernel.h:468:5: warning: conflicting types for built-in function ‘vsnprintf’ [-Wbuiltin-declaration-mismatc ]
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
     ^~~~~~~~~
In file included from ./include/linux/stat.h:6:0,
                 from ./include/linux/module.h:10,
                 from /tmp/sch_cake/sch_cake.c:53:
./arch/x86/include/uapi/asm/stat.h:84:2: error: expected specifier-qualifier-list before ‘__kernel_ulong_t’
  __kernel_ulong_t st_dev;
  ^~~~~~~~~~~~~~~~
In file included from ./include/asm/preempt.h:5:0,
                 from ./include/linux/preempt.h:81,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from ./include/linux/stat.h:19,
                 from ./include/linux/module.h:10,
                 from /tmp/sch_cake/sch_cake.c:53:
./include/linux/thread_info.h:38:10: fatal error: asm/thread_info.h: No such file or directory
 #include <asm/thread_info.h>
          ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
compilation terminated.
scripts/Makefile.build:339: recipe for target '/tmp/sch_cake/sch_cake.o' failed
make[2]: *** [/tmp/sch_cake/sch_cake.o] Error 1
Makefile:1551: recipe for target '_module_/tmp/sch_cake' failed
make[1]: *** [_module_/tmp/sch_cake] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-38-generic'
Makefile:10: recipe for target 'default' failed
make: *** [default] Error 2

What next?

I could keep trying workarounds but I think something is wrong. This is a new ubuntu 18.04 server, so I thought the config would be pretty standard. Any ideas?

More random debugging info

dpkg -l "*headers*"

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                    Version                  Architecture             Description
+++-=======================================-========================-========================-====================================================================================
un  linux-headers                           <none>                   <none>                   (no description available)
un  linux-headers-3.0                       <none>                   <none>                   (no description available)
ii  linux-headers-4.15.0-29                 4.15.0-29.31             all                      Header files related to Linux kernel version 4.15.0
ii  linux-headers-4.15.0-29-generic         4.15.0-29.31             amd64                    Linux kernel headers for version 4.15.0 on 64 bit x86 SMP
ii  linux-headers-4.15.0-38                 4.15.0-38.41             all                      Header files related to Linux kernel version 4.15.0
ii  linux-headers-4.15.0-38-generic         4.15.0-38.41             amd64                    Linux kernel headers for version 4.15.0 on 64 bit x86 SMP
ii  linux-headers-generic                   4.15.0.38.40             amd64                    Generic Linux kernel headers
un  linux-kernel-headers                    <none>                   <none>                   (no description available)

uname -a

Linux myhost 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

AOEUPL-PHE commented 6 years ago

I'm just using the official kernel version now. Didn't realize it was in 4.19

tohojo commented 6 years ago

AOEUPL-PHE notifications@github.com writes:

Closed #110.

FWIW, hopefully out-of-tree compiles are fixed properly in master now...

AOEUPL-PHE commented 6 years ago

Tried and it works with no workarounds now. Thanks!

AOEUPL-PHE commented 6 years ago

BTW, is this version worse/better/the same as the one in the 4.19 kernel?

tohojo commented 6 years ago

Cool. It should be identical - if you're updating your kernel anyway, just use the upstream version. This repo is for old kernels (and potentially for experiments in the future, but none yet)