きつねさんより馬鹿だと自覚 LLVM/Clang++


きつねさん LLVM
https://researchmap.jp/jogxeqqfo-1797580/#_1797580

LLVMは、

$brew install --with-clang --with-lld --with-python --HEAD llvm

きつねさん LLVM
http://kazegusuri.hateblo.jp/entry/20121215/1355564422

「きつねさんでもわかるLLVM」用の練習リポジトリ
https://github.com/NKMR6194/DummyC

ダウンロード。

$ make
$ mkdir -p ./obj
$ clang++ -g ./src/dcc.cpp -I./inc `llvm-config --cxxflags --
 ldflags --libs` -c -o ./obj/dcc.o
/bin/sh: llvm-config: command not found
./src/dcc.cpp:1:10: fatal error: 'llvm/IR/IRPrintingPasses.h' file not found
#include "llvm/IR/IRPrintingPasses.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [obj/dcc.o] Error 1

え、見当たらないの?

$ ln -s /Users/administrator/llvm/include/llvm /Users/administrator/Downloads/DummyC-master/inc

$ make
$ mkdir -p ./obj
$ clang++ -g ./src/dcc.cpp -I./inc `llvm-config --cxxflags --ldflags --libs` -c -o ./obj/dcc.o
/bin/sh: llvm-config: command not found
In file included from ./src/dcc.cpp:1:
In file included from ./inc/./llvm/IR/IRPrintingPasses.h:22:
In file included from ./inc/llvm/ADT/StringRef.h:13:
In file included from ./inc/llvm/ADT/STLExtras.h:31:
In file included from ./inc/llvm/ADT/Optional.h:19:
./inc/llvm/ADT/None.h:23:6: warning: scoped enumerations are a C++11 extension
      [-Wc++11-extensions]
enum class NoneType { None = 1 };
     ^
./inc/llvm/ADT/None.h:24:23: warning: use of enumeration in a nested name
      specifier is a C++11 extension [-Wc++11-extensions]
const NoneType None = NoneType::None;
                      ^
In file included from ./src/dcc.cpp:1:
In file included from ./inc/./llvm/IR/IRPrintingPasses.h:22:
In file included from ./inc/llvm/ADT/StringRef.h:13:
In file included from ./inc/llvm/ADT/STLExtras.h:31:
In file included from ./inc/llvm/ADT/Optional.h:20:
In file included from ./inc/llvm/Support/AlignOf.h:17:
./inc/llvm/Support/Compiler.h:18:10: fatal error: 'llvm/Config/llvm-config.h'
      file not found
#include "llvm/Config/llvm-config.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings and 1 error generated.
make: *** [obj/dcc.o] Error 1

llvm/Config/llvm-config.h.cmake
がファイル名。


$ cd llvm/Config
$ cp llvm-config.h.cmake llvm-config.c
$ make
$ mkdir -p ./obj
$ clang++ -g ./src/dcc.cpp -I./inc `llvm-config --cxxflags --ldflags --libs` -c -o ./obj/dcc.o
/bin/sh: llvm-config: command not found
In file included from ./src/dcc.cpp:1:
In file included from ./inc/./llvm/IR/IRPrintingPasses.h:22:
In file included from ./inc/llvm/ADT/StringRef.h:13:
In file included from ./inc/llvm/ADT/STLExtras.h:31:
In file included from ./inc/llvm/ADT/Optional.h:19:
./inc/llvm/ADT/None.h:23:6: warning: scoped enumerations are a C++11 extension
      [-Wc++11-extensions]
enum class NoneType { None = 1 };
     ^
./inc/llvm/ADT/None.h:24:23: warning: use of enumeration in a nested name
      specifier is a C++11 extension [-Wc++11-extensions]
const NoneType None = NoneType::None;
                      ^
In file included from ./src/dcc.cpp:1:
In file included from ./inc/./llvm/IR/IRPrintingPasses.h:22:
In file included from ./inc/llvm/ADT/StringRef.h:13:
In file included from ./inc/llvm/ADT/STLExtras.h:31:
In file included from ./inc/llvm/ADT/Optional.h:20:
In file included from ./inc/llvm/Support/AlignOf.h:17:
In file included from ./inc/llvm/Support/Compiler.h:18:
./inc/llvm/Config/llvm-config.h:18:2: error: invalid preprocessing directive
#cmakedefine LINK_POLLY_INTO_TOOLS
 ^
./inc/llvm/Config/llvm-config.h:21:2: error: invalid preprocessing directive
#cmakedefine LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}"
 ^
./inc/llvm/Config/llvm-config.h:24:2: error: invalid preprocessing directive
#cmakedefine01 LLVM_ENABLE_THREADS
 ^
./inc/llvm/Config/llvm-config.h:27:2: error: invalid preprocessing directive
#cmakedefine01 LLVM_HAS_ATOMICS
 ^
./inc/llvm/Config/llvm-config.h:30:2: error: invalid preprocessing directive
#cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}"
 ^
./inc/llvm/Config/llvm-config.h:33:2: error: invalid preprocessing directive
#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
 ^
./inc/llvm/Config/llvm-config.h:36:2: error: invalid preprocessing directive
#cmakedefine LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser
 ^
./inc/llvm/Config/llvm-config.h:39:2: error: invalid preprocessing directive
#cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter
 ^
./inc/llvm/Config/llvm-config.h:42:2: error: invalid preprocessing directive
#cmakedefine LLVM_NATIVE_DISASSEMBLER LLVMInitialize${LLVM_NATIVE_ARCH}D...
 ^
./inc/llvm/Config/llvm-config.h:45:2: error: invalid preprocessing directive
#cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target
 ^
./inc/llvm/Config/llvm-config.h:48:2: error: invalid preprocessing directive
#cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo
 ^
./inc/llvm/Config/llvm-config.h:51:2: error: invalid preprocessing directive
#cmakedefine LLVM_NATIVE_TARGETMC LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC
 ^
./inc/llvm/Config/llvm-config.h:54:2: error: invalid preprocessing directive
#cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX}
 ^
./inc/llvm/Config/llvm-config.h:57:2: error: invalid preprocessing directive
#cmakedefine LLVM_ON_WIN32 ${LLVM_ON_WIN32}
 ^
./inc/llvm/Config/llvm-config.h:60:2: error: invalid preprocessing directive
#cmakedefine01 LLVM_USE_INTEL_JITEVENTS
 ^
./inc/llvm/Config/llvm-config.h:63:2: error: invalid preprocessing directive
#cmakedefine01 LLVM_USE_OPROFILE
 ^
In file included from ./src/dcc.cpp:1:
In file included from ./inc/./llvm/IR/IRPrintingPasses.h:22:
In file included from ./inc/llvm/ADT/StringRef.h:13:
In file included from ./inc/llvm/ADT/STLExtras.h:31:
In file included from ./inc/llvm/ADT/Optional.h:20:
./inc/llvm/Support/AlignOf.h:113:19: warning: deleted function definitions are a
      C++11 extension [-Wc++11-extensions]
  AlignerImpl() = delete;
                  ^
./inc/llvm/Support/AlignOf.h:140:59: error: expected '(' for function-style cast
      or type construction
                                      T6, T7, T8, T9, T10>),
                                      ~~~~~~~~~~~~~~~~~~~~^
./inc/llvm/Support/AlignOf.h:142:61: error: expected class name
                                     T6, T7, T8, T9, T10>)> {
                                                            ^
In file included from ./src/dcc.cpp:1:
In file included from ./inc/./llvm/IR/IRPrintingPasses.h:22:
In file included from ./inc/llvm/ADT/StringRef.h:13:
In file included from ./inc/llvm/ADT/STLExtras.h:31:
In file included from ./inc/llvm/ADT/Optional.h:22:
./inc/llvm/Support/type_traits.h:53:32: error: a space is required between
      consecutive right angle brackets (use '> >')
struct isPodLike<std::pair<T, U>> {
                               ^~
                               > >
./inc/llvm/Support/type_traits.h:65:23: warning: alias declarations are a C++11
      extension [-Wc++11-extensions]
  using UnderlyingT = typename std::remove_reference<T>::type;
                      ^
./inc/llvm/Support/type_traits.h:78:59: warning: alias declarations are a C++11
      extension [-Wc++11-extensions]
struct add_lvalue_reference_if_not_pointer { using type = T &; };
                                                          ^
./inc/llvm/Support/type_traits.h:83:16: warning: alias declarations are a C++11
      extension [-Wc++11-extensions]
  using type = T;
               ^
./inc/llvm/Support/type_traits.h:89:46: warning: alias declarations are a C++11
      extension [-Wc++11-extensions]
struct add_const_past_pointer { using type = const T; };
                                             ^
./inc/llvm/Support/type_traits.h:94:16: warning: alias declarations are a C++11
      extension [-Wc++11-extensions]
  using type = const typename std::remove_pointer<T>::type *;
               ^
./inc/llvm/Support/type_traits.h:99:16: warning: alias declarations are a C++11
      extension [-Wc++11-extensions]
  using type = const T &;
               ^
./inc/llvm/Support/type_traits.h:104:16: warning: alias declarations are a C++11
      extension [-Wc++11-extensions]
  using type = typename add_const_past_pointer<T>::type;
               ^
In file included from ./src/dcc.cpp:1:
In file included from ./inc/./llvm/IR/IRPrintingPasses.h:22:
In file included from ./inc/llvm/ADT/StringRef.h:13:
In file included from ./inc/llvm/ADT/STLExtras.h:31:
./inc/llvm/ADT/Optional.h:33:15: warning: in-class initialization of non-static
      data member is a C++11 extension [-Wc++11-extensions]
  bool hasVal = false;
              ^
./inc/llvm/ADT/Optional.h:36:22: warning: alias declarations are a C++11
      extension [-Wc++11-extensions]
  using value_type = T;
                     ^
./inc/llvm/ADT/Optional.h:50:14: warning: rvalue references are a C++11
      extension [-Wc++11-extensions]
  Optional(T &&y) : hasVal(true) {
             ^
./inc/llvm/ADT/Optional.h:54:24: warning: rvalue references are a C++11
      extension [-Wc++11-extensions]
  Optional(Optional<T> &&O) : hasVal(O) {
                       ^
./inc/llvm/ADT/Optional.h:65:25: warning: rvalue references are a C++11
      extension [-Wc++11-extensions]
  Optional &operator=(T &&y) {
                        ^
./inc/llvm/ADT/Optional.h:75:32: warning: rvalue references are a C++11
      extension [-Wc++11-extensions]
  Optional &operator=(Optional &&O) {
                               ^
./inc/llvm/ADT/Optional.h:86:21: warning: variadic templates are a C++11
      extension [-Wc++11-extensions]
  template<typename ...ArgTypes>
                    ^
./inc/llvm/ADT/Optional.h:87:25: warning: rvalue references are a C++11
      extension [-Wc++11-extensions]
  void emplace(ArgTypes &&...Args) {
                        ^
./inc/llvm/ADT/Optional.h:132:3: warning: explicit conversion functions are a
      C++11 extension [-Wc++11-extensions]
  explicit operator bool() const { return hasVal; }
  ^~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
19 warnings and 20 errors generated.
make: *** [obj/dcc.o] Error 1

/bin/sh: llvm-config: command not found