ETANI NORIKO
2012-Jul-04 05:21 UTC
[LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker
Hi, I would like to ask you how to use Clang in cross-compile environment. My environment is as follows: ------ HOST: 32-bit Fedora 16 with Intel Core i7 gcc/g++ compiler available TARGET: 32-bit mips-typed linux gnu gcc/g++ for 32-bit mips-typed linux available ------ As Clang's option is "-c" in use, my programs are compiled and linked under a host machine's environment (in my case, 32-bit Fedora 16 is a host OS with Intel Core i7). In order to compile and link them under a target's environment (in my case, mips-typed linux gcc/g++ can work), in Clang’s "Assembler" and "Linker" processes, a compiler on a host should be changed to one on a target. Still now, I cannot find out a file to set a compiler for "Assembler" and "Linker" in Clang. Please advise me how to change a compiler from a host one to a target one. Regards, ------------ Noriko Etani
NAKAMURA Takumi
2012-Jul-06 15:12 UTC
[LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker
Konbanwa, Etani san, It might be clang driver issue. Move to cfe-dev. 2012/7/4 ETANI NORIKO <noriko-e at fc.ritsumei.ac.jp>:> I would like to ask you how to use Clang in cross-compile environment. My environment is as follows: > ------ > HOST: 32-bit Fedora 16 with Intel Core i7 > gcc/g++ compiler available > TARGET: 32-bit mips-typed linux > gnu gcc/g++ for 32-bit mips-typed linux available > ------* What do you specify as -target? (eg. clag -c -target i686-pc-mingw32) * Which toolchain have you installed and what is the prefix of it? AFAIU, GNU binutils for the target would be essential. (eg. /usr/bin/i686-pc-mingw32-ld)> As Clang's option is "-c" in use, my programs are compiled and linked under a host machine's environment (in my case, 32-bit Fedora 16 is a host OS with Intel Core i7). > > In order to compile and link them under a target's environment (in my case, mips-typed linux gcc/g++ can work), in Clang’s "Assembler" and "Linker" processes, a compiler on a host should be changed to one on a target. Still now, I cannot find out a file to set a compiler for "Assembler" and "Linker" in Clang. Please advise me how to change a compiler from a host one to a target one.* Have you tried "clang -c -integrated-as"? To Mips guys: Do you think Mips MC assembler would work? FYI, workaround. clang -S hogehoge.c target-gcc -c hogehoge.s target-gcc -o fugafuga hogehoge.o ... (I don't know how mips-clang would be mature) ...Takumi (中村)
Hatanaka, Akira
2012-Jul-06 17:08 UTC
[LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker
I think it is a driver issue too. The files should be in clang/lib/driver, but I am not very familiar with the code in the files. Perhaps Simon can answer your questions. llvm's test suite is run against clang/llvm nightly with direct object emission, so I believe clang's integrated assembler should work fine. $ clang foo.c -c -O3 -integrated-as -target mipsel-unknown-linux -ccc-clang-archs mipsel ________________________________________ From: NAKAMURA Takumi [geek4civic at gmail.com] Sent: Friday, July 06, 2012 8:12 AM To: noriko-e at fc.ritsumei.ac.jp Cc: llvmdev; cfe-dev; Hatanaka, Akira; Kotler, Reed Subject: Re: [LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker Konbanwa, Etani san, It might be clang driver issue. Move to cfe-dev. 2012/7/4 ETANI NORIKO <noriko-e at fc.ritsumei.ac.jp>:> I would like to ask you how to use Clang in cross-compile environment. My environment is as follows: > ------ > HOST: 32-bit Fedora 16 with Intel Core i7 > gcc/g++ compiler available > TARGET: 32-bit mips-typed linux > gnu gcc/g++ for 32-bit mips-typed linux available > ------* What do you specify as -target? (eg. clag -c -target i686-pc-mingw32) * Which toolchain have you installed and what is the prefix of it? AFAIU, GNU binutils for the target would be essential. (eg. /usr/bin/i686-pc-mingw32-ld)> As Clang's option is "-c" in use, my programs are compiled and linked under a host machine's environment (in my case, 32-bit Fedora 16 is a host OS with Intel Core i7). > > In order to compile and link them under a target's environment (in my case, mips-typed linux gcc/g++ can work), in Clang’s "Assembler" and "Linker" processes, a compiler on a host should be changed to one on a target. Still now, I cannot find out a file to set a compiler for "Assembler" and "Linker" in Clang. Please advise me how to change a compiler from a host one to a target one.* Have you tried "clang -c -integrated-as"? To Mips guys: Do you think Mips MC assembler would work? FYI, workaround. clang -S hogehoge.c target-gcc -c hogehoge.s target-gcc -o fugafuga hogehoge.o ... (I don't know how mips-clang would be mature) ...Takumi (中村)
Simon Atanasyan
2012-Jul-06 18:40 UTC
[LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker
Hi, 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 (https://sourcery.mentor.com/GNUToolchain/subscription3130?lite=MIPS). * 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 \ -integrated-as * 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 \ -integrated-as * 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 \ -L$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 \ -L$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? -- Simon
Joerg Sonnenberger
2012-Jul-06 21:41 UTC
[LLVMdev] [cfe-dev] how to change a compiler from a host to a target in Clang's assembler and linker
On Fri, Jul 06, 2012 at 10:40:58PM +0400, Simon Atanasyan wrote:> * 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 \ > -integrated-as-isysroot $MIPS/mips-linux-gnu/libc might be better than the -I. Your command doesn't give you the special handling for system headers. Joerg
ETANI NORIKO
2012-Jul-18 04:05 UTC
[LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker
Hi, Thank your for your confirmation. I had been looking for llvm compiler's option for compiler, assembler, and linker replacing asserted ones to target ones. As a cross-compiler, a cross-assembler, and a cross-linker for target have been already created in toolchain, they can be replaced through llvm compileration. Wishes, Noriko -----Original message----- From:NAKAMURA Takumi <geek4civic at gmail.com> To:noriko-e at fc.ritsumei.ac.jp Cc:llvmdev <llvmdev at cs.uiuc.edu>,cfe-dev <cfe-dev at cs.uiuc.edu>,Akira Hatanaka <ahatanaka at mips.com>,reed kotler <rkotler at mips.com> Date:Sat, 7 Jul 2012 00:12:24 +0900 Subject:Re: [LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker Konbanwa, Etani san, It might be clang driver issue. Move to cfe-dev. 2012/7/4 ETANI NORIKO <noriko-e at fc.ritsumei.ac.jp>:> I would like to ask you how to use Clang in cross-compile environment. My environment is as follows: > ------ > HOST: 32-bit Fedora 16 with Intel Core i7 > gcc/g++ compiler available > TARGET: 32-bit mips-typed linux > gnu gcc/g++ for 32-bit mips-typed linux available > ------* What do you specify as -target? (eg. clag -c -target i686-pc-mingw32) * Which toolchain have you installed and what is the prefix of it? AFAIU, GNU binutils for the target would be essential. (eg. /usr/bin/i686-pc-mingw32-ld)> As Clang's option is "-c" in use, my programs are compiled and linked under a host machine's environment (in my case, 32-bit Fedora 16 is a host OS with Intel Core i7). > > In order to compile and link them under a target's environment (in my case, mips-typed linux gcc/g++ can work), in Clang’s "Assembler" and "Linker" processes, a compiler on a host should be changed to one on a target. Still now, I cannot find out a file to set a compiler for "Assembler" and "Linker" in Clang. Please advise me how to change a compiler from a host one to a target one.* Have you tried "clang -c -integrated-as"? To Mips guys: Do you think Mips MC assembler would work? FYI, workaround. clang -S hogehoge.c target-gcc -c hogehoge.s target-gcc -o fugafuga hogehoge.o ... (I don't know how mips-clang would be mature) ...Takumi (中村)
ETANI NORIKO
2012-Jul-18 04:10 UTC
[LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker
Hi, Thank you for your information. I can learn how to use "ln" command to replace an assumed compiler to another one. Wishes, Noriko -----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 Hi, 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 (https://sourcery.mentor.com/GNUToolchain/subscription3130?lite=MIPS). * 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 \ -integrated-as * 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 \ -integrated-as * 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 \ -L$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 \ -L$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? -- Simon
Reasonably Related Threads
- [LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker
- [LLVMdev] how to change a compiler from a host to a target in Clang's assembler and linker
- Is the CppBackend still supported?
- The Trouble with Triples
- The Trouble with Triples