跳到正文
cccskills
免费在 GitHub 公开

compile

编译 LoongCollector C++ 与 Go 组件。涉及构建、单元测试或镜像时使用。

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md4.7 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

LoongCollector 编译指南

与 CI(make core / scripts/run_core_ut.sh) 和 E2E 镜像(make e2edocker) 对齐;仅引用仓库内已有脚本与 Makefile target。

快速选择

目标命令
C++ 主程序 + UT(CI 同款)make core PATH_IN_DOCKER=$(pwd)
跑 C++ UT./scripts/run_core_ut.sh
Go 插件(本机)make plugin_local
Go 插件(CI 风格)make plugin_main
E2E 运行时镜像make e2edocker → aliyun/loongcollector:0.0.1
发布镜像make image
ARM64 交叉编译make image ARCH=arm64
本机 CMake 增量编译见下文「本机 CMake(build/)」

前置条件

git submodule update --init --recursive

两个子模块位于 core/_thirdparty/:

  • DCGM — NVIDIA DCGM 头文件
  • coolbpf — eBPF 框架

子模块目录为空会导致 No such file or directory 编译错误。CI 还会单独初始化 coolbpf 子模块。

C++:CI 方式(推荐用于验证 PR)

在仓库根目录执行(会 docker build 构建镜像并 docker cp 产物到 core/build):

export MAKE_JOBS=16
export BUILD_LOGTAIL=OFF BUILD_LOGTAIL_UT=ON
export WITHSPL=ON BUILD_TYPE=Debug ENABLE_AGENTSIGHT=ON
make core PATH_IN_DOCKER=$(pwd)

跑单元测试:

./scripts/run_core_ut.sh
# 单个用例示例:
./scripts/run_core_ut.sh --gtest_filter=CollectionConfigUnittest.* unittest/config/collection_config_unittest

说明:每次 make core 会重建构建镜像,较慢;适合与 CI 对齐的最终验证,不适合高频迭代。

C++:本机 CMake(build/)

重要:所有 CMake 和 make 命令必须在 build/ 目录内执行。

  1. 若已有 build/ 目录且修改未涉及 CMake 文件,可直接增量编译(跳到第 4 步)。
  2. 创建并进入编译目录:
mkdir -p build && cd build
  1. 构建 CMake 命令:
cmake -DCMAKE_BUILD_TYPE=Debug -DLOGTAIL_VERSION=0.0.1 \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
      -DCMAKE_CXX_FLAGS="-I/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/include -I/opt/logtail -I/opt/logtail_spl" \
      -DBUILD_LOGTAIL=ON -DBUILD_LOGTAIL_UT=ON -DWITHOUTGDB=ON \
      -DENABLE_STATIC_LINK_CRT=ON -DWITHSPL=OFF ../core
CMake 选项用途
BUILD_LOGTAIL编译 loongcollector 主程序
BUILD_LOGTAIL_UT编译单元测试
WITHSPLSPL 支持;非 SPL 改动设为 OFF 可加快编译
  1. 编译:
make -sj$(nproc)

编译指定测试(在 build/ 目录内):

make yaml_util_unittest app_config_unittest safe_queue_unittest -j$(nproc)

运行测试(在 build/ 目录内):

./unittest/common/yaml_util_unittest
./unittest/app_config/app_config_unittest

测试必须在 build/ 目录内运行,部分测试依赖相对路径加载配置文件。

C++:本机 CMake(core/build/,可选)

需本机已安装与 docker/Dockerfile_build 兼容的工具链(如 devtoolset-9)。在 core/build 目录内执行:

mkdir -p core/build && cd core/build
cmake -DCMAKE_BUILD_TYPE=Debug -DLOGTAIL_VERSION=0.0.1 \
      -DBUILD_LOGTAIL=ON -DBUILD_LOGTAIL_UT=ON -DWITHOUTGDB=ON \
      -DENABLE_STATIC_LINK_CRT=ON -DWITHSPL=ON ..
make -sj$(nproc)

产物示例:core/build/loongcollector、core/build/unittest/.../*_unittest。

Go 插件

make plugin_local    # 输出到 output/libGoPluginBase.so,本机 c-shared
make plugin_main     # CI / 发布风格

修改 Go 插件后跑 E2E:需同步进 aliyun/loongcollector:0.0.1 镜像(见 e2e skill §4.1 增量更新)。

E2E 镜像

make e2edocker

生成 aliyun/loongcollector:0.0.1,与 .github/workflows/e2e.yaml 中 GenerateE2ETestImage 用途一致(CI 使用 docker/Dockerfile_edge_linux 构建)。

Native → Go 桥接(PPEG)

批量数据仅走 ProcessPipelineEventGroup(PipelineEventGroup PB)。已移除 ProcessLogGroup / ProcessLog export;v1 插件 runner 在 Go 侧将 Log 转为 LogGroup 后 ReceiveLogGroup。

常见问题

  • CMake 选项变更:删除 build/ 或 core/build/ 后重新 cmake。
  • 缺少依赖:通过 apt 或 yum 安装。
  • UT 链接失败:在 build/ 或 core/build 下编译;用 run_core_ut.sh 设置 LD_LIBRARY_PATH。
  • 需要 SPL 功能:将 WITHSPL=OFF 改为 WITHSPL=ON。
  • E2E 镜像过旧:C++/Go 变更后执行 make e2edocker 或手动 docker commit 更新镜像内二进制与 libGoPluginBase.so。

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

在进行 Code Review 时,使用这个技能对 LoongCollector 变更进行安全导向、架构一致性优先的深度代码评审。

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月16日 更新

commit

免费

按 Conventional Commits 规范编写提交信息。在创建 git commit 时使用。

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月16日 更新

Design document writing conventions. Use when writing or reviewing technical design documents.

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月16日 更新

e2e

免费

LoongCollector E2E 测试全流程指南:设计、编写、运行和调试。当需要编写新 E2E 测试、运行现有测试、或排查 E2E 测试失败时使用此 skill。

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月16日 更新

LoongCollector E2E Testing Framework Development Guide. Use this rule when you need to understand E2E testing framework architecture, develop new test behavior functions, or extend testing capabilities. Contains detailed BDD testing framework usage, test behavior function development and registration workflows, and comprehensive reference of existing testing capabilities. Example: When adding custom test behaviors for new plugins, use this rule to understand how to write and register new test functions. Example: When developing E2E tests, use this rule to understand the e2e framework.

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月16日 更新

E2E Testing Standards Guide. Use this rule when you need to write or execute E2E tests, including test naming conventions, test workflows, and test behavior templates. This rule should be used for end-to-end integration testing scenarios to ensure test standardization and maintainability. Example: When writing new E2E tests, use this rule to ensure proper test format and workflow compliance.

中文简介正在准备中。当前显示原文说明。

alibaba/loongcollector22072026年10月16日 更新

查看 alibaba 的全部技能

报告此技能的问题