【问题标题】:Linker error building with llvm使用 llvm 构建链接器错误
【发布时间】:2015-02-26 05:12:49
【问题描述】:

我正在尝试构建Kint。我收到链接错误,我无法找出原因。这是源文件:

#pragma once

#include <llvm/Support/Debug.h>
#include <llvm/Support/ConstantRange.h>

// llvm::ConstantRange fixup.
class CRange : public llvm::ConstantRange {
    typedef llvm::APInt APInt;
    typedef llvm::ConstantRange super;
public:
    CRange(uint32_t BitWidth, bool isFullSet) : super(BitWidth, isFullSet) {}
    // Constructors.
    CRange(const super &CR) : super(CR) {}
    CRange(const APInt &Value)
        : super(Value) {}
    CRange(const APInt &Lower, const APInt &Upper)
        : super(Lower, Upper) {}
    static CRange makeFullSet(uint32_t BitWidth) {
        return CRange(BitWidth, true);
    }
    static CRange makeEmptySet(uint32_t BitWidth) {
        return CRange(BitWidth, false);
    }
    static CRange makeICmpRegion(unsigned Pred, const CRange &other) {
        return super::makeICmpRegion(Pred, other);
    }

    void match(const CRange &R) {
        if (this->getBitWidth() != R.getBitWidth()) {
            llvm::dbgs() << "warning: range " << *this << " " 
                << this->getBitWidth() << " and " << R << " "
                << R.getBitWidth() << " unmatch\n";
            *this = this->zextOrTrunc(R.getBitWidth());
        }
    }

    bool safeUnion(const CRange &R) {
        CRange V = R, Old = *this;
        V.match(*this);
        *this = this->unionWith(V);
        return Old != *this;
    }


    CRange sdiv(const CRange &RHS) const {
        if (isEmptySet() || RHS.isEmptySet())
            return makeEmptySet(getBitWidth());
        // FIXME: too conservative.
        return makeFullSet(getBitWidth());
    }

};

这是错误信息:

/home/riyad/src/kint-updated/kint/build/src/../../src/CRange.h:32: undefined reference to `llvm::ConstantRange::ConstantRange(llvm::APInt const&)'
/home/riyad/src/kint-updated/kint/build/src/../../src/CRange.h:32: undefined reference to `llvm::ConstantRange::ConstantRange(llvm::APInt const&)'
/home/riyad/src/kint-updated/kint/build/src/../../src/CRange.h:32: undefined reference to `llvm::ConstantRange::ConstantRange(llvm::APInt const&)'
/home/riyad/src/kint-updated/kint/build/src/../../src/CRange.h:32: undefined reference to `llvm::ConstantRange::ConstantRange(llvm::APInt const&)'
/home/riyad/src/kint-updated/kint/build/src/../../src/CRange.h:32: undefined reference to `llvm::ConstantRange::ConstantRange(llvm::APInt const&)'

但是 llvm::ConstantRange::ConstantRange(llvm::APInt const&amp;) 已经在 llvm 中定义了。这是llvm中ConstantRange.h的源代码。

#if LLVM_HAS_RVALUE_REFERENCES
  // If we have move semantics, pass APInts by value and move them into place.
  typedef APInt APIntMoveTy;
#else
  // Otherwise pass by const ref to save one copy.
  typedef const APInt &APIntMoveTy;
#endif

public:
  /// Initialize a full (the default) or empty set for the specified bit width.
  ///
  explicit ConstantRange(uint32_t BitWidth, bool isFullSet = true);

  /// Initialize a range to hold the single specified value.
  ///
  ConstantRange(APIntMoveTy Value);

  /// @brief Initialize a range of values explicitly. This will assert out if
  /// Lower==Upper and Lower != Min or Max value for its type. It will also
  /// assert out if the two APInt's are not the same bit width.
  ConstantRange(APIntMoveTy Lower, APIntMoveTy Upper);

我尝试过同时使用 llvm 3.4 和 llvm 3.5。我正在使用 gcc 4.8.2。我找不到任何无法构建的原因?

【问题讨论】:

    标签: c++ llvm linker-errors


    【解决方案1】:

    我猜你的代码和 llvm 代码是用未定义/定义的 LLVM_HAS_RVALUE_REFERENCES 值编译的

    尝试在你的代码中定义 LLVM_HAS_RVALUE_REFERENCES

    基本上,你要求(T const&amp;),但llvm有(T)的方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 2012-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多