Build LLD Linker

From Dmz-portal

Jump to: navigation, search

Contents

Overview

This page describes how to build LLD linker on X86 / X86_64 host.

Prerequisites

Before you begin to build LLD linker make sure you have installed g++ 4.8 or newer and cmake 2.8 or newer.

Build

Let's define some shortcuts for directories:

$LLD_SRC
Source code root directory
$LLD_BLD
Build directory
$LLD_INSTALL
Directory to install built LLD package

First you need to checkout LLVM/Clang source code.

$ svn co http://llvm.org/svn/llvm-project/llvm/trunk $LLD_SRC
$ svn co http://llvm.org/svn/llvm-project/lld/trunk $LLD_SRC/tools/lld
$ mkdir $LLD_BLD
$ cd $LLD_BLD
$ cmake -G "Unix Makefiles" \
        -DCMAKE_CXX_FLAGS="-std=c++11 -fpermissive" \
        -DCMAKE_BUILD_TYPE:STRING=Debug \
        -DLLVM_TARGETS_TO_BUILD="X86;Mips" \
        -DCMAKE_INSTALL_PREFIX:PATH=$LLD_INSTALL \
        $LLD_SRC
$ make lld-test install

Using LLD

LLD linker can be run using different flavors: gnu, darwin etc. If you run LLD linker manually you can use the explicit way:

$ $LLD_INSTALL/bin/lld -flavor gnu -target mipsel ...

If you want to substitute default GNU ld linker, you can use implicit way to select gnu flavor:

# Create symbolic link
$ ln -s $LLD_INSTALL/bin/lld $LLD_INSTALL/bin/mipsel-linux-gnu-ld
# Run Clang to compile and link an executable file for MIPS target
$ clang -target mipsel-linux-gnu -gcc-toolchain <path to the toolchain> -B$LLD_INSTALL/bin main.c
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox