<div>Eduard,</div><div><br></div><div>See llvmlinux/arch/arm/bin/clang-wrap.sh for a script that passes clang the required parameters to cross compile for userspace ARMv7 code.</div><div><br></div><div>See llvmlinux/test/unit/register-var/Makefile for an example using clang_wrap.</div>
<div><br></div><div>There is also an example in llvmlinux/test/unit/ARM64bit/Makefile for setting the parameters.</div><div><br></div><div>It is a bit of a black art and not at all well documented.</div><div><br></div><div>
-Mark</div><div><br></div><div><br><div class="gmail_quote">On Wed, Jun 26, 2013 at 10:29 AM, Eduard Bachmakov <span dir="ltr"><<a href="mailto:e.bachmakov@gmail.com" target="_blank">e.bachmakov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Alright after tons of tinkering I came up with the following conclusions.<br>
<br>
1. I can't confirm if this is arm specific or just non-x64 because<br>
every other arch failed to compile for me.<br>
2. It is not an issue with environment or make variables.<br>
3. There is no compilation issue, it's just the analysis run that<br>
fails (that was clear before but know it's definite)<br>
4. The offending line is in here:<br>
<br>
'/home/e/llvmlinux/toolchain/clang/install/bin/clang-3.4' '-cc1'<br>
'-triple' 'x86_64-unknown-linux-gnu' '-analyze' '-disable-free'<br>
'-disable-llvm-verifier' '-main-file-name' 'bounds.c'<br>
'-analyzer-store=region' '-analyzer-opt-analyze-nested-blocks'<br>
'-analyzer-eagerly-assume' '-analyzer-checker=core'<br>
'-analyzer-checker=unix' '-analyzer-checker=deadcode'<br>
'-analyzer-checker=security.insecureAPI.UncheckedReturn'<br>
'-analyzer-checker=security.insecureAPI.getpw'<br>
'-analyzer-checker=security.insecureAPI.gets'<br>
'-analyzer-checker=security.insecureAPI.mktemp'<br>
'-analyzer-checker=security.insecureAPI.mkstemp'<br>
'-analyzer-checker=security.insecureAPI.vfork' '-analyzer-output'<br>
'plist' '-w' '-mrelocation-model' 'static' '-mdisable-fp-elim'<br>
'-fmath-errno' '-masm-verbose' '-mconstructor-aliases'<br>
'-munwind-tables' '-fuse-init-array' '-no-implicit-float'<br>
'-target-cpu' 'armv7-a' '-nostdsysteminc' '-nobuiltininc'<br>
'-resource-dir'<br>
'/home/e/llvmlinux/toolchain/clang/install/bin/../lib/clang/3.4'<br>
'-isystem' '/home/e/llvmlinux/toolchain/clang/install/bin/../lib/clang/3.4/include'<br>
'-include' '/home/e/llvmlinux/targets/vexpress/src/linux/include/linux/kconfig.h'<br>
'-D' '__KERNEL__' '-D' '__LINUX_ARM_ARCH__=7' '-D' 'KBUILD_STR(s)=#s'<br>
'-D' 'KBUILD_BASENAME=KBUILD_STR(bounds)' '-D'<br>
'KBUILD_MODNAME=KBUILD_STR(bounds)' '-I'<br>
'/home/e/llvmlinux/targets/vexpress/src/linux/arch/arm/include' '-I'<br>
'arch/arm/include/generated' '-I' 'include' '-I'<br>
'/home/e/llvmlinux/targets/vexpress/src/linux/arch/arm/include/uapi'<br>
'-I' 'arch/arm/include/generated/uapi' '-I'<br>
'/home/e/llvmlinux/targets/vexpress/src/linux/include/uapi' '-I'<br>
'include/generated/uapi' '-Wno-trigraphs' '-Wno-format-security'<br>
'-Wno-asm-operand-widths' '-Wno-unused-variable'<br>
'-Wno-format-invalid-specifier' '-Wno-tautological-compare'<br>
'-Wno-pointer-sign' '-fdebug-compilation-dir'<br>
'/home/e/llvmlinux/targets/vexpress/src/linux' '-ferror-limit' '19'<br>
'-fmessage-length' '0' '-mstackrealign' '-fno-builtin'<br>
'-fobjc-runtime=gcc' '-fobjc-default-synthesize-properties'<br>
'-fdiagnostics-show-option' '-backend-option' '-vectorize-loops'<br>
'-analyzer-display-progress' '-analyzer-output=html' '-o'<br>
'/home/e/llvmlinux/targets/vexpress/tmp/scan-build-2013-06-26-6' '-x'<br>
'c' 'kernel/bounds.c'<br>
<br>
In particular, '-target-cpu' 'armv7-a' doesn't work. I'm not sure how<br>
target-cpu works so I started guessing things like armv7 or arm but<br>
that didn't work either. According to clang -cc1 -help, target-cpu<br>
seems to be the only thing to have an influence on target architecture<br>
(with -cc1 -arch or -march or -mtune don't seem to be supported). I<br>
did a few tests with clang -### and it turns out that -march=xyz is<br>
translated to -target-cpu xyz .<br>
<br>
A quick test on my host clang 3.3 I getting the same issue for a<br>
trivial test like "clang -march=armv7-a bla.c", which surprises me<br>
since we're using -march for the actual built<br>
<br>
My current guess is that '-triple' 'x86_64-unknown-linux-gnu' might<br>
be the real reason behind the problem because ...<br>
<br>
clang -\#\#\# -target arm-none-linux-gnueabi bla.c<br>
includes "-triple" "armv4t-none-linux-gnueabi" and "-target-cpu" "arm7tdmi"<br>
<br>
and it compiles on my system (doesn't assemble but that's another issue)<br>
<br>
... does anyone know how targets/triples are defined? Or what they're<br>
really called so I can search for docs online?<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Jun 26, 2013 at 10:24 AM, Jan-Simon Möller <<a href="mailto:dl9pf@gmx.de">dl9pf@gmx.de</a>> wrote:<br>
> Comments inline ...<br>
> --<br>
><br>
> Dipl.-Ing.<br>
> Jan-Simon Möller<br>
><br>
> <a href="mailto:jansimon.moeller@gmx.de">jansimon.moeller@gmx.de</a><br>
> On Monday 24 June 2013 20:57:00 Eduard Bachmakov wrote:<br>
>> Hey everyone,<br>
>><br>
>> After what felt like a million do-overs I think I found a workable<br>
>> location for the integration of clang-analyzer. See patch below.<br>
>><br>
>> The GOOD: x64 works. How?<br>
>><br>
>> cd targets/x86_64; make kernel-scan-build; scan-view <watch end of<br>
>> output, last line before time statistics><br>
>><br>
>> The BAD: Should work for other targets, however, it seems some flags<br>
>> aren't passed down in cases of cross-compilation, I'm ironing that<br>
>> out. Feel free to try though!<br>
><br>
> Check:<br>
> ccc-analyzer ~ line 693 . Seems like "@Archs" is empty in the ARM case and<br>
> thus we don't set it properly (and seem like to default to x86).<br>
><br>
>> The UGLY: takes forever. However, JSM might donate a stripped down<br>
>> .config soon. That would speed things up a bit.<br>
><br>
> Best,<br>
> JS<br>
_______________________________________________<br>
LLVMLinux mailing list<br>
<a href="mailto:LLVMLinux@lists.linuxfoundation.org">LLVMLinux@lists.linuxfoundation.org</a><br>
<a href="https://lists.linuxfoundation.org/mailman/listinfo/llvmlinux" target="_blank">https://lists.linuxfoundation.org/mailman/listinfo/llvmlinux</a></div></div></blockquote></div><br></div>