On 08/02/13 14:42, Renato Golin wrote: [...]> Can you paste the result of a "clang -v -mcpu=CPU file.c" on your box? I > want to see what are the arguments and the assembler/linker it's > choosing to use. What CPU are we talking about?The box itself is an Allwinner A10; armv7l. /proc/cpuinfo says it's got swp half thumb fastmult vfp edsp neon vfpv3. I've been unable to find any values for CPU which are accepted (it just says 'unknown target CPU'. I've tried arm, armv7, armv7a, armv7l, arm7, armv4t... Any suggestions? Is there a way to get clang and llc to emit a list of what triples they support? Since I posted my message I notice that clang 3.2 has hit Debian experimental. This no longer produces the warning about an unrecognised platform, but it still generates softfloat code --- I've compared clang's output and gcc, and gcc produces hardfloat code. (Incidentally, I was wrong earlier about clang 3.2 failing. Its output causes ld to produce an assertion message, and it didn't occur to me then to look to see whether it had actually created a binary or not.) Here's what clang 3.2 says with 'clang -v -S -O3 test.c': Debian clang version 3.2-1~exp3 (tags/RELEASE_32/final) (based on LLVM 3.2) Target: arm-unknown-linux-gnueabihf Thread model: posix "/usr/bin/clang" -cc1 -triple armv4t-unknown-linux-gnueabihf -S -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -fuse-init-array -target-abi aapcs-linux -target-cpu arm7tdmi -mfloat-abi hard -target-linker-version 2.22 -momit-leaf-frame-pointer -v -coverage-file /home/dg/shared/workspace/calculon/test.s -resource-dir /usr/bin/../lib/clang/3.2 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.2/include -internal-isystem /usr/include/clang/3.2/include/ -internal-externc-isystem /usr/include/arm-linux-gnueabihf -internal-externc-isystem /usr/include/arm-linux-gnueabihf -internal-externc-isystem /usr/include -O3 -fno-dwarf-directory-asm -fdebug-compilation-dir /home/dg/shared/workspace/calculon -ferror-limit 19 -fmessage-length 80 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o test.s -x c test.c Clang 3.1: Debian clang version 3.1-8 (branches/release_31) (based on LLVM 3.1) Target: arm-unknown-linux-gnueabihf Thread model: posix clang: warning: unknown platform, assuming -mfloat-abi=soft "/usr/bin/clang" -cc1 -triple armv4t-unknown-linux-gnueabihf -S -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-abi apcs-gnu -target-cpu arm7tdmi -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-linker-version 2.22 -momit-leaf-frame-pointer -v -coverage-file test.s -resource-dir /usr/bin/../lib/clang/3.1 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.1/include -internal-isystem /usr/include/clang/3.1/include/ -internal-externc-isystem -internal-externc-isystem /usr/include/arm-linux-gnueabihf -internal-externc-isystem /usr/include/arm-linux-gnueabihf -internal-externc-isystem /usr/include -O3 -fno-dwarf-directory-asm -fdebug-compilation-dir /home/dg/shared/workspace/calculon -ferror-limit 19 -fmessage-length 80 -mstackrealign -fno-signed-char -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o test.s -x c test.c And here's clang 3.0: Debian clang version 3.0-6 (tags/RELEASE_30/final) (based on LLVM 3.0) Target: arm-unknown-linux-gnueabihf Thread model: posix clang: warning: unknown platform, assuming -mfloat-abi=soft "/usr/bin/clang" -cc1 -triple armv4t-unknown-linux-gnueabihf -S -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-abi apcs-gnu -target-cpu arm7tdmi -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-linker-version 2.22 -momit-leaf-frame-pointer -v -coverage-file test.s -resource-dir /usr/bin/../lib/clang/3.0 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.0/include -internal-externc-isystem /usr/include/arm-linux-gnueabihf -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fmessage-length 80 -fno-signed-char -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o test.s -x c test.c (Sorry for the spammage, but I thought it better to snip too little than too much...) I'm particularly curious about the way that the triple passed into the compiler backend starts 'armv4t' when it's rejected as a CPU type if I specify it manually. [...]> If that works, it's possible that you'll need to set the flags Clang is > doing by default on your front-end, too.But this *should* all be autodetected, right? If I'm using the JIT, I shouldn't need platform-specific knowledge to set up the code generator? -- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ "Of course, on a sufficiently small planet, 40 km/hr is, in fact, │ sufficient to punt the elastic spherical cow into low orbit." --- │ Brooks Moses on r.a.sf.c -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130208/f95f583f/attachment.sig>
On 8 February 2013 21:42, David Given <dg at cowlark.com> wrote:> The box itself is an Allwinner A10; armv7l. /proc/cpuinfo says it's got > swp half thumb fastmult vfp edsp neon vfpv3. >Yes, it's a Cortex-A8. I've been unable to find any values for CPU which are accepted (it just> says 'unknown target CPU'. I've tried arm, armv7, armv7a, armv7l, arm7, > armv4t... Any suggestions? Is there a way to get clang and llc to emit a > list of what triples they support? >armv7 and armv7a should default to Cortex-A8, "arm" will default to 7TDMI. Target: arm-unknown-linux-gnueabihf>Auto-detected wrongly (as expected),> "/usr/bin/clang" -cc1 -triple armv4t-unknown-linux-gnueabihf -S >Defaulted to armv4t == ARM7TDMI. I'm particularly curious about the way that the triple passed into the> compiler backend starts 'armv4t' when it's rejected as a CPU type if I > specify it manually. >What does: 'clang -v -mcpu=cortex-a8 -S -O3 test.c' prints as a target? Just need to do that on the latest Clang, and only paste the target line. But this *should* all be auto-detected, right? Should, but it isn't. Unfortunately, auto-detection in the ARM world is not as simple as in the Intel world, and it's just not implemented. If your compiler's name is "armv7a-unknown-linux-gnueabihf-clang", you might get it right, since that part is implemented and should guess cortex-a8 (not because it'll detect your CPU, but because it's hard-coded armv7 -> A8). If I'm using the JIT, I> shouldn't need platform-specific knowledge to set up the code generator? >You should. The IR (which the execution engine runs) is not platform independent. The front-end has to make some assumptions when generating IR, depending on the platform, so you need to generate the correct code to begin with. Also, as Amara said, you can set hard-float manually, in the execution engine, but if your CPU is still v4, I don't think it'll work. You should make sure you got a v7, than force hard-float, and NEON, and then you'll get the execution correct. However, if your command line contains "-mcpu=cortex-a8", you should get all that for free when you build your Target with the triple above. cheers, --renato -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130209/56446de2/attachment.html>
On 09/02/13 19:50, Renato Golin wrote: [...]> What does: 'clang -v -mcpu=cortex-a8 -S -O3 test.c' prints as a target?Target: arm-unknown-linux-gnueabihf ...and the triple passed in to clang is armv7-unknown-linux-gnueabihf, and it generated hardfloat code! That works! [...]> Should, but it isn't. Unfortunately, auto-detection in the ARM world is > not as simple as in the Intel world, and it's just not implemented.This sounds like something the Debian people should be doing: they know what ABI clang is being built for, therefore they should be doing whatever configuration is needed to make sure that the default configuration allows the compiler produces binaries that actually work. I'll file a bug. Thank-you very much. Incidentally, clang -help doesn't list the -mcpu= option. And is there any way to make the compiler list the supported set of architectures? It would never have occurred to me to try cortex-a8... -- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ "Of course, on a sufficiently small planet, 40 km/hr is, in fact, │ sufficient to punt the elastic spherical cow into low orbit." --- │ Brooks Moses on r.a.sf.c -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130209/a1320576/attachment.sig>