darlinghq / darling

Darwin/macOS emulation layer for Linux
http://www.darlinghq.org
GNU General Public License v3.0
11.45k stars 444 forks source link

Linux Kernel Module fails to build and load on WSL 2 #260

Closed DuIslingr closed 2 years ago

DuIslingr commented 7 years ago

What would it take to get darling to function on WSL? I can make and install it just fine, however I cannot build the kernel submodule since its a similar issue to a closed issue I came across regarding docker.

make -C /lib/modules/4.4.0-43-Microsoft/build M=/home/DuIslingr/darling/src/lkm modules make[1]: *** /lib/modules/4.4.0-43-Microsoft/build: No such file or directory. Stop. Makefile:36: recipe for target 'default' failed make: *** [default] Error 2

I know it was said that it wouldn't work due to docker being simply a chroot environment essentially basically so it has no real kernel to work with. Which the same can be said for wsl. just would be nice if i could run Apples toolchain without having to wait for ports to linux or windows etc.

bugaevc commented 7 years ago

As of now, it's impossible to run Darling in WSL for various reasons, the two most important ones being:

  1. Darling needs to load its own kernel module. Since there's no Linux kernel in WSL, it's impossible to use our module there. To make it work, the functionality would need to be reimplemented in some other way.
  2. We make use of various features that WSL does not support, such as mount namespaces (last time I checked, WSL didn't have any support for mounting anything, let alone namespacing that).
DuIslingr commented 7 years ago

Hmmm 2 would be the more likely to be resolved as work on wsl progresses more features are supported. As far as 1 goes idk. Probably be more likely for you guys to make it work in some other fashion. But oh well I guess for the time being. Can just vm linux or somethin.

oscarbg commented 7 years ago

would be nice if you submit type 2 issues as suggestions to Microsoft here: https://github.com/Microsoft/BashOnWindows/issues also reading: https://msdn.microsoft.com/en-us/commandline/wsl/release_notes seems latest preview builds have support for mount namespaces.. I'm right?

oscarbg commented 7 years ago

So I put an issue in WSL site for help..

bugaevc commented 7 years ago

seems latest preview builds have support for mount namespaces

Seems so indeed! That's pretty cool, thanks for bringing it to my attention.

overlayfs is still missing, but we could do without it (the way Wine does it). PID namespaces are missing, too, though these could be faked quite easily in LKM (or whatever replaces it).

fpqc commented 7 years ago

@bugaevc Mount, PID, IPC, and UTS namespaces are all implemented now (they appear to be pursuing container support on the hush hush). I think the main problem here is going to be lack of 'kernel' headers or real module-loading capabilities.

The trouble is that WSL's modules, if they ever are implemented for arbitrary modules, will need to be a special kind of Windows signed driver (because the Windows Kernel enforces driver signing with either a Microsoft or very high-level microsoft partner signature. Drivers submitted for loading have to be signed after code review within Microsoft or a trusted partner).

Alex Ionescu wrote up a little article on his github about it, and he was able to write a very basic out-of-tree kernelmode driver to expose some virtual hardware inside WSL.

However, the WSL driver API is still neither finalized and versioned or even exposed with symbols, so even if you did want to write a driver for it, it would be a hack with no Kernel shim engine support, and it would only work if the system was set up to boot in 'Test Mode'. There are several people with signatures who might be willing to sign an opensource drivers for free (the people who sign dokany and who will sign the btrfs driver in the future), but it's unlikely they would do it if you're programming against an unstable and undocumented API.

So for the foreseeable future, it's going to be a no-go.

CuriousTommy commented 5 years ago

Seeing that WSL2 uses the actual Linux kernel, I wonder if there will be support for building and installing modules.

bugaevc commented 5 years ago

Yeah, that's what I'm wondering as well. If modules are supported, there's a high chance Darling will work.

theonlyfoxy commented 5 years ago

WSL2 early preview released today(Insider Fast Ring). Can anybody confirm if it works work Darling?

wizoomer95 commented 5 years ago

I wish I could confirm Darling works in WSL2. I have yet to build the kernel module to confirm if that works or not, but I will explain my experience thus far and see if the developers here can make anything of it. First things first; I had troubles getting WSL2 to install on my machine, but that's neither here nor there. Remember: You need virtualization technology enabled in BIOS to make use of WSL2. That wasn't my only issue in getting it to work, but for our purposes here, I'll skip those details. I'm using Ubuntu 18.04 LTS on WSL2. Now, the first issue you'll notice when trying to install the dependencies to build Darling is that clang isn't included as a package in the package manager. However, you can still workaround this issue by manually installing the Clang binaries. Also, the i386 architecture isn't enabled in WSL2 by default, so you have to manually add the architecture in the shell. Here's the list of the commands to satisfy the dependencies for Darling: sudo apt-get update sudo apt install build-essential xz-utils curl curl http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz --output clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz tar xf clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz cd clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04 sudo mkdir /usr/local/clang_8.0.0 sudo cp -R . /usr/local/clang_8.0.0 export PATH=/usr/local/clang_8.0.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/clang_8.0.0/lib:$LD_LIBRARY_PATH sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install cmake bison flex xz-utils libfuse-dev libudev-dev pkg-config libc6-dev:i386 linux-headers-generic gcc-multilib libcap2-bin libcairo2-dev libgl1-mesa-dev libtiff5-dev libfreetype6-dev libfreetype6-dev:i386 git libelf-dev libxml2-dev libegl1-mesa-dev libfontconfig1-dev libbsd-dev However, all was for naught as far as Darling is concerned. I started the building process. Everything was working well as usual until I got to the make command. There were many warnings along the way, Now, because the build process is so long, the beginning of the logged output had trailed off. I'm attaching as much of the log as I have zipped, and in the meantime, here is the tail-end of the logged output of the make command: `[ 39%] Building C object src/external/foundation/CMakeFiles/Foundation.dir/src/NSCallBacks.o /home/ricorobbins/darling/src/external/foundation/src/NSCallBacks.m:106:52: warning: values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead [-Wformat] return [NSString stringWithFormat: @"%#"PRIxPTR, (NSUInteger)p];


/home/ricorobbins/darling/src/external/foundation/src/NSCallBacks.m:205:52: warning: values of type 'NSUInteger' should
      not be used as format arguments; add an explicit cast to 'unsigned long' instead [-Wformat]
  return [NSString stringWithFormat: @"%0"PRIxPTR, (NSUInteger)p];
                                       ~~~~~~~~~~  ^~~~~~~~~~~~~
/home/ricorobbins/darling/src/external/foundation/src/NSCallBacks.m:238:62: warning: values of type 'NSUInteger' should
      not be used as format arguments; add an explicit cast to 'unsigned long' instead [-Wformat]
  return [NSString stringWithFormat: @"%d(%#"PRIxPTR")", *p, (NSUInteger)p];
                                          ~~~~~~~~~~         ^~~~~~~~~~~~~
/home/ricorobbins/darling/src/external/foundation/src/NSCallBacks.m:253:11: error: use of undeclared identifier 'o'
  return [o isEqual: p];;
          ^
/home/ricorobbins/darling/src/external/foundation/src/NSCallBacks.m:272:13: warning: instance method '-describe' not
      found (return type defaults to 'id') [-Wobjc-method-access]
  return [o describe];
            ^~~~~~~~
4 warnings and 1 error generated.
src/external/foundation/CMakeFiles/Foundation.dir/build.make:4358: recipe for target 'src/external/foundation/CMakeFiles/Foundation.dir/src/NSCallBacks.o' failed
make[2]: *** [src/external/foundation/CMakeFiles/Foundation.dir/src/NSCallBacks.o] Error 1
CMakeFiles/Makefile2:13628: recipe for target 'src/external/foundation/CMakeFiles/Foundation.dir/all' failed
make[1]: *** [src/external/foundation/CMakeFiles/Foundation.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2`
So, as of right now, it appears that Darling on WSL2 is a no-go.
[Partial Darling Compile Error Log.zip](https://github.com/darlinghq/darling/files/3305287/Partial.Darling.Compile.Error.Log.zip)
CuriousTommy commented 5 years ago

@wizoomer95

/home/ricorobbins/darling/src/external/foundation/src/NSCallBacks.m:253:11: error: use of undeclared identifier 'o' return [o isEqual: p];; ^ 

This issue was fixed with https://github.com/darlinghq/darling-foundation/commit/0a00d64871aa9f74952756c76a4a44aa28e245c1, but the darling repo has not been updated to use the newer commits from the submodule.

You are going to have to either manually update the files, or use an older commit that didn't introduce the build breaking changes.

Edit: @bugaevc would it be possible for you to update the submodule?

bugaevc commented 5 years ago

Edit: @bugaevc would it be possible for you to update the submodule?

Yeah, sure, but I need to get home & deal with other stuff first :)

coffeekomrade commented 5 years ago

Can we bump to open this back up?

wizoomer95 commented 5 years ago

Got back to attempting to re-compile Darling. One thing that I learned the first time reattempting to rebuild is that environment variables $PATH and $LD_LIBRARY_PATH do NOT remain set after exiting WSL2. This is important because as I mentioned above, I had to manually install the Clang binary as it isn't included in the package manager in Ubuntu 18.04 on WSL2. If I don't manually re-add Clang to these environment variables, it will attempt to compile with GCC and G++, which will result in build errors. I still am researching the issue to see if there's a way I can set the environment variables once and keep them set. Manually replacing the files as suggested by @CuriousTommy worked to get past that build error. However, it initially failed at 41% due to Python not being properly installed. This was easily fixed by installing Python with the command sudo apt install python-minimal. However, resuming the build did NOT result in completing the build successfully. It errored at 74% with this error:

Scanning dependencies of target SecurityInterface
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SecurityInterface.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFButtonNotBecomeKey.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFAuthorizationRights.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFAuthorizationView_ivars.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFAuthorizationView.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFChooseIdentityTableCellView.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFCertificatePanel_ivars.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFCertificatePanel.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFCertificateTrustPanel_ivars.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFCertificateTrustPanel.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFCertificateView_ivars.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFFlippedView.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFCertificateView.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFChooseIdentityPanel_ivars.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFChooseIdentityPanel.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFKeychainSavePanel_ivars.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFKeychainSavePanel.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFKeychainSettingsPanel_ivars.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFAutoLockTextValue.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFKeychainSettingsPanel.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFEntropyBarView.o
[ 74%] Building C object src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFPasswordAsstController.o
In file included from /home/ricorobbins/darling/src/SecurityInterface/src/SFPasswordAsstController.m:20:
In file included from /home/ricorobbins/darling/src/SecurityInterface/include/SecurityInterface/SFPasswordAsstController.h:20:
In file included from /home/ricorobbins/darling/src/external/foundation/include/Foundation/Foundation.h:71:
In file included from /home/ricorobbins/darling/src/external/foundation/include/Foundation/NSURLCredential.h:2:
/home/ricorobbins/darling/src/external/security/include/Security/Security.h:95:2: error: invalid preprocessing directive
#i<AE>clude <<F3>ecurity<U+000F>Authori
 ^
/home/ricorobbins/darling/src/external/security/include/Security/Security.h:96:8: error: source file is not valid UTF-8
ationTa<D7>s.h>
       ^
/home/ricorobbins/darling/src/external/security/include/Security/Security.h:96:1: error: unknown type name 'ationTa'
ationTa<D7>s.h>
^
/home/ricorobbins/darling/src/external/security/include/Security/Security.h:96:10: error: expected ';' after top level
      declarator
ationTa<D7>s.h>
            ^
            ;
/home/ricorobbins/darling/src/external/security/include/Security/Security.h:97:2: error: invalid preprocessing directive
#i<AE>clude <<C3>ecurity<9F>Authori<CA>ationDB<EE>h>
 ^
/home/ricorobbins/darling/src/external/security/include/Security/Security.h:100:2: error: invalid preprocessing
      directive
#<U+0019>nclude <EC>Securit<A9>/CMSDecOder.h>
 ^
In file included from /home/ricorobbins/darling/src/SecurityInterface/src/SFPasswordAsstController.m:20:
In file included from /home/ricorobbins/darling/src/SecurityInterface/include/SecurityInterface/SFPasswordAsstController.h:20:
In file included from /home/ricorobbins/darling/src/external/foundation/include/Foundation/Foundation.h:71:
In file included from /home/ricorobbins/darling/src/external/foundation/include/Foundation/NSURLCredential.h:2:
In file included from /home/ricorobbins/darling/src/external/security/include/Security/Security.h:102:
/home/ricorobbins/darling/src/external/security/include/Security/CipherSuite.h:46:9: error: unknown type name
      'SSLCipherSuite'
CF_ENUM(SSLCipherSuite)
        ^
In file included from /home/ricorobbins/darling/src/SecurityInterface/src/SFPasswordAsstController.m:20:
In file included from /home/ricorobbins/darling/src/SecurityInterface/include/SecurityInterface/SFPasswordAsstController.h:20:
In file included from /home/ricorobbins/darling/src/external/foundation/include/Foundation/Foundation.h:71:
In file included from /home/ricorobbins/darling/src/external/foundation/include/Foundation/NSURLCredential.h:2:
In file included from /home/ricorobbins/darling/src/external/security/include/Security/Security.h:103:
/home/ricorobbins/darling/src/external/security/include/Security/SecureTransport.h:753:10: error: unknown type name
      'SSLCipherSuite'
                                                          SSLCipherSuite                *ciphers,               ...
                                                          ^
/home/ricorobbins/darling/src/external/security/include/Security/SecureTransport.h:765:15: error: unknown type name
      'SSLCipherSuite'
                                                         const SSLCipherSuite   *ciphers,
                                                               ^
/home/ricorobbins/darling/src/external/security/include/Security/SecureTransport.h:782:9: error: unknown type name
      'SSLCipherSuite'
                                                         SSLCipherSuite                 *ciphers,               ...
                                                         ^
/home/ricorobbins/darling/src/external/security/include/Security/SecureTransport.h:1140:9: error: unknown type name
      'SSLCipherSuite'
                                                         SSLCipherSuite         *cipherSuite)
                                                         ^
11 errors generated.
src/SecurityInterface/CMakeFiles/SecurityInterface.dir/build.make:566: recipe for target 'src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFPasswordAsstController.o' failed
make[2]: *** [src/SecurityInterface/CMakeFiles/SecurityInterface.dir/src/SFPasswordAsstController.o] Error 1
CMakeFiles/Makefile2:48265: recipe for target 'src/SecurityInterface/CMakeFiles/SecurityInterface.dir/all' failed
make[1]: *** [src/SecurityInterface/CMakeFiles/SecurityInterface.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Above all, I would just like to fix these build errors so I can get to testing the kernel module element. I tried researching if there was a similar issue to the darling-foundation issue I had above, but I can't find the SecurityInterface equivalent module repository. Any help is appreciated!

bugaevc commented 5 years ago
/home/ricorobbins/darling/src/external/security/include/Security/Security.h:95:2: error: invalid preprocessing directive
#i<AE>clude <<F3>ecurity<U+000F>Authori

That sounds like you have either a corrupted file or a buggy filesystem. Try re-fetching Security.

I tried researching if there was a similar issue to the darling-foundation issue I had above, but I can't find the SecurityInterface equivalent module repository. Any help is appreciated!

The repo is here, the file is here, and it's a symlink to here.

wizoomer95 commented 5 years ago

As of now, I can confirm that Darling on WSL2 is a no-go. Re-fetching Security helped me solve my latest issue. I also had to re-fetch JavaScriptCore because it wouldn't link, giving the error:

[ 98%] Linking CXX shared library JavaScriptCore
ld: file too small (length=0) file 'CMakeFiles/JavaScriptCore.dir/runtime/HashMapImpl.o' for architecture i386
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
src/external/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/build.make:24779: recipe for target 'src/external/JavaScriptCore/JavaScriptCore' failed
make[2]: *** [src/external/JavaScriptCore/JavaScriptCore] Error 1
CMakeFiles/Makefile2:56543: recipe for target 'src/external/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/all' failed
make[1]: *** [src/external/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Re-fetching JavaScriptCore fixed this problem, and I was able to build most of Darling. However, I can't say I've had the same success with building the kernel module. It appears that I'm getting a similar error to the one in the OP:

ricorobbins@DESKTOP-Q0DM43J:~/darling/build5$ make lkm
Built target migcom
Built target migexe
Scanning dependencies of target lkm_generate
Generating osfmk/mach/upl_user.c, osfmk/mach/upl.h, osfmk/mach/upl_server.c, osfmk/mach/upl_server.h
Generating osfmk/mach/host_notify_reply_user.c, osfmk/mach/host_notify_reply.h, osfmk/mach/host_notify_reply_server.c, osfmk/mach/host_notify_reply_server.h
Generating osfmk/mach/vm32_map_user.c, osfmk/mach/vm32_map.h, osfmk/mach/vm32_map_server.c, osfmk/mach/vm32_map_server.h
Generating osfmk/mach/mach_notify_user.c, osfmk/mach/mach_notify.h, osfmk/mach/mach_notify_server.c, osfmk/mach/mach_notify_server.h
Generating osfmk/mach/security_user.c, osfmk/mach/security.h, osfmk/mach/security_server.c, osfmk/mach/security_server.h
Generating osfmk/mach/memory_object_control_user.c, osfmk/mach/memory_object_control.h, osfmk/mach/memory_object_control_server.c, osfmk/mach/memory_object_control_server.h
Generating osfmk/mach/memory_object_user.c, osfmk/mach/memory_object.h, osfmk/mach/memory_object_server.c, osfmk/mach/memory_object_server.h
Generating osfmk/mach/memory_object_default_user.c, osfmk/mach/memory_object_default.h, osfmk/mach/memory_object_default_server.c, osfmk/mach/memory_object_default_server.h
Generating osfmk/mach/vm_map_user.c, osfmk/mach/vm_map.h, osfmk/mach/vm_map_server.c, osfmk/mach/vm_map_server.h
Generating osfmk/mach/exc_user.c, osfmk/mach/exc.h, osfmk/mach/exc_server.c, osfmk/mach/exc_server.h
Generating osfmk/mach/mach_exc_user.c, osfmk/mach/mach_exc.h, osfmk/mach/mach_exc_server.c, osfmk/mach/mach_exc_server.h
Generating osfmk/mach/notify_user.c, osfmk/mach/notify.h, osfmk/mach/notify_server.c, osfmk/mach/notify_server.h
Generating osfmk/mach/task_user.c, osfmk/mach/task.h, osfmk/mach/task_server.c, osfmk/mach/task_server.h
Generating osfmk/mach/clock_user.c, osfmk/mach/clock.h, osfmk/mach/clock_server.c, osfmk/mach/clock_server.h
Generating osfmk/mach/clock_priv_user.c, osfmk/mach/clock_priv.h, osfmk/mach/clock_priv_server.c, osfmk/mach/clock_priv_server.h
Generating osfmk/mach/processor_user.c, osfmk/mach/processor.h, osfmk/mach/processor_server.c, osfmk/mach/processor_server.h
Generating osfmk/mach/host_priv_user.c, osfmk/mach/host_priv.h, osfmk/mach/host_priv_server.c, osfmk/mach/host_priv_server.h
Generating osfmk/mach/host_security_user.c, osfmk/mach/host_security.h, osfmk/mach/host_security_server.c, osfmk/mach/host_security_server.h
Generating osfmk/mach/lock_set_user.c, osfmk/mach/lock_set.h, osfmk/mach/lock_set_server.c, osfmk/mach/lock_set_server.h
Generating osfmk/mach/mach_port_user.c, osfmk/mach/mach_port.h, osfmk/mach/mach_port_server.c, osfmk/mach/mach_port_server.h
Generating osfmk/mach/mach_vm_user.c, osfmk/mach/mach_vm.h, osfmk/mach/mach_vm_server.c, osfmk/mach/mach_vm_server.h
Generating osfmk/mach/mach_host_user.c, osfmk/mach/mach_host.h, osfmk/mach/mach_host_server.c, osfmk/mach/mach_host_server.h
Generating osfmk/mach/processor_set_user.c, osfmk/mach/processor_set.h, osfmk/mach/processor_set_server.c, osfmk/mach/processor_set_server.h
Generating osfmk/mach/memory_object_name_user.c, osfmk/mach/memory_object_name.h, osfmk/mach/memory_object_name_server.c, osfmk/mach/memory_object_name_server.h
Generating osfmk/mach/thread_act_user.c, osfmk/mach/thread_act.h, osfmk/mach/thread_act_server.c, osfmk/mach/thread_act_server.h
Generating osfmk/mach/clock_reply_user.c, osfmk/mach/clock_reply.h, osfmk/mach/clock_reply_server.c, osfmk/mach/clock_reply_server.h
Generating osfmk/device/device_user.c, osfmk/device/device.h, osfmk/device/device_server.c, osfmk/device/device_server.h
Generating osfmk/default_pager/default_pager_object_user.c, osfmk/default_pager/default_pager_object.h, osfmk/default_pager/default_pager_object_server.c, osfmk/default_pager/default_pager_object_server.h
Generating osfmk/UserNotification/UNDReply_user.c, osfmk/UserNotification/UNDReply.h, osfmk/UserNotification/UNDReply_server.c, osfmk/UserNotification/UNDReply_server.h
Built target lkm_generate
Scanning dependencies of target lkm
Building the Linux kernel module
make[4]: Entering directory '/home/ricorobbins/darling/src/lkm'
Running kernel version is 4.19.43-microsoft-standard
rm -f darling-mach.mod.o
make -C /lib/modules/4.19.43-microsoft-standard/build M=/home/ricorobbins/darling/src/lkm modules
make[5]: Entering directory '/home/ricorobbins/darling/src/lkm'
make[5]: *** /lib/modules/4.19.43-microsoft-standard/build: No such file or directory.  Stop.
make[5]: Leaving directory '/home/ricorobbins/darling/src/lkm'
Makefile:291: recipe for target 'default' failed
make[4]: *** [default] Error 2
make[4]: Leaving directory '/home/ricorobbins/darling/src/lkm'
src/lkm/CMakeFiles/lkm.dir/build.make:57: recipe for target 'src/lkm/CMakeFiles/lkm' failed
make[3]: *** [src/lkm/CMakeFiles/lkm] Error 2
CMakeFiles/Makefile2:55841: recipe for target 'src/lkm/CMakeFiles/lkm.dir/all' failed
make[2]: *** [src/lkm/CMakeFiles/lkm.dir/all] Error 2
CMakeFiles/Makefile2:55848: recipe for target 'src/lkm/CMakeFiles/lkm.dir/rule' failed
make[1]: *** [src/lkm/CMakeFiles/lkm.dir/rule] Error 2
Makefile:15361: recipe for target 'lkm' failed
make: *** [lkm] Error 2

And before you ask, yes, I confirmed that I am, in fact, on WSL2:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\rico_> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-18.04    Running         2

As of right now, apart from opening a new issue within the MicrosoftDocs/WSL repository, I'm at a loss for what to do next.

bugaevc commented 5 years ago

make[5]: *** /lib/modules/4.19.43-microsoft-standard/build: No such file or directory. Stop.

That simply means that you don't have sources/headers for the kernel version you're running. Try this.

wizoomer95 commented 5 years ago

Okay, I've downloaded and extracted the kernel source from Microsoft, but I still cannot compile the kernel module:

ricorobbins@DESKTOP-Q0DM43J:~/darling/build5$ make lkm
Built target migcom
Built target migexe
Built target lkm_generate
Building the Linux kernel module
make[4]: Entering directory '/home/ricorobbins/darling/src/lkm'
Running kernel version is 4.19.43-microsoft-standard
rm -f darling-mach.mod.o
make -C /lib/modules/4.19.43-microsoft-standard/build M=/home/ricorobbins/darling/src/lkm modules
make[5]: Entering directory '/lib/modules/4.19.43-microsoft-standard/build'

  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

Running kernel version is 4.19.43-microsoft-standard
Invoked by kernel build system, building for 4.19.43
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_entry.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_hash.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_space.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_kmsg.o
/home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_kmsg.c: In function ‘ipc_kmsg_copyin’:
/home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_kmsg.c:2590:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if ((kmsg->ikm_header->msgh_bits & MACH_MSGH_BITS_COMPLEX) == 0)
     ^~
/home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_kmsg.c:2593:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  mr = ipc_kmsg_copyin_body( kmsg, space, map);
  ^~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_labelh.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_notify.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_object.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_pset.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_table.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mig_log.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mach_port.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mach_msg.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mach_debug.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mach_kernelrpc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_init.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_right.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_mqueue.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_port.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/sync_sema.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/down_interruptible.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/traps.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct.h:105:0,
                 from /home/ricorobbins/darling/src/lkm/darling/traps.c:20:
/home/ricorobbins/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/ricorobbins/darling/src/lkm/darling/traps.c: In function ‘mach_init’:
/home/ricorobbins/darling/src/lkm/darling/traps.c:201:1: warning: label ‘fail’ defined but not used [-Wunused-label]
 fail:
 ^~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/task_registry.o
/home/ricorobbins/darling/src/lkm/darling/task_registry.c: In function ‘darling_task_fork_wait_for_child’:
/home/ricorobbins/darling/src/lkm/darling/task_registry.c:471:2: warning: ignoring return value of ‘down_interruptible’, declared with attribute warn_unused_result [-Wunused-result]
  down_interruptible(&e->sem_fork);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/module.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/host_info.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/evprocfd.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/evpsetfd.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/pthread_kill.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/psynch_support.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/foreign_mm.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/darling_xnu_init.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_atomic.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_ipc_pset.o
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_ipc_pset.c: In function ‘duct_filt_machport_attach’:
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_ipc_pset.c:80:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_clock.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_debug.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_kalloc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_printf.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_startup.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_sysctl.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_task.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct.h:105:0,
                 from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_task.c:36:
/home/ricorobbins/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);
              ^~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread_act.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct.h:105:0,
                 from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread_act.c:36:
/home/ricorobbins/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);
              ^~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.o
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.c: In function ‘duct_thread_bootstrap’:
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.c:209:2: warning: #warning Init thread initialization disabled! [-Wcpp]
 #warning Init thread initialization disabled!
  ^~~~~~~
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.c: In function ‘duct_thread_create_internal’:
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.c:275:2: warning: #warning compat_uthread disabled [-Wcpp]
 #warning compat_uthread disabled
  ^~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread_call.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_waitqueue.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_zalloc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_libsa.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_machine_routines.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_machine_rtclock.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_pcb.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_init.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_kern.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_map.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_user.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct.h:105:0,
                 from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_user.c:35:
/home/ricorobbins/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);
              ^~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_arm_locks_arm.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_fileport.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/clock_oldops.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_clock.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_tt.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_sync.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_misc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/host.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_host.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_kobject.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/mk_timer.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_mig.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/locks.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-resident.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-thread-call.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-map.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-user.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-task.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-thread.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-audit-sessionport.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-locks.o
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-locks.c:113:2: warning: #warning Implement locks? [-Wcpp]
 #warning Implement locks?
  ^~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-misc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/mach/message.h:77:0,
                 from /home/ricorobbins/darling/src/lkm/osfmk/mach/policy.h:73,
                 from /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c:67:
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c: In function ‘processor_pset’:
/home/ricorobbins/darling/src/lkm/osfmk/mach/kern_return.h:94:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
 #define KERN_FAILURE   5
                        ^
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c:152:16: note: in expansion of macro ‘KERN_FAILURE’
         return KERN_FAILURE;
                ^~~~~~~~~~~~
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c: In function ‘pset_node_root’:
/home/ricorobbins/darling/src/lkm/osfmk/mach/kern_return.h:94:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
 #define KERN_FAILURE   5
                        ^
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c:159:16: note: in expansion of macro ‘KERN_FAILURE’
         return KERN_FAILURE;
                ^~~~~~~~~~~~
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c: In function ‘pset_create’:
/home/ricorobbins/darling/src/lkm/osfmk/mach/kern_return.h:94:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
 #define KERN_FAILURE   5
                        ^
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c:167:16: note: in expansion of macro ‘KERN_FAILURE’
         return KERN_FAILURE;
                ^~~~~~~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-syscall-emulation.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-zalloc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-sync-lock.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-machine.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-clock-oldops.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-thread-policy.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-task-policy.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-mk-sp.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-memory-object.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-kmod.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-kern.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-debug.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-thread-act.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-host-notify.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/bsd/dummy-kdebug.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/bsd/dummy-init.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/bsd/dummy-sched.o
  CC [M]  /home/ricorobbins/darling/src/lkm/libkern/gen/OSAtomicOperations.o
  AS [M]  /home/ricorobbins/darling/src/lkm/libkern/x86_64/OSAtomic.o
/home/ricorobbins/darling/src/lkm/libkern/x86_64/OSAtomic.o: warning: objtool: .text+0x0: unreachable instruction
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/task_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/clock_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/clock_priv_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/processor_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/host_priv_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/host_security_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/lock_set_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/mach_port_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/mach_vm_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/mach_host_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/processor_set_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/memory_object_name_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/thread_act_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/clock_reply_user.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/mach/notify_user.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/device/device_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/default_pager/default_pager_object_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/../../build5/src/lkm/osfmk/UserNotification/UNDReply_server.o
  CC [M]  /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_gen_bootargs.o
In file included from /home/ricorobbins/darling/src/lkm/bsd/i386/types.h:71:0,
                 from /home/ricorobbins/darling/src/lkm/bsd/machine/types.h:35,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/stdint.h:24,
                 from /home/ricorobbins/darling/src/lkm/osfmk/mach/mach_types.h:76,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_gen_bootargs.h:33,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_gen_bootargs.c:34:
/home/ricorobbins/darling/src/lkm/bsd/sys/cdefs.h:93:0: warning: "__CONCAT" redefined
 #define __CONCAT(x,y) x ## y

In file included from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe.h:33:0,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_gen_bootargs.c:33:
./include/linux/kernel.h:985:0: note: this is the location of the previous definition
 #define __CONCAT(a, b) a ## b

  CC [M]  /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe_kprintf.o
In file included from /home/ricorobbins/darling/src/lkm/bsd/i386/types.h:71:0,
                 from /home/ricorobbins/darling/src/lkm/bsd/machine/types.h:35,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/stdint.h:24,
                 from /home/ricorobbins/darling/src/lkm/osfmk/mach/mach_types.h:76,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe_kprintf.h:33,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe_kprintf.c:34:
/home/ricorobbins/darling/src/lkm/bsd/sys/cdefs.h:93:0: warning: "__CONCAT" redefined
 #define __CONCAT(x,y) x ## y

In file included from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe.h:33:0,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe_kprintf.c:33:
./include/linux/kernel.h:985:0: note: this is the location of the previous definition
 #define __CONCAT(a, b) a ## b

  CC [M]  /home/ricorobbins/darling/src/lkm/darling/binfmt.o
In file included from /home/ricorobbins/darling/src/lkm/bsd/i386/types.h:71:0,
                 from /home/ricorobbins/darling/src/lkm/bsd/machine/types.h:35,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/stdint.h:24,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/mach-o/loader.h:29,
                 from /home/ricorobbins/darling/src/lkm/darling/binfmt.c:24:
/home/ricorobbins/darling/src/lkm/bsd/sys/cdefs.h:93:0: warning: "__CONCAT" redefined
 #define __CONCAT(x,y) x ## y

In file included from ./arch/x86/include/asm/percpu.h:45:0,
                 from ./arch/x86/include/asm/current.h:6,
                 from ./include/linux/sched.h:12,
                 from ./include/linux/binfmts.h:5,
                 from /home/ricorobbins/darling/src/lkm/darling/binfmt.h:3,
                 from /home/ricorobbins/darling/src/lkm/darling/binfmt.c:20:
./include/linux/kernel.h:985:0: note: this is the location of the previous definition
 #define __CONCAT(a, b) a ## b

In file included from /home/ricorobbins/darling/src/lkm/darling/binfmt.c:442:0:
/home/ricorobbins/darling/src/lkm/darling/binfmt_loader.c: In function ‘load64’:
/home/ricorobbins/darling/src/lkm/darling/binfmt_loader.c:145:1: warning: label ‘no_slide’ defined but not used [-Wunused-label]
 no_slide:
 ^~~~~~~~
In file included from /home/ricorobbins/darling/src/lkm/darling/binfmt.c:447:0:
/home/ricorobbins/darling/src/lkm/darling/binfmt_loader.c: In function ‘load32’:
/home/ricorobbins/darling/src/lkm/darling/binfmt_loader.c:145:1: warning: label ‘no_slide’ defined but not used [-Wunused-label]
 no_slide:
 ^~~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/commpage.o
In file included from /home/ricorobbins/darling/src/lkm/bsd/i386/types.h:71:0,
                 from /home/ricorobbins/darling/src/lkm/bsd/machine/types.h:35,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/stdint.h:24,
                 from /home/ricorobbins/darling/src/lkm/darling/commpage.h:3,
                 from /home/ricorobbins/darling/src/lkm/darling/commpage.c:25:
/home/ricorobbins/darling/src/lkm/bsd/sys/cdefs.h:93:0: warning: "__CONCAT" redefined
 #define __CONCAT(x,y) x ## y

In file included from ./include/linux/list.h:9:0,
                 from ./include/linux/preempt.h:11,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/vmalloc.h:5,
                 from /home/ricorobbins/darling/src/lkm/darling/commpage.c:21:
./include/linux/kernel.h:985:0: note: this is the location of the previous definition
 #define __CONCAT(a, b) a ## b

/home/ricorobbins/darling/src/lkm/darling/commpage.c:36:0: warning: "__cpuid" redefined
 #define __cpuid(level, eax, ebx, ecx, edx) \

In file included from ./arch/x86/include/asm/cpufeature.h:5:0,
                 from ./arch/x86/include/asm/thread_info.h:53,
                 from ./include/linux/thread_info.h:38,
                 from ./arch/x86/include/asm/preempt.h:7,
                 from ./include/linux/preempt.h:81,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/vmalloc.h:5,
                 from /home/ricorobbins/darling/src/lkm/darling/commpage.c:21:
./arch/x86/include/asm/processor.h:584:0: note: this is the location of the previous definition
 #define __cpuid   native_cpuid

  LD [M]  /home/ricorobbins/darling/src/lkm/darling-mach.o
  Building modules, stage 2.
Running kernel version is 4.19.43-microsoft-standard
Invoked by kernel build system, building for 4.19.43
  MODPOST 1 modules
/bin/sh: 1: scripts/mod/modpost: not found
scripts/Makefile.modpost:92: recipe for target '__modpost' failed
make[6]: *** [__modpost] Error 127
Makefile:1527: recipe for target 'modules' failed
make[5]: *** [modules] Error 2
make[5]: Leaving directory '/lib/modules/4.19.43-microsoft-standard/build'
Makefile:291: recipe for target 'default' failed
make[4]: *** [default] Error 2
make[4]: Leaving directory '/home/ricorobbins/darling/src/lkm'
src/lkm/CMakeFiles/lkm.dir/build.make:57: recipe for target 'src/lkm/CMakeFiles/lkm' failed
make[3]: *** [src/lkm/CMakeFiles/lkm] Error 2
CMakeFiles/Makefile2:55841: recipe for target 'src/lkm/CMakeFiles/lkm.dir/all' failed
make[2]: *** [src/lkm/CMakeFiles/lkm.dir/all] Error 2
CMakeFiles/Makefile2:55848: recipe for target 'src/lkm/CMakeFiles/lkm.dir/rule' failed
make[1]: *** [src/lkm/CMakeFiles/lkm.dir/rule] Error 2
Makefile:15361: recipe for target 'lkm' failed
make: *** [lkm] Error 2
bugaevc commented 5 years ago

You should have modpost sources, but not modpost itself — you'd need to build it (I'm not sure if that's possible without building the whole kernel). Here's their new repo with the kernel sources: https://github.com/microsoft/WSL2-Linux-Kernel

wizoomer95 commented 5 years ago

I built the entire kernel as well and was now able to build the kernel module and install it, but I still can't seem to run darling:

modprobe: ERROR: could not insert 'darling_mach': Exec format error
Failed to load the kernel module

Perhaps I didn't build the kernel and/or kernel module properly? To double check, I attempted cmake inside a new directory and attempted to build the kernel module again. However, I encountered another build error:

ricorobbins@DESKTOP-Q0DM43J:~/darling/build7$ make lkm
[FLEX][MyScanner] Building scanner with flex 2.6.4
[BISON][MyParser] Building parser with bison 3.0.4
Scanning dependencies of target migcom
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/error.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/global.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/header.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/mig.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/routine.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/server.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/statement.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/string.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/type.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/user.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/migcom.tproj/utils.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/parser.o
Building C object src/bootstrap_cmds/CMakeFiles/migcom.dir/lexer.o
Linking C executable migcom
Built target migcom
Scanning dependencies of target migexe
Generating ../../mig
Built target migexe
Scanning dependencies of target lkm_generate
Generating osfmk/mach/upl_user.c, osfmk/mach/upl.h, osfmk/mach/upl_server.c, osfmk/mach/upl_server.h
Generating osfmk/mach/host_notify_reply_user.c, osfmk/mach/host_notify_reply.h, osfmk/mach/host_notify_reply_server.c, osfmk/mach/host_notify_reply_server.h
Generating osfmk/mach/vm32_map_user.c, osfmk/mach/vm32_map.h, osfmk/mach/vm32_map_server.c, osfmk/mach/vm32_map_server.h
Generating osfmk/mach/mach_notify_user.c, osfmk/mach/mach_notify.h, osfmk/mach/mach_notify_server.c, osfmk/mach/mach_notify_server.h
Generating osfmk/mach/security_user.c, osfmk/mach/security.h, osfmk/mach/security_server.c, osfmk/mach/security_server.h
Generating osfmk/mach/memory_object_control_user.c, osfmk/mach/memory_object_control.h, osfmk/mach/memory_object_control_server.c, osfmk/mach/memory_object_control_server.h
Generating osfmk/mach/memory_object_user.c, osfmk/mach/memory_object.h, osfmk/mach/memory_object_server.c, osfmk/mach/memory_object_server.h
Generating osfmk/mach/memory_object_default_user.c, osfmk/mach/memory_object_default.h, osfmk/mach/memory_object_default_server.c, osfmk/mach/memory_object_default_server.h
Generating osfmk/mach/vm_map_user.c, osfmk/mach/vm_map.h, osfmk/mach/vm_map_server.c, osfmk/mach/vm_map_server.h
Generating osfmk/mach/exc_user.c, osfmk/mach/exc.h, osfmk/mach/exc_server.c, osfmk/mach/exc_server.h
Generating osfmk/mach/mach_exc_user.c, osfmk/mach/mach_exc.h, osfmk/mach/mach_exc_server.c, osfmk/mach/mach_exc_server.h
Generating osfmk/mach/notify_user.c, osfmk/mach/notify.h, osfmk/mach/notify_server.c, osfmk/mach/notify_server.h
Generating osfmk/mach/task_user.c, osfmk/mach/task.h, osfmk/mach/task_server.c, osfmk/mach/task_server.h
Generating osfmk/mach/clock_user.c, osfmk/mach/clock.h, osfmk/mach/clock_server.c, osfmk/mach/clock_server.h
Generating osfmk/mach/clock_priv_user.c, osfmk/mach/clock_priv.h, osfmk/mach/clock_priv_server.c, osfmk/mach/clock_priv_server.h
Generating osfmk/mach/processor_user.c, osfmk/mach/processor.h, osfmk/mach/processor_server.c, osfmk/mach/processor_server.h
Generating osfmk/mach/host_priv_user.c, osfmk/mach/host_priv.h, osfmk/mach/host_priv_server.c, osfmk/mach/host_priv_server.h
Generating osfmk/mach/host_security_user.c, osfmk/mach/host_security.h, osfmk/mach/host_security_server.c, osfmk/mach/host_security_server.h
Generating osfmk/mach/lock_set_user.c, osfmk/mach/lock_set.h, osfmk/mach/lock_set_server.c, osfmk/mach/lock_set_server.h
Generating osfmk/mach/mach_port_user.c, osfmk/mach/mach_port.h, osfmk/mach/mach_port_server.c, osfmk/mach/mach_port_server.h
Generating osfmk/mach/mach_vm_user.c, osfmk/mach/mach_vm.h, osfmk/mach/mach_vm_server.c, osfmk/mach/mach_vm_server.h
Generating osfmk/mach/mach_host_user.c, osfmk/mach/mach_host.h, osfmk/mach/mach_host_server.c, osfmk/mach/mach_host_server.h
Generating osfmk/mach/processor_set_user.c, osfmk/mach/processor_set.h, osfmk/mach/processor_set_server.c, osfmk/mach/processor_set_server.h
Generating osfmk/mach/memory_object_name_user.c, osfmk/mach/memory_object_name.h, osfmk/mach/memory_object_name_server.c, osfmk/mach/memory_object_name_server.h
Generating osfmk/mach/thread_act_user.c, osfmk/mach/thread_act.h, osfmk/mach/thread_act_server.c, osfmk/mach/thread_act_server.h
Generating osfmk/mach/clock_reply_user.c, osfmk/mach/clock_reply.h, osfmk/mach/clock_reply_server.c, osfmk/mach/clock_reply_server.h
Generating osfmk/device/device_user.c, osfmk/device/device.h, osfmk/device/device_server.c, osfmk/device/device_server.h
Generating osfmk/default_pager/default_pager_object_user.c, osfmk/default_pager/default_pager_object.h, osfmk/default_pager/default_pager_object_server.c, osfmk/default_pager/default_pager_object_server.h
Generating osfmk/UserNotification/UNDReply_user.c, osfmk/UserNotification/UNDReply.h, osfmk/UserNotification/UNDReply_server.c, osfmk/UserNotification/UNDReply_server.h
Built target lkm_generate
Scanning dependencies of target lkm
Building the Linux kernel module
make[4]: Entering directory '/home/ricorobbins/darling/src/lkm'
Running kernel version is 4.19.43-microsoft-standard
rm -f darling-mach.mod.o
make -C /lib/modules/4.19.43-microsoft-standard/build M=/home/ricorobbins/darling/src/lkm modules
make[5]: Entering directory '/lib/modules/4.19.43-microsoft-standard/build'
Running kernel version is 4.19.43-microsoft-standard
Invoked by kernel build system, building for 4.19.43+
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_entry.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_hash.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_space.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_kmsg.o
/home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_kmsg.c: In function ‘ipc_kmsg_copyin’:
/home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_kmsg.c:2590:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if ((kmsg->ikm_header->msgh_bits & MACH_MSGH_BITS_COMPLEX) == 0)
     ^~
/home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_kmsg.c:2593:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  mr = ipc_kmsg_copyin_body( kmsg, space, map);
  ^~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_labelh.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_notify.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_object.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_pset.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_table.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mig_log.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mach_port.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mach_msg.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mach_debug.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/mach_kernelrpc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_init.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_right.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_mqueue.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/ipc/ipc_port.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/sync_sema.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/down_interruptible.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/traps.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct.h:105:0,
                 from /home/ricorobbins/darling/src/lkm/darling/traps.c:20:
/home/ricorobbins/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/ricorobbins/darling/src/lkm/darling/traps.c: In function ‘mach_init’:
/home/ricorobbins/darling/src/lkm/darling/traps.c:201:1: warning: label ‘fail’ defined but not used [-Wunused-label]
 fail:
 ^~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/task_registry.o
/home/ricorobbins/darling/src/lkm/darling/task_registry.c: In function ‘darling_task_fork_wait_for_child’:
/home/ricorobbins/darling/src/lkm/darling/task_registry.c:471:2: warning: ignoring return value of ‘down_interruptible’, declared with attribute warn_unused_result [-Wunused-result]
  down_interruptible(&e->sem_fork);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/module.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/host_info.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/evprocfd.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/evpsetfd.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/pthread_kill.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/psynch_support.o
  CC [M]  /home/ricorobbins/darling/src/lkm/darling/foreign_mm.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/darling_xnu_init.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_atomic.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_ipc_pset.o
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_ipc_pset.c: In function ‘duct_filt_machport_attach’:
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_ipc_pset.c:80:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_clock.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_debug.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_kalloc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_printf.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_startup.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_sysctl.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_task.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct.h:105:0,
                 from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_task.c:36:
/home/ricorobbins/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);
              ^~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread_act.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct.h:105:0,
                 from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread_act.c:36:
/home/ricorobbins/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);
              ^~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.o
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.c: In function ‘duct_thread_bootstrap’:
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.c:209:2: warning: #warning Init thread initialization disabled! [-Wcpp]
 #warning Init thread initialization disabled!
  ^~~~~~~
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.c: In function ‘duct_thread_create_internal’:
/home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread.c:275:2: warning: #warning compat_uthread disabled [-Wcpp]
 #warning compat_uthread disabled
  ^~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_thread_call.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_waitqueue.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_kern_zalloc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_libsa.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_machine_routines.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_machine_rtclock.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_pcb.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_init.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_kern.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_map.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_user.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct.h:105:0,
                 from /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_vm_user.c:35:
/home/ricorobbins/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);
              ^~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_arm_locks_arm.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/duct/duct_fileport.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/clock_oldops.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_clock.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_tt.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_sync.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_misc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/host.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_host.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_kobject.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/mk_timer.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/ipc_mig.o
  CC [M]  /home/ricorobbins/darling/src/lkm/osfmk/kern/locks.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-resident.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-thread-call.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-map.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-user.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-task.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-thread.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-audit-sessionport.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-locks.o
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-locks.c:113:2: warning: #warning Implement locks? [-Wcpp]
 #warning Implement locks?
  ^~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-misc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.o
In file included from /home/ricorobbins/darling/src/lkm/osfmk/mach/message.h:77:0,
                 from /home/ricorobbins/darling/src/lkm/osfmk/mach/policy.h:73,
                 from /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c:67:
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c: In function ‘processor_pset’:
/home/ricorobbins/darling/src/lkm/osfmk/mach/kern_return.h:94:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
 #define KERN_FAILURE   5
                        ^
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c:152:16: note: in expansion of macro ‘KERN_FAILURE’
         return KERN_FAILURE;
                ^~~~~~~~~~~~
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c: In function ‘pset_node_root’:
/home/ricorobbins/darling/src/lkm/osfmk/mach/kern_return.h:94:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
 #define KERN_FAILURE   5
                        ^
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c:159:16: note: in expansion of macro ‘KERN_FAILURE’
         return KERN_FAILURE;
                ^~~~~~~~~~~~
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c: In function ‘pset_create’:
/home/ricorobbins/darling/src/lkm/osfmk/mach/kern_return.h:94:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
 #define KERN_FAILURE   5
                        ^
/home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-processor.c:167:16: note: in expansion of macro ‘KERN_FAILURE’
         return KERN_FAILURE;
                ^~~~~~~~~~~~
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-syscall-emulation.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-zalloc.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-sync-lock.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-machine.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-clock-oldops.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-thread-policy.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-task-policy.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-mk-sp.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-memory-object.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-kmod.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-kern.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-vm-debug.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-thread-act.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/osfmk/dummy-kern-host-notify.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/bsd/dummy-kdebug.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/bsd/dummy-init.o
  CC [M]  /home/ricorobbins/darling/src/lkm/duct/bsd/dummy-sched.o
  CC [M]  /home/ricorobbins/darling/src/lkm/libkern/gen/OSAtomicOperations.o
  AS [M]  /home/ricorobbins/darling/src/lkm/libkern/x86_64/OSAtomic.o
/home/ricorobbins/darling/src/lkm/libkern/x86_64/OSAtomic.o: warning: objtool: .text+0x0: unreachable instruction
  CC [M]  /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_gen_bootargs.o
In file included from /home/ricorobbins/darling/src/lkm/bsd/i386/types.h:71:0,
                 from /home/ricorobbins/darling/src/lkm/bsd/machine/types.h:35,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/stdint.h:24,
                 from /home/ricorobbins/darling/src/lkm/osfmk/mach/mach_types.h:76,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_gen_bootargs.h:33,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_gen_bootargs.c:34:
/home/ricorobbins/darling/src/lkm/bsd/sys/cdefs.h:93:0: warning: "__CONCAT" redefined
 #define __CONCAT(x,y) x ## y

In file included from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe.h:33:0,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_gen_bootargs.c:33:
./include/linux/kernel.h:985:0: note: this is the location of the previous definition
 #define __CONCAT(a, b) a ## b

  CC [M]  /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe_kprintf.o
In file included from /home/ricorobbins/darling/src/lkm/bsd/i386/types.h:71:0,
                 from /home/ricorobbins/darling/src/lkm/bsd/machine/types.h:35,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/stdint.h:24,
                 from /home/ricorobbins/darling/src/lkm/osfmk/mach/mach_types.h:76,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe_kprintf.h:33,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe_kprintf.c:34:
/home/ricorobbins/darling/src/lkm/bsd/sys/cdefs.h:93:0: warning: "__CONCAT" redefined
 #define __CONCAT(x,y) x ## y

In file included from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe.h:33:0,
                 from /home/ricorobbins/darling/src/lkm/pexpert/duct/duct_pe_kprintf.c:33:
./include/linux/kernel.h:985:0: note: this is the location of the previous definition
 #define __CONCAT(a, b) a ## b

  CC [M]  /home/ricorobbins/darling/src/lkm/darling/binfmt.o
In file included from /home/ricorobbins/darling/src/lkm/bsd/i386/types.h:71:0,
                 from /home/ricorobbins/darling/src/lkm/bsd/machine/types.h:35,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/stdint.h:24,
                 from /home/ricorobbins/darling/src/lkm/EXTERNAL_HEADERS/mach-o/loader.h:29,
                 from /home/ricorobbins/darling/src/lkm/darling/binfmt.c:24:
/home/ricorobbins/darling/src/lkm/bsd/sys/cdefs.h:93:0: warning: "__CONCAT" redefined
 #define __CONCAT(x,y) x ## y

In file included from ./arch/x86/include/asm/percpu.h:45:0,
                 from ./arch/x86/include/asm/current.h:6,
                 from ./include/linux/sched.h:12,
                 from ./include/linux/binfmts.h:5,
                 from /home/ricorobbins/darling/src/lkm/darling/binfmt.h:3,
                 from /home/ricorobbins/darling/src/lkm/darling/binfmt.c:20:
./include/linux/kernel.h:985:0: note: this is the location of the previous definition
 #define __CONCAT(a, b) a ## b

/home/ricorobbins/darling/src/lkm/darling/binfmt.c:55:10: fatal error: rtsig.h: No such file or directory
 #include <rtsig.h>
          ^~~~~~~~~
compilation terminated.
scripts/Makefile.build:303: recipe for target '/home/ricorobbins/darling/src/lkm/darling/binfmt.o' failed
make[6]: *** [/home/ricorobbins/darling/src/lkm/darling/binfmt.o] Error 1
Makefile:1524: recipe for target '_module_/home/ricorobbins/darling/src/lkm' failed
make[5]: *** [_module_/home/ricorobbins/darling/src/lkm] Error 2
make[5]: Leaving directory '/lib/modules/4.19.43-microsoft-standard/build'
Makefile:291: recipe for target 'default' failed
make[4]: *** [default] Error 2
make[4]: Leaving directory '/home/ricorobbins/darling/src/lkm'
src/lkm/CMakeFiles/lkm.dir/build.make:57: recipe for target 'src/lkm/CMakeFiles/lkm' failed
make[3]: *** [src/lkm/CMakeFiles/lkm] Error 2
CMakeFiles/Makefile2:55841: recipe for target 'src/lkm/CMakeFiles/lkm.dir/all' failed
make[2]: *** [src/lkm/CMakeFiles/lkm.dir/all] Error 2
CMakeFiles/Makefile2:55848: recipe for target 'src/lkm/CMakeFiles/lkm.dir/rule' failed
make[1]: *** [src/lkm/CMakeFiles/lkm.dir/rule] Error 2
Makefile:15361: recipe for target 'lkm' failed
make: *** [lkm] Error 2

The only thing I did that was different between my first attempt at building the kernel module and this new attempt was restarting the make lkm command after fixing more kernel-related dependency issues. I'm at a loss. Unless I'm missing something, as of now, it appears even on WSL2, Darling is a no-go.

JohnHolmesII commented 5 years ago

I have WSL2 running, and my results are the exact opposite. The guy above clearly has a corrupted or broken system, given the sheer number of issues he ran into. The only thing I had to do to build it was sudo dpkg --add-architecture i386 && sudo apt update, and then followed the normal Ubuntu build instructions. No other steps of any kind were necessary. Does it run? I have no idea, as I don't know of a good way of testing darling.

One thing to note is that the build system creates many symlinks, meaning this can only be built on linux filesystems, i.e. the native WSL2 area.

JohnHolmesII commented 5 years ago

Oh, and there are some very bizarre warnings throughout the build, which is why I'm worried about it running.

wizoomer95 commented 5 years ago

Quick question: Which variant of Ubuntu did you install in WSL2: Ubuntu 16.04, Ubuntu 18.04, or the one simply named Ubuntu? I currently have the Ubuntu 18.04 installed, which could explain some issues if you're using a different version of Ubuntu.

And I did get a lot of warnings during the build process, actually. The only thing I couldn't get to compile properly was the kernel module. I'm not a developer by any stretch of the imagination, but I am tech-savvy and have messed around compiling other things already written before. Honestly, my past issues might be caused by other hardware-related issues. If I left WSL2 running for a prolonged period of time, my system tended to crash. Sometimes after a few hours, sometimes after 15 minutes. I didn't think anything of it because WSL2 is new and not in a stable build of Windows, but it could be that my system is broken.

Honestly, I'd keep testing it myself, but right now I'm just a macOS enthusiast. In fact, the Windows system I tested it on was a multiboot Hackintosh, so I have no need to use Darling in my daily workflow. Depending on the extent of GUI support, once it's figured out and added, I might be able to create a "poor man's Hackintosh", if you will, and use that instead. Far more legal and less EULA issues to worry about. It's a pipe dream, for now, but maybe GUI support will be figured out by the time WSL2 becomes mainstream.

For now, I just wanted to see if it could work, and since no one had started attempting it yet, I decided to give it a go myself. I'm glad you got it working! Maybe I'd be better off uninstalling WSL2 and going back to a stable build of Windows.

JohnHolmesII commented 5 years ago

I'm on 18.04 as well. In particular, I'm referring to things like having to reinstall simple packages, and the fact that clang is actually available as a normal package.

Looking at my comment, I may have given the impression that I got the whole thing running. I did not 😄 . I did get it to build very smoothly though.

ahyattdev commented 5 years ago

@JohnHolmesII this is exciting. In order to test it, just run darling shell. If the shell works then we can assume Darling works in WSL 😄

oscarbg commented 5 years ago

Hi tested today with latest on Debian 10 on WSL2 on latest 18956 insider (ships with kernel 4.19.57) builded ok after fixing clang with update-alternatives present in instructions.. kernel builded with downloaded 4.19.57 from Microsoft WSL2 kernel repo.. a notice I needed to change wsl-config from Microsoft repo to disable "CONFIG_EMBEDDED not set" if not building darling module failed with: task_watch_t not defined.. then I run darling shell:

Loaded the kernel module
Setting up a new Darling prefix at /home/osc2/.darling
Bootstrapping the container with launchd...

and then lots of errors even when I close with ctr+c

Assertion failed: (status == 0), function main, file /home/osc2/darling/src/libnotify/notifyd/notifyd.c, line 1207.

did a dmesg log:

sudo dmesg

darlingbaddmesg.txt

EDITED: attached dmesg as file

oscarbg commented 5 years ago

ok guys.. finally success! diff from previous effort: first learned how to compile & use custom kernel on WSL2.. due to needing module being compiled with a kernel built with "CONFIG_EMBEDDED not set" as previously rebuilt kernel with that flag but was not used still and used default(read provided by Microsoft) kernel (with CONFIG_EMBEDDED=y).. thing to note here: I made the mistake of thinking WSL2Kernel releases from Github (like https://github.com/microsoft/WSL2-Linux-Kernel/releases/tag/v4.19.57) were "Microsoft enhanced WSL2 kernels" in fact they are not.. a simple diff with official kernel from kernel.org shows no differences hence no Microsoft WSL2 patches.. EDIT: important to note, as currently no matter how effort you put on running your built "original kernel" you will have not success.. note even I tried latest 5.3rc4 as some WSL2 patches seems to have been upstreamed by Microsoft but also not have success (all using wsl-config).. seems the correct way is to clone repo (a hint that shouldn't be omitted that this is the only patched kernel is that it contains Microsoft folder with wsl-config).. In fact I cloned branch https://github.com/microsoft/WSL2-Linux-Kernel/tree/linux-msft-wsl-4.19.y which has newer 4.19.67 kernel which served two purposed in my learning:

Once module was built from this "running" kernel this time still produced similar errors.. So finally tried "sudo darling shell" and now it works on Debian WSL2 distro..

Note I don't remember if in my last test I ran darling with sudo.. perhaps it should have worked with original kernel as long as you built a kernel " CONFIG_EMBEDDED not set" but not used as boot kernel.. Guess issue can be closed now..

CuriousTommy commented 5 years ago

@oscarbg Glad to see that you are able to get it working on WSL2; however, it does bring up a few questions.

  1. Why does Darling not like having CONFIG_EMBEDDED enabled?
  2. Why does Microsoft currently have CONFIG_EMBEDDED enabled?
oscarbg commented 5 years ago

@CuriousTommy

  1. it's because Darling kernel module source code if CONFIG_EMBEDDED is enabled uses task_watch_t variable not defined anywhere.. altough probably not WSL2 specific as probably major Linux distros ship with built kernel with CONFIG_EMBEDDED not set..
  2. better may be asking Microsoft.. probably an oversight with so much kernel flags/options.. they keep changing kernel flags every kernel update from what I see.. I think if we ask them at https://github.com/microsoft/WSL2-Linux-Kernel they will have no problem disabling the flag..
CuriousTommy commented 5 years ago

@oscarbg Would you be willing to open up an issue over there?

Edit: Or we could just fix the darling's code to use an alternative type when CONFIG_EMBEDDED is enabled.

Edit2: It is strange that darling can't find task_watch_t. It seems to be defined here: https://github.com/darlinghq/darling-newlkm/blob/dee2bd58b46847fbe948b1f5445479b3a2b60a53/osfmk/kern/task.h#L217

Especially since thread.h imports <kern/task.h>: https://github.com/darlinghq/darling-newlkm/blob/596145436ae77cbd0377f92bc2be9448d3008936/osfmk/kern/thread.h#L123

oscarbg commented 5 years ago

@CuriousTommy yep I believe task_watch_t issue was on osfmk/kern/task.h file.. I opened WSL2 Kernel issue: https://github.com/microsoft/WSL2-Linux-Kernel/issues/39

facekapow commented 5 years ago

EDIT

Please refer to the official instructions now.

I'm leaving the original message here for posterity's sake.


Hi, first of all, big thanks to all the Darling contributors for this amazing piece of software! Great job!

Second, I'd just like to confirm that @oscarbg's method does in fact work, with the catch that I must run darling shell as root (sudo darling shell) otherwise I get a bunch failed assertion errors (the same ones @oscarbg was getting) that seem to be coming from the kernel module, seeing as how they don't stop even after killing darling.

Other than that, everything runs as expected! I'm pretty sure Curl not being able to download over HTTPS because of SSL errors is normal in Darling, right? (According to #463, at least it is). I'm just asking since the first thing I tried to do was install Homebrew (which failed due to no support for HTTPS).

DIY Instructions

Want to try out Darwin in the WSL? Here are some instructions to try this out for yourself:

1. Build most of the components

Open up a WSL shell and paste the following code. This will download, compile, and install most of the Darling components, except the kernel module, and then it'll download, compile, and install a modified WSL kernel (and copy it to your C: drive so it can be used).

Note that parts where it says 5.4.81 might need to be tweaked, since the patch number might've change from the last time this guide was updated.

# make sure APT can find 32-bit libraries
sudo dpkg --add-architecture i386
sudo apt-get update

# install the necessary dependencies
sudo apt-get install cmake clang bison flex xz-utils libfuse-dev libudev-dev pkg-config libc6-dev:i386 linux-headers-generic gcc-multilib libcap2-bin libcairo2-dev libgl1-mesa-dev libtiff5-dev libfreetype6-dev libfreetype6-dev:i386 git libelf-dev libxml2-dev libegl1-mesa-dev libfontconfig1-dev libbsd-dev

# clone and configure Darling
git clone --recursive https://github.com/darlinghq/darling.git
cd darling
mkdir build && cd build
cmake ..

# symlink some files that are missing from `/usr/include`
# i had to do this on my system, maybe on your system you don't
# in any case, it won't hurt to symlink them even if you do have them in `/usr/include`
sudo ln -s /usr/include/x86_64-linux-gnu/jconfig.h /usr/include/jconfig.h
sudo ln -s /usr/include/x86_64-linux-gnu/tiffio.h /usr/include/tiffio.h
sudo ln -s /usr/include/x86_64-linux-gnu/tiff.h /usr/include/tiff.h
sudo ln -s /usr/include/x86_64-linux-gnu/tiffconf.h /usr/include/tiffconf.h
sudo ln -s /usr/include/x86_64-linux-gnu/tiffvers.h /usr/include/tiffvers.h
sudo ln -s /usr/include/x86_64-linux-gnu/tiffio.hxx /usr/include/tiffio.hxx

# build most of Darling
make
sudo make install

# before we can build the kernel module, we need to build the modified kernel
cd ../..

# clone and modify the kernel
git clone --depth 1 --single-branch --branch linux-msft-wsl-5.4.y https://github.com/microsoft/WSL2-Linux-Kernel.git kernel
cd kernel
sed -i 's/CONFIG_EMBEDDED=y/CONFIG_EMBEDDED=n/g' Microsoft/config-wsl

# build and install the kernel
make KCONFIG_CONFIG=Microsoft/config-wsl
sudo make modules_install
sudo make install
sudo update-initramfs -c -k 5.4.81-microsoft-standard-WSL2+

# copy the kernel to your C: drive
mkdir /mnt/c/linux-kernels
cp /boot/vmlinuz-5.4.81-microsoft-standard-WSL2+ /mnt/c/linux-kernels/vmlinuz-5.4.81-microsoft-standard-WSL2+

2. Configure WSL to use your new kernel

Now, you need to edit (or create) your .wslconfig (in your Windows home directory) and add the following:

[wsl2]
# ... other settings (if you have any) ...
kernel=C:\\linux-kernels\\vmlinuz-5.4.81-microsoft-standard-WSL2+

Then, in PowerShell or CMD, shutdown the WSL by doing the following:

wsl --shutdown

3. Build the Darling kernel module

Open up another WSL prompt, and paste the following code. This will compile and install the kernel module

# get back to the directory you built Darling in
cd darling/build
make lkm
sudo make lkm_install

4. Enjoy!

darling shell

You now have a functioning Darwin-in-Ubuntu-in-Windows abomination 😁 ! Happy hacking!

Update The build instructions have been updated to use Microsoft's 5.4 kernel, given that Darling now requires a 5.x kernel to run and Microsoft ships 4.x by default.

sempervictus commented 4 years ago

Jeebus, MSFT builds their kernel as embedded? Do they strip symbols too? :)

Berrysoft commented 4 years ago

@facekapow I followed your instruction but failed at step 3. The compiler cannot find lck_mtx_t.

First errors:

In file included from /home/berrysoft/GitHub/darling/src/external/lkm/osfmk/machine/locks.h:32,
                 from /home/berrysoft/GitHub/darling/src/external/lkm/osfmk/kern/locks.h:37,
                 from /home/berrysoft/GitHub/darling/src/external/lkm/osfmk/kern/queue.h:1016,
                 from /home/berrysoft/GitHub/darling/src/external/lkm/osfmk/ipc/ipc_voucher.h:38,
                 from /home/berrysoft/GitHub/darling/src/external/lkm/../../../build/src/external/lkm/osfmk/mach/mach_exc_server.h:34,
                 from /home/berrysoft/GitHub/darling/src/external/lkm/../../../build/src/external/lkm/osfmk/mach/mach_exc_server.c:13:
/home/berrysoft/GitHub/darling/src/external/lkm/osfmk/i386/locks.h:115:39: error: unknown type name ‘lck_mtx_t’
  115 | extern int  lck_mtx_lock_spinwait_x86(lck_mtx_t *mutex);
      |                                       ^~~~~~~~~
/home/berrysoft/GitHub/darling/src/external/lkm/osfmk/i386/locks.h:116:36: error: unknown type name ‘lck_mtx_t’
  116 | extern void  lck_mtx_lock_wait_x86(lck_mtx_t *mutex);
      |                                    ^~~~~~~~~
/home/berrysoft/GitHub/darling/src/external/lkm/osfmk/i386/locks.h:117:39: error: unknown type name ‘lck_mtx_t’
  117 | extern void  lck_mtx_lock_acquire_x86(lck_mtx_t *mutex);
      |                                       ^~~~~~~~~
/home/berrysoft/GitHub/darling/src/external/lkm/osfmk/i386/locks.h:118:40: error: unknown type name ‘lck_mtx_t’
  118 | extern void  lck_mtx_unlock_wakeup_x86(lck_mtx_t *mutex, int prior_lock_state);
      |                                        ^~~~~~~~~
/home/berrysoft/GitHub/darling/src/external/lkm/osfmk/i386/locks.h:120:42: error: unknown type name ‘lck_mtx_t’
  120 | extern void  lck_mtx_lock_mark_destroyed(lck_mtx_t *mutex);
      |                                          ^~~~~~~~~
/home/berrysoft/GitHub/darling/src/external/lkm/osfmk/i386/locks.h:121:37: error: unknown type name ‘lck_mtx_t’
  121 | extern int  lck_mtx_lock_grab_mutex(lck_mtx_t *mutex);
      |                                     ^~~~~~~~~
/home/berrysoft/GitHub/darling/src/external/lkm/osfmk/i386/locks.h:141:2: error: unknown type name ‘lck_mtx_t’
  141 |  lck_mtx_t  lck_mtx;
      |  ^~~~~~~~~

Also it seems that the \\ in step 2 should be \.

facekapow commented 4 years ago

@Berrysoft Unfortunately, as of now, older kernels like the one Microsoft is using are not supported. They might still build, but they're not officially supported.

Maybe you could try again with the latest code from master; @LubosD recently pushed a fix for the lck_mtx_t issue.

Also it seems that the \\ in step 2 should be \.

Actually, no. See this Microsoft doc, particularly this:

Entries with the path value must be Windows paths with escaped backslashes, e.g: C:\\Temp\\myCustomKernel

jthoward64 commented 4 years ago

I know there have been some workarounds found for this, but is there any hope of Darling getting official support for WSL2?Especially with all the new developments as of Build 2020.

The-SamminAter commented 4 years ago

I know that this may be slightly off-topic, but is any WSL downloaded from the Microsoft Store WSL2? Is WSL2 available/can it be obtained on Win 10 LTSC (build 17763)?

facekapow commented 4 years ago

I know there have been some workarounds found for this, but is there any hope of Darling getting official support for WSL2?Especially with all the new developments as of Build 2020.

@tajetaje Our position on this at the moment is pretty much "if it works, it works": we'll accept patches to make it work, but we won't support it officially.

I know that this may be slightly off-topic, but is any WSL downloaded from the Microsoft Store WSL2? Is WSL2 available/can it be obtained on Win 10 LTSC (build 17763)?

@The-SamminAter The apps you download from the Microsoft Store are just the Linux distros that run atop the WSL; the actual WSL is distributed as an optional Windows feature. To be able to enable WSL 2, you need to be on Windows build number 19041 or higher (see https://docs.microsoft.com/en-us/windows/wsl/wsl2-index).

The-SamminAter commented 4 years ago

@The-SamminAter The apps you download from the Microsoft Store are just the Linux distros that run atop the WSL; the actual WSL is distributed as an optional Windows feature. To be able to enable WSL 2, you need to be on Windows build number 19041 or higher (see https://docs.microsoft.com/en-us/windows/wsl/wsl2-index).

Ok, thanks for the information.

mateushnsoares commented 4 years ago

Any update on this issue ?

jthoward64 commented 4 years ago

Any update on this issue ?

See the response from facekapow, basically whenever WSL gets close enough to bare-metal Linux that it works out-of-the box, that'll be when you might expect support. It's the same way that you CAN run x86 apps on ARM, but don't expect help from Adobe for photoshop crashing, until that is, ARM's capabilities include full emulation of x86.

facekapow commented 2 years ago

Closing this as we no longer use a kernel module.

jthoward64 commented 2 years ago

Has anyone gotten it to work since?

facekapow commented 2 years ago

It should work normally in the WSL now, just like it does on Linux.