Make toolchain/install failed on WSL2 debian 9

Hello, I'm new to openwrt. I followed instructions from [OpenWrt Wiki] Preparing your OpenWrt build system for use

When I execute

make toolchain/install

I got the following error:

WARNING: Makefile 'package/utils/busybox/Makefile' has a build dependency on 'libpam', which does not exist
WARNING: Makefile 'package/boot/kexec-tools/Makefile' has a dependency on 'liblzma', which does not exist
WARNING: Makefile 'package/network/services/lldpd/Makefile' has a dependency on 'libnetsnmp', which does not exist
WARNING: Makefile 'package/luci-app-xray/Makefile' has a dependency on 'curl', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a build dependency on 'libpam', which does not exist
make[2]: Entering directory '/mnt/d/code/openwrt/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/mnt/d/code/openwrt/scripts/config'
 make[1] toolchain/install
 make[2] tools/compile
 make[3] -C tools/flock compile
 make[3] -C tools/xz compile
    ERROR: tools/xz failed to build.
make -r toolchain/install: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what's going on
/mnt/d/code/openwrt/include/toplevel.mk:228: recipe for target 'toolchain/install' failed
make: *** [toolchain/install] Error 1

My WSL2 environment:

Distributor ID: Debian
Description:    Debian GNU/Linux 9.13 (stretch)
Release:        9.13
Codename:       stretch

And I use the openwrt-22.03 branch and target device is Xiaomi-CR6608.

I already make sure I execute

./scripts/feeds update -a
./scripts/feeds install -a

and every commands is running by non-sudo priviledge.

I tried to run with -j1 V=s and the output is:

...
checking whether ln -s works... yes
checking whether make supports the include directive... cat: -: No such file or
directory
no
checking for x86_64-pc-linux-gnu-gcc... gcc
cat: -: No such file or directory
checking whether the C compiler works... no
configure: error: in `/mnt/d/code/openwrt/build_dir/host/xz-5.2.5':
configure: error: C compiler cannot create executables
See `config.log' for more details
Makefile:36: recipe for target '/mnt/d/code/openwrt/build_dir/host/xz-5.2.5/.con
figured' failed
make[3]: *** [/mnt/d/code/openwrt/build_dir/host/xz-5.2.5/.configured] Error 77
make[3]: Leaving directory '/mnt/d/code/openwrt/tools/xz'
time: tools/xz/compile#0.27#0.05#1.65
    ERROR: tools/xz failed to build.
tools/Makefile:166: recipe for target 'tools/xz/compile' failed
make[2]: *** [tools/xz/compile] Error 1
make[2]: Leaving directory '/mnt/d/code/openwrt'
tools/Makefile:164: recipe for target '/mnt/d/code/openwrt/staging_dir/host/stam
p/.tools_compile_yyyyyynnyyyyynyyyyyynyynyyynynyyyyyyyyyyyyyyyyynynnyyyyyyyy' fa
iled
make[1]: *** [/mnt/d/code/openwrt/staging_dir/host/stamp/.tools_compile_yyyyyynn
yyyyynyyyyyynyynyyynynyyyyyyyyyyyyyyyyynynnyyyyyyyy] Error 2
make[1]: Leaving directory '/mnt/d/code/openwrt'
/mnt/d/code/openwrt/include/toplevel.mk:228: recipe for target 'toolchain/instal
l' failed
make: *** [toolchain/install] Error 2
%

and in the build_dir/host/xz-5.2.5/config.log:

...
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18+deb9u1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1) 
configure:5286: $? = 0
configure:5275: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:5286: $? = 1
configure:5275: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:5286: $? = 1
configure:5306: checking whether the C compiler works
configure:5328: gcc -O2 -I/mnt/d/code/openwrt/staging_dir/host/include  -I/mnt/d/code/openwrt/staging_dir/host/include  -L/mnt/d/code/openwrt/staging_dir/host/lib  conftest.c  >&5
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
...

Ensure the path doesn't have blank spaces. In WSL the path includes windows names with blanks. The easiest way to overcome that is to run make with a different PATH variable. So, instead of:

make toolchain/install

use

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make toolchain/install

or

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
make toolchain/install

A third option could be creating an alias, including it into the .bashrc or .zshrc:

alias mk='PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make'

And then using it instead of make:

mk toolchain/install

You can/should remove the Windows Paths in WSL/WSL2 installs.

1 Like

It is not necessary and it can remove a lot of cross-functionality such as the ability to use integrated VScode and other tools. Since there are less invasive ways to solve the issue without sacrificing the benefits of WSL2, completely removing Windows paths should be the very last option.

1 Like

In a WSL2 environment, the entire vhdx is a single file that is mounted, not a standard file tree on the NTFS drive. WSL does mount to the Host system via /mnt/ though, and even with the Pathing turned off, you can access the device via \\wsl$\

I don't use vscode myself (everything is done via nano and the terminal), but having the Windows paths left in is a known problem area.

As you start using VScode and start using Windows-Linux integration, you will see the value in the whole platform. WSL is much more, but without the Windows-Linux interoperability, it is only another virtualized Linux.

Actually, the problem is not the interoperability, but the mistakes and errors in the build software. The problem shows up because the original shell scripts are using string variables without double-quotes (a common shell script mistake). If you have Linux paths with blank spaces you will have the same issue, so it is not only a WSL problem. Assuming that there will be no blank spaces in the folder or file names is the source of the problem and at some point in the future, it will be solved.

I have been using WSL for development for a while, and I am only having that issue with the OpenWrt toolchain.

I use now the alias solution, as it is faster, easier to type, and compatible with everything else.