Since Windows 10 version 2004 (and WSL2) are now officially available outside of the Insider Preview program, I figured I should finally clean up my notes, and document how to setup WSL2 to compile Asuswrt-Merlin.
I initially tried this on my new laptop to see how the performance was. First results were horrible, build times on the laptop took three times longer than on the desktop's VM. After a few exchanges on Twitter with other WSL2 users (and Microsoft's own Program Manager responsible for WSL), we finally tracked down the issue to the search path (building the firmware requires to execute the compiler many thousands of times). Searching through the Windows portion of the path introduced a major performance penalty.
After configuring WSL to not include the Windows search path within the Linux search path, I was able to get an RT-AC68U firmware to build in 25 minutes under WSL2 on my new laptop (an AMD Ryzen 5 4500U 6-cores). Doing the same build on the laptop running VirtualBox took 30 minutes. So at least with this AMD CPU, WSL2 is quite faster than VBox.
For reference, my desktop's i7 7700K running VMWare Player does it in about 20-21 minutes. Can't install WSL2 on it to compare as I need VMWare for work purposes, and WSL2 requires Hyper-V, which is currently incompatible with other hypervisors. Both VMWare and VBox devs are working on this. VBox already kinda supports running under Hyper-V, but it's much, much slower at the moment.
So for anyone who wants a build environment without the bulkiness of a VM, WSL2 is a very viable option. If you try it out, I'd be curious to see the performance difference for your system between WSL2 and a VM.
The guide was added to the Wiki:
https://github.com/RMerl/asuswrt-merlin.ng/wiki/Compiling-under-WSL2
I initially tried this on my new laptop to see how the performance was. First results were horrible, build times on the laptop took three times longer than on the desktop's VM. After a few exchanges on Twitter with other WSL2 users (and Microsoft's own Program Manager responsible for WSL), we finally tracked down the issue to the search path (building the firmware requires to execute the compiler many thousands of times). Searching through the Windows portion of the path introduced a major performance penalty.
After configuring WSL to not include the Windows search path within the Linux search path, I was able to get an RT-AC68U firmware to build in 25 minutes under WSL2 on my new laptop (an AMD Ryzen 5 4500U 6-cores). Doing the same build on the laptop running VirtualBox took 30 minutes. So at least with this AMD CPU, WSL2 is quite faster than VBox.
For reference, my desktop's i7 7700K running VMWare Player does it in about 20-21 minutes. Can't install WSL2 on it to compare as I need VMWare for work purposes, and WSL2 requires Hyper-V, which is currently incompatible with other hypervisors. Both VMWare and VBox devs are working on this. VBox already kinda supports running under Hyper-V, but it's much, much slower at the moment.
So for anyone who wants a build environment without the bulkiness of a VM, WSL2 is a very viable option. If you try it out, I'd be curious to see the performance difference for your system between WSL2 and a VM.
The guide was added to the Wiki:
https://github.com/RMerl/asuswrt-merlin.ng/wiki/Compiling-under-WSL2