Repository navigation
Getting Started
Follow the steps below to build MCLinker project.
-
Download MCLinker source code into ${MCLINKER_SRC} directory.
git clone https://github.com/mclinker/mclinker.git ${MCLINKER_SRC} -
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 -
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
-
Setup environmnent
cd ${MCLINKER_SRC} -
Run autogen if there is no `configure' script
./autogen.sh -
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 -
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
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.
ld.mcld [options] objfile
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
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.
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
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
Please report bugs and problems to Issues. Any suggestion for improvement is also welcome.