SPIR generator/Clang Installation Instructions

These instructions describe how to build, install and operate SPIR generator Clang.


Step 1: Organization

SPIR generator/Clang is designed to be built as part of an LLVM build.

SPIR generator/Clang is based on LLVM/Clang version 3.2.

The LLVM source code could be downloaded from http://www.llvm.org/releases/3.2/llvm-3.2.src.tar.gz.

It is also available directly from the LLVM svn server:

  svn co http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_32/final llvm

Or could be cloned from LLVM git repository:

  git clone http://llvm.org/git/llvm.git llvm
  cd llvm
  git checkout --track -b release_32 remotes/origin/release_32

Assuming that the LLVM source code is located at $LLVM_SRC_ROOT, then the clang source code should be installed as: $LLVM_SRC_ROOT/tools/clang.

The directory is not required to be called clang, but doing so will allow the LLVM build system to automatically recognize it and build it along with LLVM.

  cd $LLVM_SRC_ROOT/tools
  git clone https://github.com/KhronosGroup/SPIR clang
  cd clang
  git checkout --track -b spir_12 remotes/origin/spir_12

Step 2: Configure and Build LLVM

Configure and build your copy of LLVM (see $LLVM_SRC_ROOT/GettingStarted.html for more information).

Assuming you installed clang at $LLVM_SRC_ROOT/tools/clang then Clang will automatically be built with LLVM. Otherwise, run make in the Clang source directory to build Clang.

  • Note: currently there might be failures in check_clang project.

Step 3: (Optional) Verify Your Build

It is a good idea to run the Clang tests to make sure your build works correctly. From inside the Clang build directory, run make test to run the tests.


Step 4: Install Clang

If you wish to run Clang from the generated binary directory, you may skip this section.

From inside the Clang build directory, run make install to install the Clang compiler and header files into the prefix directory selected when LLVM was configured.

The Clang compiler is available as clang and clang++. It supports a gcc like command line interface. See the man page for clang (installed into $prefix/share/man/man1) for more information.


Step 5: Creating SPIR binaries

To create a SPIR binary from a valid OpenCL-C file (.cl), use the following command lines:

  clang -cc1 -emit-llvm-bc -triple <triple> <OpenCL compile options> -cl-spir-compile-options "<OpenCL compile options>" -include <opencl_spir.h> -o <output> <input>
  • <triple>: for 32 bit SPIR use spir-unknown-unknown, for 64 bit SPIR use spir64-unknown-unknown.
  • Note: <OpenCL compile options> appears twice. The command line option -cl-spir-compile-options "<OpenCL compile options>" specifies the compile options that occur in the SPIR metadata.
  • <opencl_spir.h>: download opencl_spir.h from https://github.com/KhronosGroup/SPIR-Tools/blob/master/headers/opencl_spir.h
  • -O: -O0 (default) is the only tested option value at the moment. It's assumed by design that all optimizations are executed by SPIR consumer.

Reporting issues

Bugs/feature requests can be filed via github or Khronos Bugzilla bug tracker.



SPIR generator/Clang Installation Instructions

这些说明描述如何构建,安装和操作SPIR生成器Clang。


步骤1:组织

SPIR生成器/ Clang旨在构建为LLVM构建的一部分。

SPIR生成器/ Clang基于LLVM / Clang版本3.2。

可以从 http://www.llvm.org下载LLVM源代码/releases/3.2/llvm-3.2.src.tar.gz

它也可以直接从LLVM svn服务器获得:

或者可以从LLVM git仓库克隆:

  git clone http://llvm.org/git/llvm.git llvm
  cd llvm
  git checkout –track -b release_32 remotes/origin/release_32
假设LLVM源代码位于 $ LLVM_SRC_ROOT ,那么cl 源代码应该安装为: $ LLVM_SRC_ROOT / tools / clang

该目录不需要被称为clang,但这样做将允许 LLVM构建系统自动识别它,并与LLVM一起构建。

  cd $LLVM_SRC_ROOT/tools
  git clone https://github.com/KhronosGroup/SPIR clang
  cd clang
  git checkout –track -b spir_12 remotes/origin/spir_12

步骤2:配置和构建LLVM

配置和构建您的LLVM副本(有关详细信息,请参阅 $ LLVM_SRC_ROOT / GettingStarted.html )。

假设你在 $ LLVM_SRC_ROOT / tools / clang 上安装了clang,那么Clang将 自动使用LLVM构建。否则,在Clang源中运行 make 目录来构建Clang。

  • 注意:目前check_clang项目可能会出现故障。

步骤3 :(可选)验证您的构建

运行Clang测试以确保您的构建工作是一个好主意 正确的从Clang构建目录里面,运行 make test 来运行 测试。


步骤4:安装Clang

如果要从生成的二进制目录中运行Clang,可以跳过此目录 部分。

从Clang构建目录里面,运行 make install 来安装Clang 编译器和头文件放入LLVM所选的前缀目录中 配置。

Clang编译器可用作 clang clang ++ 。它支持一个gcc 像命令行界面。参见手册页面(安装到 $ prefix / share / man / man1)获取更多信息。


步骤5:创建SPIR二进制文件

要从有效的OpenCL-C文件(.cl)创建SPIR二进制文件,请使用以下命令 命令行:

  clang -cc1 -emit-llvm-bc -triple <triple> <OpenCL compile options> -cl-spir-compile-options "<OpenCL compile options>" -include <opencl_spir.h> -o <output> <input>

报告问题

可以通过 github Khronos Bugzilla 错误跟踪器。




相关问题推荐