Skip to content

Commit

Permalink
add dynamic libs to glibc check (#322)
Browse files Browse the repository at this point in the history
* add glibc check

* fix version script

* print all bad symbols

* add libPluginAdapter.so and libPluginBase.so to glibc checklist
  • Loading branch information
yyuuttaaoo authored Aug 17, 2022
1 parent ab6a3c1 commit d30b0d3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/cn/developer-guide/code-check/check-codestyle.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# 检查代码规范

## 检查Go代码规范

LogtailPlugin 使用 [golangci-lint](https://golangci-lint.run/) 检查代码风格。 `SCOPE` 定义是
可选,默认范围是根目录。

```makefile
SCOPE=xxx make lint
```
xxx为限定的目录名称。

xxx为限定的目录名称。
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ iLogtail 基于Apache 2.0 协议进行开源,开发者需要保证依赖包协
## 检查依赖包License

开发者可以使用以下命令进行依赖包License 扫描。

```makefile
make check-dependency-licenses
```

- 当提示 `DEPENDENCIES CHECKING IS PASSED` 时,说明依赖包检查通过。
- 当提示 `FOLLOWING DEPENDENCIES SHOULD BE ADDED to LICENSE_OF_ILOGTAIL_DEPENDENCIES.md` 时,说明依赖包将需要被添加(需要保证协议与Apache 2.0 协议兼容),可以查看 `find_licenses/LICENSE-{liencese type}`文件查看待添加依赖包协议。
- 当提示 `FOLLOWING DEPENDENCIES IN LICENSE_OF_ILOGTAIL_DEPENDENCIES.md SHOULD BE REMOVED` 时,说明存在多余的依赖包,按提示进行删除即可。
- 当提示 `FOLLOWING DEPENDENCIES IN LICENSE_OF_ILOGTAIL_DEPENDENCIES.md SHOULD BE REMOVED` 时,说明存在多余的依赖包,按提示进行删除即可。
7 changes: 6 additions & 1 deletion docs/cn/developer-guide/code-check/check-license.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ LogtailPlugin 遵循标准的 Apache 2.0 许可,所有文件必须具有许可
```makefile
SCOPE=xxx make check-license
```

xxx为限定的目录名称。

## 添加许可证

当某些带有许可证的文件建立后,您可以通过以下方式将许可证添加到文件中。 请注意,这种方式将修复所有缺少许可证的文件。

```makefile
make license
```

同上,如果你想限制变化范围,请在命令中附加`SCOPE`

```makefile
SCOPE=xxx make license
```
xxx为限定的目录名称。

xxx为限定的目录名称。
3 changes: 2 additions & 1 deletion docs/cn/developer-guide/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
虽然[源代码编译](docs/cn/installation/sources/build.md)已经提供了方便的iLogtail编译方法,但却不适合开发场景。因为开发过程中需要不断进行编译调试,重复全量编译的速度太慢,因此需要构建支持增量编译开发环境。

## 进程结构

iLogtail为了支持插件系统,引入了 libPluginAdaptor 和 libPluginBase(以下简称 adaptor 和 base)这两个动态库,它们与 iLogtail 之间的关系如下:<br />
iLogtail 动态依赖于这两个动态库(即 binary 中不依赖),在初始化时,iLogtail 会尝试使用动态库接口(如 dlopen)动态加载它们,获取所需的符号。<br />
Adaptor 充当一个中间层,iLogtail 和 base 均依赖它,iLogtail 向 adaptor 注册回调,adpator 将这些回调记录下来以接口的形式暴露给 base 使用。<br />
Expand Down Expand Up @@ -133,7 +134,6 @@ make -sj$(nproc) # 每次更新core代码后从这里开始

![image.png](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/images/developer-guide/development-environment/c%2B%2B-compiling.png)<br />![image.png](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/images/developer-guide/development-environment/c%2B%2B-compile-result.png)


如果只是对core代码进行了修改,则只需要执行最后一行命令即可增量编译。

默认的编译选项代码可能被优化,若需要Debug建议修改CMAKE_BUILD_TYPE开关。替换上述第2行为
Expand Down Expand Up @@ -207,6 +207,7 @@ docker exec -it ilogtail-build bash
### 1. 修改官方镜像entrypoint

基于官方镜像包进行调试,首先用bash覆盖官方镜像的entrypoint,避免杀死ilogtail后容器直接退出。

- docker:指定CMD

```bash
Expand Down
2 changes: 2 additions & 0 deletions docs/cn/installation/sources/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ VERSION=1.1.1 make dist
└── libPluginBase.so (插件lib)
```

开发环境增量编译的方法请参考[开发环境](../../developer-guide/development-environment.md)

## Go插件本地编译

Go插件可以在主机上进行直接编译,编译前,需要安装基础的 Go 1.16+
Expand Down
8 changes: 7 additions & 1 deletion scripts/check_glibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ set -o pipefail
OUT_DIR=${1:-output}
ROOTDIR=$(cd $(dirname "${BASH_SOURCE[0]}") && cd .. && pwd)
BIN="${ROOTDIR}/${OUT_DIR}/ilogtail"
ADAPTER="${ROOTDIR}/${OUT_DIR}/libPluginAdapter.so"
PLUGIN="${ROOTDIR}/${OUT_DIR}/libPluginBase.so"

# check if the symbols in ilogtail are compatible with GLIBC_2.5
awk_script=$(cat <<- EOF
Expand Down Expand Up @@ -49,4 +51,8 @@ END {
}
EOF
)
objdump -T "$BIN" | awk "$awk_script"
all=("$BIN" "$ADAPTER" "$PLUGIN")
for obj in "${all[@]}"; do
echo "Checking symbols in $obj ..."
objdump -T "$obj" | awk "$awk_script"
done

0 comments on commit d30b0d3

Please sign in to comment.