[cfe-dev] [LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker

ETANI NORIKO noriko-e at fc.ritsumei.ac.jp
Tue Jul 17 21:10:22 PDT 2012


Thank you for your information.
I can learn how to use "ln" command to replace an assumed compiler to another one.


-----Original message-----
From:Simon Atanasyan <satanasyan at mips.com>
To:noriko-e at fc.ritsumei.ac.jp
Cc:llvmdev <llvmdev at cs.uiuc.edu>,clang-dev Developers <cfe-dev at cs.uiuc.edu>
Date:Fri, 6 Jul 2012 22:40:58 +0400
Subject:Re: [LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker


On Wed, Jul 4, 2012 at 9:21 AM, ETANI NORIKO <noriko-e at fc.ritsumei.ac.jp> wrote:
> Please advise me how to change a compiler from a host one to a target one.

Suppose MIPS toolchain is installed in the $MIPS folder (i.e.
mips-linux-gnu-gcc is in the $MIPS/bin folder). Note, if you want to
generate little-endian code and/or 64-bit code, you have to create the
following links in the $MIPS/bin folder:
* Little-endian 32-bit
    ln -s mips-linux-gnu-ld mipsel-linux-gnu-ld
    ln -s mips-linux-gnu-as mipsel-linux-gnu-as
* Little-endian 64-bit
    ln -s mips-linux-gnu-ld mips64el-linux-gnu-ld
    ln -s mips-linux-gnu-as mips64el-linux-gnu-as
* Big-endian 64-bit
    ln -s mips-linux-gnu-ld mips64-linux-gnu-ld
    ln -s mips-linux-gnu-as mips64-linux-gnu-as

If you use integrated assembler (turned on by -integrated-as option)
you can skip mips-linux-gnu-as links creation.

Exact command line options depends on used toolchain. Examples below
work for Mentor Graphics Toolchain version 2011.09-75

* Little-endian 32-bit
$ clang -target mipsel-linux-gnu main.c -static \
    --sysroot $MIPS/mips-linux-gnu/libc/el \
    -I$MIPS/mips-linux-gnu/libc/usr/include \
    -B$MIPS/lib/gcc/mips-linux-gnu/4.5.2/el \
    -L$MIPS/lib/gcc/mips-linux-gnu/4.5.2/el \

* Big-endian 32-bit
$ clang -target mips-linux-gnu main.c -static \
    --sysroot $MIPS/mips-linux-gnu/libc \
    -I$MIPS/mips-linux-gnu/libc/usr/include \
    -B$MIPS/lib/gcc/mips-linux-gnu/4.5.2 \
    -L$MIPS/lib/gcc/mips-linux-gnu/4.5.2 \

* Little-endian 64-bit
$ clang -target mips64el-linux-gnu main.c -static \
    --sysroot $MIPS/mips-linux-gnu/libc/el \
    -I$MIPS/mips-linux-gnu/libc/usr/include \
    -B$MIPS/lib/gcc/mips-linux-gnu/4.5.2/el/64 \

* Big-endian 64-bit
$ clang -target mips64-linux-gnu main.c -static \
    --sysroot $MIPS/mips-linux-gnu/libc \
    -I$MIPS/mips-linux-gnu/libc/usr/include \
    -B$MIPS/lib/gcc/mips-linux-gnu/4.5.2/64 \

If that does not work for you, could you please provide more information:
1. What command line options do you use?
2. What toolchain do you use and where is it installed?
3. What errors do you get?


More information about the cfe-dev mailing list