Skip to content

gn 主机编译失败:edit_subcommands.cc 中 lambda 无法转换为 Result<ParseNodeGenerator> #2046

Description

@qq761861

问题描述

在编译 LEDE/OpenWrt 时,feeds/helloworld/gn 在主机编译阶段失败,导致整个固件编译中止。

其他软件包,例如 chinadns-ng、kcptun 和 mosdns 均已正常完成编译,问题出现在 gn 的 host 编译阶段。

编译环境
Target:aarch64_generic
libc:musl
Target root:root-rockchip
GN 版本目录:
gn-2026-09-02-356ee8a8
编译器:clang++
C++ 标准:C++23

错误信息

编译 src/gn/edit_subcommands.cc 时失败:

[1/212] CXX src/gn/edit_subcommands.o
FAILED: src/gn/edit_subcommands.o

../src/gn/edit_subcommands.cc:73:12: error:
no viable conversion from returned value of type
'(lambda at ../src/gn/edit_subcommands.cc:73:12)'
to function return type
'Result'
(aka 'Result<function<Result<std::unique_ptr> (BuildFile &)>>')

随后第 78 行和第 84 行出现相同错误。

第 73 行代码涉及:

return [expr_string = std::move(expr_string)](BuildFile& build_file) {
return build_file.parse_expression(expr_string);
};

第 78 行和第 84 行也是返回 lambda,并尝试转换为 Result。

编译器同时指出 Result 提供了以下构造函数:

Result(const T& value)
Result(T&& value)
Result(Err err)

但当前 lambda 无法转换为目标类型 Result。

完整错误结尾
3 errors generated. ninja: build stopped: subcommand failed. make[3]: *** [Makefile:59: .../gn/.built] Error 1 ERROR: package/feeds/helloworld/gn [host] failed to build. make[2]: *** [package/Makefile:169: package/feeds/helloworld/gn/host/compile] Error 1 make[1]: *** [package/Makefile:165: .../.package_compile] Error 2 make: *** [include/toplevel.mk:231: world] Error 2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions