Book Image

Getting Started with LLVM Core Libraries

Book Image

Getting Started with LLVM Core Libraries

Overview of this book

Table of Contents (17 chapters)
Getting Started with LLVM Core Libraries
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Cross-compiling with Clang command-line arguments


Now that you know each toolchain component, we will show you how to use Clang as a cross-compiler by using the appropriate driver arguments.

Note

All the examples in this section are tested in an x86_64 machine running Ubuntu 12.04. We use Ubuntu-specific tools to download some dependencies, but the Clang-related commands should work in any other OS environment without (or with minor) modifications.

Driver options for the target

Clang uses the –target=<triple> driver option to dynamically select the target triple for which code needs to be generated. Beyond the triple, other options can be used to make target selection more accurate:

  • The -march=<arch> option selects the target base architecture. The examples of the <arch> values include armv4t, armv6, armv7, and armv7f for ARM and mips32, mips32r2, mips64, and mips64r2 for MIPS. This option alone also selects a default base CPU to be used in the code generator.

  • To select a specific...