Giter Site home page Giter Site logo

llvm-tutorial's Introduction

llvm-tutorial

LLVM Tutorialを勉強するリポジトリ

How to compile samples

KaleidoscopeのChapter04以降で必要になるdynamic linkのコードが一部ビルドで正しく動きません. 今の所,llvmのgithubミラーのrelease_60ブランチだと正しく動作するようです. brewなどのパッケージでインストールされたllvmの場合,うまく動作しないので,githubからrelease_60ブランチのソースをチェックアウトし,コンパイルして使ってください.コンパイラは,macOSの場合,デフォルトのclang++を使えばよいようです.

LLVMのビルド

git clone https://github.com/llvm-mirror/llvm.git
cd llvm
git checkout -b release_60 origin/release_60
mkdir build
cd build
CC=gcc CXX=g++                              \
cmake -DCMAKE_INSTALL_PREFIX=/usr           \
      -DLLVM_ENABLE_FFI=ON                  \
      -DCMAKE_BUILD_TYPE=Release            \
      -DLLVM_BUILD_LLVM_DYLIB=ON            \
      -DLLVM_LINK_LLVM_DYLIB=ON             \
      -DLLVM_TARGETS_TO_BUILD="host;"       \
      -DLLVM_BUILD_TESTS=ON                 \
      -Wno-dev -G Ninja ..                  &&
ninja

LLVMのソース中のサンプルのビルドと動作確認

cd ./examples/Kaleidoscope/Chapter4/
g++ ./toy.cpp `../../../build/bin/llvm-config --cxxflags --ldflags --libs --libfiles --system-libs`
echo "extern printd(x);printd(1.0);" | ./a.out

正しくビルドできていれば,上記コードは,以下のような結果を出す.

ready> ready> Read extern: 
declare double @printd(double)

ready> ready> 1.000000
Evaluated to 0.000000
ready> ready> > Chapter4 sonson$ 

Table of contents

  1. Chapter 01
  2. Chapter 02
  3. Chapter 03
  4. Chapter 04
  5. Chapter 05
  6. Chapter 06
  7. Chapter 07
  8. Chapter 08
  9. Chapter 09
  10. Chapter 10

License

このリポジトリは,LLVMのソースコード,ドキュメントをベースに作成し,LLVM Release Licenseに従い,コンテンツを作成しています.

llvm-tutorial's People

Contributors

sonsongithub avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.