WSL2 has better support for native Linux development, and Vscode can work with it well. But it doesn't provide the `perf' command, which is used intensively. The post in stackoverflow provides several solutions. One solution is to build `perf' from the source code. And it is the most reliable way to keep the `perf' command matching the Linux kernel.
The steps are listed as follows,
```
$ git clone https://github.com/microsoft/WSL2-Linux-Kernel
```
<https://github.com/microsoft/WSL2-Linux-Kernel/tags>
<https://devconnected.com/how-to-checkout-git-tags/>
```
$ git fetch --all --tags
$ git checkout tags/<tag> -b <branch>
```
```
$ cd WSL2-Linux-Kernel/tools/perf
$ make
<snipped>
Makefile.config:600: slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev
Makefile.config:614: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
<snipped>
```
Hold breath. Pay attention to the error messages and install the missing packages. For example, If TUI is not enabled, "perf top -g" will not have the expandable "+" sign. Without this functionality, perf (top\|report) -g's output is ugly and not readable. If there are any warnings saying the include files' mismatch, make sure to sync the kernel include files with the tools include files. Copying files from $topdir/include/xxx to tools/include/xxx may not work, see <https://github.com/bombela/backward-cpp/pull/165/files> for a concrete example on errors in srcline.c.
If everything is OK, you can run the perf command under tools/ directory or copy it to /usr/bin/perf.
links to: https://zedware.github.io
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。