Skip to content

Commit

Permalink
docs(pages): add compilation steps docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hengyoush committed Dec 3, 2024
1 parent 634abea commit f84cc67
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ export default defineConfig({
{ text: 'How to use watch', link: './watch' },
{ text: 'How to use stat', link: './stat' },
]
},
{
text: 'Development',
items: [

{ text: 'How to build', link: './how-to-build' },
]
}
],

Expand Down
46 changes: 46 additions & 0 deletions docs/cn/how-to-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
next:
prev: false
---

# 编译步骤

本文介绍 kyanos 的本地编译方法,我的环境是ubuntu 22.04,其他环境可能会有所不同。

## 工具版本要求

- golang 1.23 以上
- clang 10.0 以上
- llvm 10.0 以上

## 编译环境依赖安装
### Ubuntu
如果你使用的是ubuntu 22.04以及更新版本,可以使用一条命令即可完成编译环境的初始化。
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/hengyoush/kyanos/master/init_env.sh)"
```
### 其他 Linux 发行版
编译环境除了上面工具链版本列出的软件外,还需要以下软件,请自行安装。

- linux-tools-common
- linux-tools-generic
- pkgconf
- libelf-dev

### 如果你的内核没开启BTF
如果没有开启BTF,那么虽然可能成功编译,但你可能无法成功启动 kyanos.

检查是否开启BTF:
```
grep CONFIG_DEBUG_INFO_BTF "/boot/config-$(uname -r)"
```
如果结果是`CONFIG_DEBUG_INFO_BTF=y`说明开启了,如果没开启请到 [mirrors.openanolis.cn](https://mirrors.openanolis.cn/coolbpf/btf/) or [btfhub-archive](https://github.com/aquasecurity/btfhub-archive/)上下载,然后启动 kyanos 时使用 `--btf` 选项指定下载的 btf 文件。


## 编译命令
执行
```
make build-bpf && make
```

之后在项目根目录下会生成 kyanos 可执行文件。
44 changes: 44 additions & 0 deletions docs/how-to-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
next:
prev: false
---
# Compilation Steps

This document describes the local compilation method for kyanos. My environment is Ubuntu 22.04, and other environments may vary.

## Tool Version Requirements

- golang 1.23 or above
- clang 10.0 or above
- llvm 10.0 or above

## Installation of Compilation Environment Dependencies
### Ubuntu
If you are using Ubuntu 22.04 or later, you can initialize the compilation environment with a single command.
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/hengyoush/kyanos/master/init_env.sh)"
```
### Other Linux Distributions
In addition to the toolchain versions listed above, the compilation environment also requires the following software. Please install them manually.

- linux-tools-common
- linux-tools-generic
- pkgconf
- libelf-dev

### If Your Kernel Does Not Enable BTF
If BTF is not enabled, you may not be able to start kyanos successfully.

Check if BTF is enabled:
```
grep CONFIG_DEBUG_INFO_BTF "/boot/config-$(uname -r)"
```
If the result is `CONFIG_DEBUG_INFO_BTF=y`, it means BTF is enabled. If not, please download from [mirrors.openanolis.cn](https://mirrors.openanolis.cn/coolbpf/btf/) or [btfhub-archive](https://github.com/aquasecurity/btfhub-archive/), and use the `--btf` option to specify the downloaded BTF file when starting kyanos.

## Compilation Command
Execute
```
make build-bpf && make
```

Afterwards, the kyanos executable will be generated in the root directory of the project.

0 comments on commit f84cc67

Please sign in to comment.