8000 Getting Started · mclinker/mclinker Wiki · GitHub
[go: up one dir, main page]

Skip to content

Getting Started

Pete Chou edited this page May 28, 2016 · 6 revisions

Build MCLinker

Follow the steps below to build MCLinker project.

Prepare MCLinker and LLVM
  1. Download MCLinker source code into ${MCLINKER_SRC} directory.

     git clone https://github.com/mclinker/mclinker.git ${MCLINKER_SRC}
    
  2. Find the specific LLVM revision or branch in README. For example, you may download LLVM trunk if you are working on master.

     svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
    
  3. Build LLVM and install to directory ${LLVM_INSTALL}

     cd where you want to build llvm
     mkdir llvm-build
     cd llvm-build
     cmake -DCMAKE_INSTALL_PREFIX=${LLVM_INSTALL} -DLLVM_ENABLE_PEDANTIC=off ${PATH_TO_LLVM_SOURCES}
     make all install
    

Since there is a bug in LLVM cmake script, we suggest you using auto-tools rather than cmake. see http://llvm.org/bugs/show_bug.cgi?id=14200

Build MCLinker
  1. Setup environmnent

     cd ${MCLINKER_SRC}
    
  2. Run autogen if there is no `configure' script

     ./autogen.sh
    
  3. To configure MCLinker, create a build directory ${MCLINKER_BUILD} and run the configuration

     cd ${MCLINKER_BUILD}
     ${MCLINKER_SRC}/configure --prefix=${MCLINKER_INSTALL} --with-llvm-config=${LLVM_INSTALL}/bin/llvm-config
    
  4. Build and install MCLinker.

     make && make install
    

The configuration argument --with-llvm-config specifies the config of llvm. For more configuration arguments, please refer to ${MCLINKER_SRC}/configure --help.

Besides, MCLinker provides some candies for developing in envsetup.sh. You can simply use command mk to build MCLinker everywhere. To do so, source ${MCLINKER_SRC}/scripts/envsetup.sh

Run

MCLinker builds shared objects, executables or partial links objects according to the given options. MCLinker supports several backends. Use -march or -m to specify the target device type.

synopsis

ld.mcld [options] objfile

usage

Build shared object from object files.

    ld.mcld -shared -march=arm ${filename}.o -sysroot=${ANDROID_SYSROOT} -o ${outputfile}.so

For more supported options, please refer to ld.mcld --help

Run Unit Test

MCLinker contains a set of unit tests inside the MCLinker repository. Unit tests help to test the specific class and its functions in MCLinker without running the whole program.

To build and run unit tests:

    cd ${MCLINKER_BUILD}
    make unittests

Writing Unit Test gives the tutorial of creating and writing a unit test for MCLinker.

Run Regression Tests

MCLinker also contains a set of regression tests inside the repository, under ${MCLINKER_SRC}/test. The regression tests help to verify the specific features of MCLinker. To run the regression tests, simply go into the build directory and run the command make check.

    cd ${MCLINKER_BUILD}
    make check

Run Coding Style Checker

MCLinker follows Google's C++ style, and for the include style, it follows LLVM include style. In MCLinker, cpplint is involved to check the coding style. To run the checker, go into the build directory and run the command make cpplint.

    cd ${MCLINKER_BUILD}
    make cpplint

Bug Reports

Please report bugs and problems to Issues. Any suggestion for improvement is also welcome.

Clone this wiki locally

0