本文へ移動
cccskills
無料GitHub で公開

compile

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

インストール方法を見る

含まれるファイル(1)

  • SKILL.md4.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

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。

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

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

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

commit

無料

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

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

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

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

e2e

無料

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

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

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/loongcollector2,2042026年10月9日 更新

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/loongcollector2,2042026年10月9日 更新

alibaba のスキルをすべて見る

このスキルの問題を報告する