How to Configure WSL2 for build rustc Using Visual Studio Build Tools on Windows?

I use wsl2-ubuntu to build the rustc compiler.
To compile for windows target:

./x build --target x86_64-pc-windows-msvc

I need VS Build Tools, which I have installed on windows.

Initially ubuntu required link.exe and I set the path to it in the PATH variable
In bashrc I added:

export PATH=$PATH:/mnt/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2022/BuildTools/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64

This solved the problem with link.exe, but a new one appeared:

          LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
          
note: `link.exe` returned an unexpected error

note: you may need to install Visual Studio build tools with the "C++ build tools" workload

error: could not compile `std` (lib) due to 1 previous error
Build completed unsuccessfully in 0:00:17

Is there any possibility to connect to linux all necessary tools for compilation under windows for rustc build?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.