[cfe-dev] llvm failing to find it's own headers

blubee blubeeme via cfe-dev cfe-dev at lists.llvm.org
Sat Sep 16 11:51:48 PDT 2017


I have this simple test program:
#include <stdio.h>
#include <clang/AST/AST.h>
#include <clang-c/Index.h>

int main(){
        printf("this is a test\n");
        return 0;
}

when I try to compile it with clang++
clang++ -I/usr/local/llvm40/include test.cpp
In file included from test.cpp:9:
In file included from /usr/local/llvm40/include/clang/AST/AST.h:18:
In file included from /usr/local/llvm40/include/clang/AST/ASTContext.h:18:
In file included from
/usr/local/llvm40/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/llvm40/include/clang/AST/Decl.h:17:
In file included from /usr/local/llvm40/include/clang/AST/APValue.h:17:
In file included from /usr/local/llvm40/include/clang/Basic/LLVM.h:25:
/usr/local/llvm40/include/llvm/ADT/None.h:22:6: warning: scoped
      enumerations are a C++11 extension [-Wc++11-extensions]
enum class NoneType { None };
     ^
In file included from test.cpp:9:
In file included from /usr/local/llvm40/include/clang/AST/AST.h:18:
In file included from /usr/local/llvm40/include/clang/AST/ASTContext.h:18:
In file included from
/usr/local/llvm40/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/llvm40/include/clang/AST/Decl.h:17:
In file included from /usr/local/llvm40/include/clang/AST/APValue.h:18:
In file included from /usr/local/llvm40/include/llvm/ADT/APFloat.h:20:
In file included from /usr/local/llvm40/include/llvm/ADT/APInt.h:20:
/usr/local/llvm40/include/llvm/Support/MathExtras.h:248:1: error:
      unknown type name 'constexpr'
constexpr inline uint32_t Hi_32(uint64_t Value) {
^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:248:11: error:
      expected unqualified-id
constexpr inline uint32_t Hi_32(uint64_t Value) {
          ^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:253:1: error:
      unknown type name 'constexpr'
constexpr inline uint32_t Lo_32(uint64_t Value) {
^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:253:11: error:
      expected unqualified-id
constexpr inline uint32_t Lo_32(uint64_t Value) {
          ^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:259:1: error:
      unknown type name 'constexpr'
constexpr inline uint64_t Make_64(uint32_t High, uint32_t Low) {
^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:259:11: error:
      expected unqualified-id
constexpr inline uint64_t Make_64(uint32_t High, uint32_t Low) {
          ^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:264:23: error:
      unknown type name 'constexpr'
template <unsigned N> constexpr inline bool isInt(int64_t x) {
                      ^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:264:33: error:
      expected unqualified-id
template <unsigned N> constexpr inline bool isInt(int64_t x) {
                                ^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:702:10: error: use of
      undeclared identifier 'alignTo'
  return alignTo(Value, Align) - Value;
         ^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:707:23: error:
      unknown type name 'constexpr'
template <unsigned B> constexpr inline int32_t SignExtend32(uint32_t X) {
                      ^
/usr/local/llvm40/include/llvm/Support/MathExtras.h:707:33: error:
      expected unqualified-id
template <unsigned B> constexpr inline int32_t SignExtend32(uint32_t X) {
                                ^
In file included from test.cpp:9:
In file included from /usr/local/llvm40/include/clang/AST/AST.h:18:
In file included from /usr/local/llvm40/include/clang/AST/ASTContext.h:18:
In file included from
/usr/local/llvm40/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/llvm40/include/clang/AST/Decl.h:17:
In file included from /usr/local/llvm40/include/clang/AST/APValue.h:18:
In file included from /usr/local/llvm40/include/llvm/ADT/APFloat.h:20:
/usr/local/llvm40/include/llvm/ADT/APInt.h:291:15: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  APInt(APInt &&that) : BitWidth(that.BitWidth), VAL(that.VAL) {
              ^
/usr/local/llvm40/include/llvm/ADT/APInt.h:661:26: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  APInt &operator=(APInt &&that) {
                         ^
/usr/local/llvm40/include/llvm/ADT/APInt.h:393:14: error: use of
      undeclared identifier 'isPowerOf2_64'
      return isPowerOf2_64(VAL);
             ^
/usr/local/llvm40/include/llvm/ADT/APInt.h:1387:20: error: no member
      named 'countTrailingOnes' in namespace 'llvm'; did you mean
      'countTrailingZeros'?
      return llvm::countTrailingOnes(VAL);
             ~~~~~~^~~~~~~~~~~~~~~~~
                   countTrailingZeros
/usr/local/llvm40/include/llvm/Support/MathExtras.h:111:13: note:
      'countTrailingZeros' declared here
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
            ^
In file included from test.cpp:9:
In file included from /usr/local/llvm40/include/clang/AST/AST.h:18:
In file included from /usr/local/llvm40/include/clang/AST/ASTContext.h:18:
In file included from
/usr/local/llvm40/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/llvm40/include/clang/AST/Decl.h:17:
In file included from /usr/local/llvm40/include/clang/AST/APValue.h:18:
In file included from /usr/local/llvm40/include/llvm/ADT/APFloat.h:20:
/usr/local/llvm40/include/llvm/ADT/APInt.h:1399:20: error: no member
      named 'countPopulation' in namespace 'llvm'
      return llvm::countPopulation(VAL);
             ~~~~~~^
/usr/local/llvm40/include/llvm/ADT/APInt.h:1742:46: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
inline APInt operator+(const APInt &a, APInt &&b) {
                                             ^
/usr/local/llvm40/include/llvm/ADT/APInt.h:1762:46: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
inline APInt operator-(const APInt &a, APInt &&b) {
                                             ^
In file included from test.cpp:9:
In file included from /usr/local/llvm40/include/clang/AST/AST.h:18:
In file included from /usr/local/llvm40/include/clang/AST/ASTContext.h:18:
In file included from
/usr/local/llvm40/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/llvm40/include/clang/AST/Decl.h:17:
In file included from /usr/local/llvm40/include/clang/AST/APValue.h:18:
/usr/local/llvm40/include/llvm/ADT/APFloat.h:213:17: warning: 'final'
      keyword is a C++11 extension [-Wc++11-extensions]
class IEEEFloat final : public APFloatBase {
                ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:225:23: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  IEEEFloat(IEEEFloat &&);
                      ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:330:46: warning: deleted
      function definitions are a C++11 extension [-Wc++11-extensions]
  bool operator==(const IEEEFloat &) const = delete;
                                             ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:408:34: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  IEEEFloat &operator=(IEEEFloat &&);
                                 ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:600:21: warning: 'final'
      keyword is a C++11 extension [-Wc++11-extensions]
class DoubleAPFloat final : public APFloatBase {
                    ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:616:48: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  DoubleAPFloat(const fltSemantics &S, APFloat &&First, APFloat &...
                                               ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:616:65: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  ...fltSemantics &S, APFloat &&First, APFloat &&Second);
                                               ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:618:31: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  DoubleAPFloat(DoubleAPFloat &&RHS);
                              ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:622:42: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  DoubleAPFloat &operator=(DoubleAPFloat &&RHS) {
                                         ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:661:15: error: union member
      'IEEE' has a non-trivial copy constructor
    IEEEFloat IEEE;
              ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:224:3: note: because type
      'llvm::detail::IEEEFloat' has a user-provided copy constructor
  IEEEFloat(const IEEEFloat &);
  ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:662:19: error: union member
      'Double' has a non-trivial copy constructor
    DoubleAPFloat Double;
                  ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:617:3: note: because type
      'llvm::detail::DoubleAPFloat' has a user-provided copy constructor
  DoubleAPFloat(const DoubleAPFloat &RHS);
  ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:670:23: warning: variadic
      templates are a C++11 extension [-Wc++11-extensions]
    template <typename... ArgTypes>
                      ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:671:53: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
    Storage(const fltSemantics &Semantics, ArgTypes &&... Args) {
                                                    ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:707:21: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
    Storage(Storage &&RHS) {
                    ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:733:32: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
    Storage &operator=(Storage &&RHS) {
                               ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:750:35: error: too many
      arguments provided to function-like macro invocation
                  std::is_same<T, DoubleAPFloat>::value, "");
                                  ^
/usr/include/c++/v1/__config:727:12: note: macro 'static_assert' defined
      here
#   define static_assert(__b, __m) _Static_assert(__b, __m)
           ^
In file included from test.cpp:9:
In file included from /usr/local/llvm40/include/clang/AST/AST.h:18:
In file included from /usr/local/llvm40/include/clang/AST/ASTContext.h:18:
In file included from
/usr/local/llvm40/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/llvm40/include/clang/AST/Decl.h:17:
In file included from /usr/local/llvm40/include/clang/AST/APValue.h:18:
/usr/local/llvm40/include/llvm/ADT/APFloat.h:825:33: warning: defaulted
      function definitions are a C++11 extension [-Wc++11-extensions]
  APFloat(const APFloat &RHS) = default;
                                ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:826:19: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  APFloat(APFloat &&RHS) = default;
                  ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:826:28: warning: defaulted
      function definitions are a C++11 extension [-Wc++11-extensions]
  APFloat(APFloat &&RHS) = default;
                           ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:828:16: warning: defaulted
      function definitions are a C++11 extension [-Wc++11-extensions]
  ~APFloat() = default;
               ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:1016:44: warning: deleted
      function definitions are a C++11 extension [-Wc++11-extensions]
  bool operator==(const APFloat &) const = delete;
                                           ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:1052:44: warning: defaulted
      function definitions are a C++11 extension [-Wc++11-extensions]
  APFloat &operator=(const APFloat &RHS) = default;
                                           ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:1053:30: warning: rvalue
      references are a C++11 extension [-Wc++11-extensions]
  APFloat &operator=(APFloat &&RHS) = default;
                             ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:1053:39: warning: defaulted
      function definitions are a C++11 extension [-Wc++11-extensions]
  APFloat &operator=(APFloat &&RHS) = default;
                                      ^
/usr/local/llvm40/include/llvm/ADT/APFloat.h:1078:10: warning:
      unelaborated friend declaration is a C++11 extension; specify
      'class' to befriend 'IEEEFloat' (aka 'llvm::detail::IEEEFloat')
      [-Wc++11-extensions]
  friend IEEEFloat;
         ^
         class
/usr/local/llvm40/include/llvm/ADT/APFloat.h:1079:10: warning:
      unelaborated friend declaration is a C++11 extension; specify
      'class' to befriend 'DoubleAPFloat' (aka
      'llvm::detail::DoubleAPFloat') [-Wc++11-extensions]
  friend DoubleAPFloat;
         ^
         class
/usr/local/llvm40/include/llvm/ADT/APFloat.h:749:5: error: use of
      undeclared identifier 'static_assert'
    static_assert(std::is_same<T, IEEEFloat>::value ||
    ^
In file included from test.cpp:9:
In file included from /usr/local/llvm40/include/clang/AST/AST.h:18:
In file included from /usr/local/llvm40/include/clang/AST/ASTContext.h:18:
In file included from
/usr/local/llvm40/include/clang/AST/ASTTypeTraits.h:20:
In file included from /usr/local/llvm40/include/clang/AST/Decl.h:17:
In file included from /usr/local/llvm40/include/clang/AST/APValue.h:20:
In file included from
/usr/local/llvm40/include/llvm/ADT/PointerIntPair.h:18:
/usr/local/llvm40/include/llvm/Support/PointerLikeTypeTraits.h:45:61:
error:
      'T' does not refer to a value
  enum { NumLowBitsAvailable = detail::ConstantLog2<alignof(T)>::value };
                                                            ^
/usr/local/llvm40/include/llvm/Support/PointerLikeTypeTraits.h:40:20: note:
      declared here
template <typename T> class PointerLikeTypeTraits<T *> {
                   ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
28 warnings and 20 errors generated.

then I try with verbose output along with -std=c++11

clang -v -std=c++11 test.cpp
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM
4.0.0)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang" -cc1 -triple x86_64-unknown-freebsd12.0 -emit-obj
-mrelax-all -disable-free -main-file-name test.cpp -mrelocation-model
static -mthread-model posix -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -v
-dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/bin/../lib/clang/4.0.0 -I/usr/local/include
-I/usr/local/llvm40/include -c-isystem -I/usr/local/llvm40/include
-cxx-isystem -I/usr/local/llvm40/include -internal-isystem
/usr/include/c++/v1 -std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/home/blubee -ferror-limit 19 -fmessage-length 102 -fobjc-runtime=gnustep
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
-o /tmp/test-10b94f.o -x c++ test.cpp
clang -cc1 version 4.0.0 based upon LLVM 4.0.0 default target
x86_64-unknown-freebsd12.0
ignoring nonexistent directory "-I/usr/local/llvm40/include"
ignoring nonexistent directory "-I/usr/local/llvm40/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/llvm40/include
 /usr/include/c++/v1
 /usr/bin/../lib/clang/4.0.0/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1
--hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o
/usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/test-10b94f.o -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
/tmp/test-10b94f.o:(.data+0x0): undefined reference to
`llvm::DisableABIBreakingChecks'
clang: error: linker command failed with exit code 1 (use -v to see
invocation)

still getting a linker error, am I overlooking something simple? What's
going on?

Best
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170917/8bfc918b/attachment.html>


More information about the cfe-dev mailing list