darling-mach fails to build on Linux 5.1

Created on 19 May 2019  Â·  3Comments  Â·  Source: darlinghq/darling

Hi all. make and sudo make install are doing fine, however, when I try to build the kernel module, the compilation almost stops immediately. Here's the complete build log:

$ make lkm                                                                                                                                                       
Built target migcom
Built target migexe
Built target lkm_generate
Building the Linux kernel module
make[4]: Entering directory '/home/leia/darling/src/lkm'
Running kernel version is 5.1.2-arch1-1-ARCH
rm -f darling-mach.mod.o
make -C /lib/modules/5.1.2-arch1-1-ARCH/build M=/home/leia/darling/src/lkm modules
make[5]: Entering directory '/usr/lib/modules/5.1.2-arch1-1-ARCH/build'
Running kernel version is 5.1.2-arch1-1-ARCH
Invoked by kernel build system, building for 5.1.2-arch1-1-ARCH
  CC [M]  /home/leia/darling/src/lkm/darling/traps.o
In file included from /home/leia/darling/src/lkm/osfmk/i386/user_ldt.h:72,
                 from /home/leia/darling/src/lkm/osfmk/i386/task.h:61,
                 from /home/leia/darling/src/lkm/osfmk/machine/task.h:32,
                 from /home/leia/darling/src/lkm/osfmk/kern/task.h:108,
                 from /home/leia/darling/src/lkm/osfmk/kern/thread.h:123,
                 from /home/leia/darling/src/lkm/bsd/kern/ast.h:37,
                 from /home/leia/darling/src/lkm/osfmk/kern/processor.h:75,
                 from /home/leia/darling/src/lkm/osfmk/i386/cpu_data.h:41,
                 from /home/leia/darling/src/lkm/osfmk/i386/cpu_number.h:75,
                 from /home/leia/darling/src/lkm/osfmk/machine/cpu_number.h:34,
                 from /home/leia/darling/src/lkm/osfmk/kern/wait_queue.h:48,
                 from /home/leia/darling/src/lkm/osfmk/ipc/ipc_mqueue.h:77,
                 from /home/leia/darling/src/lkm/osfmk/ipc/ipc_port.h:91,
                 from /home/leia/darling/src/lkm/darling/traps.c:42:
/home/leia/darling/src/lkm/osfmk/i386/seg.h:213: warning: "SZ_64" redefined
 #define SZ_64  0x2   /* 64-bit segment */

In file included from ./include/linux/mm.h:29,
                 from /home/leia/darling/src/lkm/osfmk/duct/duct.h:54,
                 from /home/leia/darling/src/lkm/darling/traps.c:20:
./include/linux/sizes.h:19: note: this is the location of the previous definition
 #define SZ_64    0x00000040

In file included from /home/leia/darling/src/lkm/osfmk/i386/user_ldt.h:72,
                 from /home/leia/darling/src/lkm/osfmk/i386/task.h:61,
                 from /home/leia/darling/src/lkm/osfmk/machine/task.h:32,
                 from /home/leia/darling/src/lkm/osfmk/kern/task.h:108,
                 from /home/leia/darling/src/lkm/osfmk/kern/thread.h:123,
                 from /home/leia/darling/src/lkm/bsd/kern/ast.h:37,
                 from /home/leia/darling/src/lkm/osfmk/kern/processor.h:75,
                 from /home/leia/darling/src/lkm/osfmk/i386/cpu_data.h:41,
                 from /home/leia/darling/src/lkm/osfmk/i386/cpu_number.h:75,
                 from /home/leia/darling/src/lkm/osfmk/machine/cpu_number.h:34,
                 from /home/leia/darling/src/lkm/osfmk/kern/wait_queue.h:48,
                 from /home/leia/darling/src/lkm/osfmk/ipc/ipc_mqueue.h:77,
                 from /home/leia/darling/src/lkm/osfmk/ipc/ipc_port.h:91,
                 from /home/leia/darling/src/lkm/darling/traps.c:42:
/home/leia/darling/src/lkm/osfmk/i386/seg.h:214: warning: "SZ_32" redefined
 #define SZ_32  0x4   /* 32-bit segment */

In file included from ./include/linux/mm.h:29,
                 from /home/leia/darling/src/lkm/osfmk/duct/duct.h:54,
                 from /home/leia/darling/src/lkm/darling/traps.c:20:
./include/linux/sizes.h:18: note: this is the location of the previous definition
 #define SZ_32    0x00000020

In file included from /home/leia/darling/src/lkm/osfmk/duct/duct.h:105,
                 from /home/leia/darling/src/lkm/darling/traps.c:20:
/home/leia/darling/src/lkm/osfmk/duct/duct__pre_xnu_types.h:99:33: warning: ‘struct xnu_rlimit’ declared inside parameter list will not be visible outside of this definition or declaration
 #define rlimit                  xnu_rlimit
                                 ^~~~~~~~~~
./include/linux/sched/mm.h:129:14: note: in expansion of macro ‘rlimit’
       struct rlimit *rlim_stack);
              ^~~~~~
/home/leia/darling/src/lkm/darling/traps.c: In function ‘mach_init’:
/home/leia/darling/src/lkm/darling/traps.c:201:1: warning: label ‘fail’ defined but not used [-Wunused-label]
 fail:
 ^~~~
/home/leia/darling/src/lkm/darling/traps.c: At top level:
/home/leia/darling/src/lkm/darling/traps.c:408:16: error: initialization of ‘vm_fault_t (*)(struct vm_fault *)’ {aka ‘unsigned int (*)(struct vm_fault *)’} from incompatible pointer type ‘int (*)(struct vm_fault *)’ [-Werror=incompatible-pointer-types]
  .fault      = mach_mmap_fault,
                ^~~~~~~~~~~~~~~
/home/leia/darling/src/lkm/darling/traps.c:408:16: note: (near initialization for ‘mach_mmap_ops.fault’)
cc1: some warnings being treated as errors
make[6]: *** [scripts/Makefile.build:276: /home/leia/darling/src/lkm/darling/traps.o] Error 1
make[5]: *** [Makefile:1571: _module_/home/leia/darling/src/lkm] Error 2
make[5]: Leaving directory '/usr/lib/modules/5.1.2-arch1-1-ARCH/build'
make[4]: *** [Makefile:292: default] Error 2
make[4]: Leaving directory '/home/leia/darling/src/lkm'
make[3]: *** [src/lkm/CMakeFiles/lkm.dir/build.make:58: src/lkm/CMakeFiles/lkm] Error 2
make[2]: *** [CMakeFiles/Makefile2:54343: src/lkm/CMakeFiles/lkm.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:54350: src/lkm/CMakeFiles/lkm.dir/rule] Error 2
make: *** [Makefile:15036: lkm] Error 2

I'm running the latest kernel version provided by Arch Linux, and the latest versions of software listed on the wiki.
Thanks for this project and (hopefully) for solving this issue!

Linux Kernel Module

Most helpful comment

Thanks to some PRs this has been fixed, thanks @mrtino and @jamesbrink

All 3 comments

It's not Arch, it's just that vm_fault_t has changed from int to unsigned int in Linux 5.1; I would say the fix is to use vm_fault_t directly rather than what it's typedefed to.

Would you like to submit a PR? 😀

Thanks to some PRs this has been fixed, thanks @mrtino and @jamesbrink

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jmexe picture jmexe  Â·  5Comments

pmannle picture pmannle  Â·  7Comments

PhilipDeegan picture PhilipDeegan  Â·  7Comments

cgjames907 picture cgjames907  Â·  3Comments

seanballais picture seanballais  Â·  6Comments