Rob Stewart
2013-Nov-26 15:36 UTC
[LLVMdev] Targeting ARM Cortex-a9 from x86_64 with clang
Hi, here's the canonical helloworld.c #include<stdio.h> int main() { printf("Hello World"); return 0; } In accordance with the cross-compilation LLVM documentation [1], I am trying to target the ARM on the Zedboard [2]. It is an ARM Cortex-A9. The machine I am compiling on is an x86_64 Fedora Linux machine, using clang 3.3. I am failing to generate an executable, instead seeing an error "unrecognized option '-mfpu=neon'". $ clang -v -target armv7a-linux-eabi -mcpu=cortex-a9 -mfloat-abi=soft -mfpu=neon helloworld.c clang version 3.3 (tags/RELEASE_33/rc3) Target: armv7a--linux-eabi Thread model: posix "/usr/bin/clang" -cc1 -triple armv7--linux-eabi -S -disable-free -disable-llvm-verifier -main-file-name helloworld.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -fuse-init-array -target-abi aapcs -target-cpu cortex-a9 -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature +neon -target-feature -neon -target-linker-version 2.23.52.0.1 -v -resource-dir /usr/bin/../lib/clang/3.3 -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.3/include -internal-externc-isystem /usr/include -internal-externc-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include -fno-dwarf-directory-asm -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 157 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/helloworld-SVQDb9.s -x c helloworld.c clang -cc1 version 3.3 based upon LLVM 3.3 default target x86_64-redhat-linux-gnu #include "..." search starts here: #include <...> search starts here: /usr/local/include /usr/bin/../lib/clang/3.3/include /usr/include /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include End of search list. "/usr/bin/as" -mfpu=neon -mfloat-abi=soft -mcpu=cortex-a9 -mfpu=neon -o /tmp/helloworld-DFsRi6.o /tmp/helloworld-SVQDb9.s /usr/bin/as: unrecognized option '-mfpu=neon' clang: error: assembler command failed with exit code 1 (use -v to see invocation) Any ideas? Thanks! [1] - http://clang.llvm.org/docs/CrossCompilation.html [2] - http://elinux.org/Zedboard
Renato Golin
2013-Nov-26 16:44 UTC
[LLVMdev] Targeting ARM Cortex-a9 from x86_64 with clang
On 26 November 2013 15:36, Rob Stewart <robstewart57 at gmail.com> wrote:> $ clang -v -target armv7a-linux-eabi -mcpu=cortex-a9 -mfloat-abi=soft > -mfpu=neon helloworld.c >Hi Rod, You need cross-binutils installed on your box. If you use Debian, there are packages (gcc-4.7-arm-linux-gnueabi and friends). Other distros may have similar packages, but you can always download the Linaro toolchain ( http://releases.linaro.org/latest/components/toolchain). Supposing you already have it, and it's in the PATH, Clang only recognizes it automatically if your triple is identical to the name of your cross compiler (See "Toolchain Options" in the referred doc). That means, you either need to have an "armv7a-linux-eabi-gcc" on the path, or you have to change your triple to something like "arm-linux-gnueabi", because that's what your cross-GCC will probably be called. The -mcpu will take care of choosing v7A. Otherwise, you'll have to set --sysroot or --gcc-name as well as the triple, but that's not recommended. "/usr/bin/as" -mfpu=neon -mfloat-abi=soft -mcpu=cortex-a9 -mfpu=neon>As you can see, it chose the platform assembler, which is x86_64-only, not a cross-assembler. That's the hint that Clang didn't find your cross-binutils. I know, Clang could have better error detection and stop when it's clearly the wrong architecture, but hey, Clang can deal with all archs on the same binary, there's no reason your system assembler (whatever it is) can't, too. One day, LLVM binutils will be... ;) cheers, --renato -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131126/dfffabb0/attachment.html>
On Tue, Nov 26, 2013 at 11:44 AM, Renato Golin <renato.golin at linaro.org>wrote:> On 26 November 2013 15:36, Rob Stewart <robstewart57 at gmail.com> wrote: > >> $ clang -v -target armv7a-linux-eabi -mcpu=cortex-a9 -mfloat-abi=soft >> -mfpu=neon helloworld.c >> > > Hi Rod, > > You need cross-binutils installed on your box. If you use Debian, there > are packages (gcc-4.7-arm-linux-gnueabi and friends). Other distros may > have similar packages, but you can always download the Linaro toolchain ( > http://releases.linaro.org/latest/components/toolchain). > > Supposing you already have it, and it's in the PATH, Clang only recognizes > it automatically if your triple is identical to the name of your cross > compiler (See "Toolchain Options" in the referred doc). That means, you > either need to have an "armv7a-linux-eabi-gcc" on the path, or you have to > change your triple to something like "arm-linux-gnueabi", because that's > what your cross-GCC will probably be called. The -mcpu will take care of > choosing v7A. > > Otherwise, you'll have to set --sysroot or --gcc-name as well as the > triple, but that's not recommended. > > > "/usr/bin/as" -mfpu=neon -mfloat-abi=soft -mcpu=cortex-a9 -mfpu=neon >> > > As you can see, it chose the platform assembler, which is x86_64-only, not > a cross-assembler. That's the hint that Clang didn't find your > cross-binutils. >Out of curiosity, can't clang do the assembly itself in this case?> > I know, Clang could have better error detection and stop when it's clearly > the wrong architecture, but hey, Clang can deal with all archs on the same > binary, there's no reason your system assembler (whatever it is) can't, > too. One day, LLVM binutils will be... ;) >Well, just remember that the GNU binutils that those tools are derived from support far more architectures (3x, 5x?) than LLVM does (just supporting linux requires like 30 architectures). When we get to that point, it will probably not make sense for a distro to ship a binary targeting all the architectures that we support, for the same reason it doesn't make sense for them to install binaries for every target supported by the GNU toolchain. (but at least in LLVM's case, it would be a conscious tradeoff, while IIRC the GNU toolchain simply can't be built in a way that targets all of them from a single binary). -- Sean Silva> > cheers, > --renato > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131126/70ea0853/attachment.html>
Rob Stewart
2013-Nov-27 13:57 UTC
[LLVMdev] Targeting ARM Cortex-a9 from x86_64 with clang
On 26 November 2013 16:44, Renato Golin <renato.golin at linaro.org> wrote:> On 26 November 2013 15:36, Rob Stewart <robstewart57 at gmail.com> wrote: >> >> $ clang -v -target armv7a-linux-eabi -mcpu=cortex-a9 -mfloat-abi=soft >> -mfpu=neon helloworld.c > > Hi Rod,I'm honoured. (But Rob is also OK) :-)> You need cross-binutils installed on your box. If you use Debian, there are > packages (gcc-4.7-arm-linux-gnueabi and friends). Other distros may have > similar packages, but you can always download the Linaro toolchain > (http://releases.linaro.org/latest/components/toolchain). > > Supposing you already have it, and it's in the PATH, Clang only recognizes > it automatically if your triple is identical to the name of your cross > compiler (See "Toolchain Options" in the referred doc). That means, you > either need to have an "armv7a-linux-eabi-gcc" on the path, or you have to > change your triple to something like "arm-linux-gnueabi", because that's > what your cross-GCC will probably be called. The -mcpu will take care of > choosing v7A.So on my Fedora box, I've installed packages gcc-arm-linux-gnu.x86_64 and cross-binutils-common.noarch . Moreover, the first of these two packages provide `/usr/bin/arm-linux-gnu-gcc` $ repoquery -lq gcc-arm-linux-gnu.x86_64 Repository google-chrome is listed more than once in the configuration /usr/bin/arm-linux-gnu-cpp /usr/bin/arm-linux-gnu-gcc /usr/bin/arm-linux-gnu-gcov /usr/lib/gcc/arm-linux-gnueabi /usr/lib/gcc/arm-linux-gnueabi/4.8.1 /usr/lib/gcc/arm-linux-gnueabi/4.8.1/crtbegin.o ... The -target that appears to be recognised by clang is `arm-none-eabi`. However, I'm now falling in to another trap. $ clang -v -target arm-none-eabi -mcpu=cortex-a9 -mfloat-abi=soft helloworld.c ... arm-none-eabi-gcc: fatal error: selected multilib '.' not installed I've put the -v output to gist: https://gist.github.com/robstewart57/7676030
Possibly Parallel Threads
- [LLVMdev] Targeting ARM Cortex-a9 from x86_64 with clang
- [LLVMdev] Targeting ARM Cortex-a9 from x86_64 with clang
- [LLVMdev] Targeting ARM Cortex-a9 from x86_64 with clang
- [LLVMdev] Targeting ARM Cortex-a9 from x86_64 with clang
- [LLVMdev] Setting up a cross-compiler for cortex-m3