前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Perf for WSL2

Perf for WSL2

原创
作者头像
zedware
修改2021-08-31 10:56:14
1.8K0
修改2021-08-31 10:56:14
举报
文章被收录于专栏:Programming

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,

  1. Clone the kernel source code for WSL2 Linux
代码语言:txt
复制
```
代码语言:txt
复制
$ git clone https://github.com/microsoft/WSL2-Linux-Kernel
代码语言:txt
复制
```
  1. Kernel version must match `uname -a`, find the correct tag.
代码语言:txt
复制
<https://github.com/microsoft/WSL2-Linux-Kernel/tags>
  1. Get latest tags and check it out
代码语言:txt
复制
<https://devconnected.com/how-to-checkout-git-tags/>
代码语言:txt
复制
```
代码语言:txt
复制
$ git fetch --all --tags
代码语言:txt
复制
$ git checkout tags/<tag> -b <branch>
代码语言:txt
复制
```
  1. Build (make sure to install the missing packages)
代码语言:txt
复制
```
代码语言:txt
复制
$ cd WSL2-Linux-Kernel/tools/perf
代码语言:txt
复制
$ make
代码语言:txt
复制
<snipped>
代码语言:txt
复制
Makefile.config:600: slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev
代码语言:txt
复制
Makefile.config:614: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
代码语言:txt
复制
<snipped>
代码语言:txt
复制
```
代码语言:txt
复制
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 删除。

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档