Clang error: Cannot compile builtin function yet

Clang error: Cannot compile builtin function yet

我正在编译 linux 内核代码,其中还包含带有 clang 的 gcc 库(单独添加)。我遇到以下错误:

gcc/unwind-dw2.c:1336:3: error: cannot compile this __builtin_init_dwarf_reg_size_table yet 

'__builtin_init_dwarf_reg_size_table' 是 gcc 中的内置函数。我在网上找不到足够的 material 来解决这个错误。但是我在 clang 中找到了对这个函数的引用:

BUILTIN(__builtin_init_dwarf_reg_size_table, "vv*", "n")

位置 prebuilt_include/clang/include/clang/Basic/Builtins.def。但是我不明白它的用途是什么

任何有关该错误的提醒都会很有帮助。

编辑:在环顾四周以了解 clang 的工作原理时,我在函数 'EmitBuiltinExpr' 的 CGBuiltin.cpp 文件中找到了另一个对此内置函数的引用。但无法理解如何使用它来解决我的问题。有什么好的资料可以理解这一切吗?

Clang 代码表明,错误 cannot compile this <something> yet 意味着 <something> 是目标体系结构上 Clang 不支持的构造。

在这种情况下,init_dwarf_reg_size_table 是一个 GCC 内置函数,并非所有 Clang 目标都完全支持它。检查 GCC 的 builtins.def 可以确认 init_dwarf_reg_size_table 是一个 GCC 扩展。

作为一种变通方法,您可能必须改用 GCC 进行编译,或者使用支持此内置函数(如果有)的更新的 clang 版本进行编译。


在 clang 代码之后,cannot compile this <something> yet 消息由 CodeGenModule.cpp 中的 ErrorUnsupported 函数打印:

/// ErrorUnsupported - Print out an error that codegen doesn't support the
/// specified stmt yet.
void CodeGenModule::ErrorUnsupported(const Stmt *S, const char *Type) {
  unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
                                               "cannot compile this %0 yet");
  std::string Msg = Type;
  getDiags().Report(Context.getFullLoc(S->getLocStart()), DiagID)
    << Msg << S->getSourceRange();
}

CGBuiltin.cpp 中,如果 initDwarfEHRegSizeTable 目标挂钩失败,则扩展内置函数并调用 ErrorUnsupported

  case Builtin::BI__builtin_init_dwarf_reg_size_table: {
    Value *Address = EmitScalarExpr(E->getArg(0));
    if (getTargetHooks().initDwarfEHRegSizeTable(*this, Address))
      CGM.ErrorUnsupported(E, "__builtin_init_dwarf_reg_size_table");
    return RValue::get(llvm::UndefValue::get(ConvertType(E->getType())));
  }

initDwarfEHRegSizeTableTargetInfo.cpp 中定义。老实说,我还没有完全理解它在什么情况下会失败(这也取决于目标架构)。