用llvm构建链接器错误

时间:2014-12-30 01:56:24

标签: c++ llvm linker-errors

我正在尝试构建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中已经定义了llvm::ConstantRange::ConstantRange(llvm::APInt const&)。这是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。我找不到任何理由不建造这个?

1 个答案:

答案 0 :(得分:0)

我猜你的代码和llvm代码是使用未定义/定义的LLVM_HAS_RVALUE_REFERENCES

值编译的

尝试在代码中定义LLVM_HAS_RVALUE_REFERENCES

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