<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">&lt;<a href="mailto:e.bachmakov@gmail.com" target="_blank">e.bachmakov@gmail.com</a>&gt;</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&#39;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&#39;s just the analysis run that<br>
fails (that was clear before but know it&#39;s definite)<br>
  4. The offending line is in here:<br>
<br>
&#39;/home/e/llvmlinux/toolchain/clang/install/bin/clang-3.4&#39; &#39;-cc1&#39;<br>
&#39;-triple&#39; &#39;x86_64-unknown-linux-gnu&#39; &#39;-analyze&#39; &#39;-disable-free&#39;<br>
&#39;-disable-llvm-verifier&#39; &#39;-main-file-name&#39; &#39;bounds.c&#39;<br>
&#39;-analyzer-store=region&#39; &#39;-analyzer-opt-analyze-nested-blocks&#39;<br>
&#39;-analyzer-eagerly-assume&#39; &#39;-analyzer-checker=core&#39;<br>
&#39;-analyzer-checker=unix&#39; &#39;-analyzer-checker=deadcode&#39;<br>
&#39;-analyzer-checker=security.insecureAPI.UncheckedReturn&#39;<br>
&#39;-analyzer-checker=security.insecureAPI.getpw&#39;<br>
&#39;-analyzer-checker=security.insecureAPI.gets&#39;<br>
&#39;-analyzer-checker=security.insecureAPI.mktemp&#39;<br>
&#39;-analyzer-checker=security.insecureAPI.mkstemp&#39;<br>
&#39;-analyzer-checker=security.insecureAPI.vfork&#39; &#39;-analyzer-output&#39;<br>
&#39;plist&#39; &#39;-w&#39; &#39;-mrelocation-model&#39; &#39;static&#39; &#39;-mdisable-fp-elim&#39;<br>
&#39;-fmath-errno&#39; &#39;-masm-verbose&#39; &#39;-mconstructor-aliases&#39;<br>
&#39;-munwind-tables&#39; &#39;-fuse-init-array&#39; &#39;-no-implicit-float&#39;<br>
&#39;-target-cpu&#39; &#39;armv7-a&#39; &#39;-nostdsysteminc&#39; &#39;-nobuiltininc&#39;<br>
&#39;-resource-dir&#39;<br>
&#39;/home/e/llvmlinux/toolchain/clang/install/bin/../lib/clang/3.4&#39;<br>
&#39;-isystem&#39; &#39;/home/e/llvmlinux/toolchain/clang/install/bin/../lib/clang/3.4/include&#39;<br>
&#39;-include&#39; &#39;/home/e/llvmlinux/targets/vexpress/src/linux/include/linux/kconfig.h&#39;<br>
&#39;-D&#39; &#39;__KERNEL__&#39; &#39;-D&#39; &#39;__LINUX_ARM_ARCH__=7&#39; &#39;-D&#39; &#39;KBUILD_STR(s)=#s&#39;<br>
&#39;-D&#39; &#39;KBUILD_BASENAME=KBUILD_STR(bounds)&#39; &#39;-D&#39;<br>
&#39;KBUILD_MODNAME=KBUILD_STR(bounds)&#39; &#39;-I&#39;<br>
&#39;/home/e/llvmlinux/targets/vexpress/src/linux/arch/arm/include&#39; &#39;-I&#39;<br>
&#39;arch/arm/include/generated&#39; &#39;-I&#39; &#39;include&#39; &#39;-I&#39;<br>
&#39;/home/e/llvmlinux/targets/vexpress/src/linux/arch/arm/include/uapi&#39;<br>
&#39;-I&#39; &#39;arch/arm/include/generated/uapi&#39; &#39;-I&#39;<br>
&#39;/home/e/llvmlinux/targets/vexpress/src/linux/include/uapi&#39; &#39;-I&#39;<br>
&#39;include/generated/uapi&#39; &#39;-Wno-trigraphs&#39; &#39;-Wno-format-security&#39;<br>
&#39;-Wno-asm-operand-widths&#39; &#39;-Wno-unused-variable&#39;<br>
&#39;-Wno-format-invalid-specifier&#39; &#39;-Wno-tautological-compare&#39;<br>
&#39;-Wno-pointer-sign&#39; &#39;-fdebug-compilation-dir&#39;<br>
&#39;/home/e/llvmlinux/targets/vexpress/src/linux&#39; &#39;-ferror-limit&#39; &#39;19&#39;<br>
&#39;-fmessage-length&#39; &#39;0&#39; &#39;-mstackrealign&#39; &#39;-fno-builtin&#39;<br>
&#39;-fobjc-runtime=gcc&#39; &#39;-fobjc-default-synthesize-properties&#39;<br>
&#39;-fdiagnostics-show-option&#39; &#39;-backend-option&#39; &#39;-vectorize-loops&#39;<br>
&#39;-analyzer-display-progress&#39; &#39;-analyzer-output=html&#39; &#39;-o&#39;<br>
&#39;/home/e/llvmlinux/targets/vexpress/tmp/scan-build-2013-06-26-6&#39; &#39;-x&#39;<br>
&#39;c&#39; &#39;kernel/bounds.c&#39;<br>
<br>
In particular, &#39;-target-cpu&#39; &#39;armv7-a&#39; doesn&#39;t work. I&#39;m not sure how<br>
target-cpu works so I started guessing things like armv7 or arm but<br>
that didn&#39;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&#39;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 &quot;clang -march=armv7-a bla.c&quot;, which surprises me<br>
since we&#39;re using -march for the actual built<br>
<br>
My current guess is that &#39;-triple&#39; &#39;x86_64-unknown-linux-gnu&#39;  might<br>
be the real reason behind the problem because ...<br>
<br>
clang -\#\#\# -target arm-none-linux-gnueabi bla.c<br>
includes &quot;-triple&quot; &quot;armv4t-none-linux-gnueabi&quot; and &quot;-target-cpu&quot; &quot;arm7tdmi&quot;<br>
<br>
and it compiles on my system (doesn&#39;t assemble but that&#39;s another issue)<br>
<br>
... does anyone know how targets/triples are defined? Or what they&#39;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 &lt;<a href="mailto:dl9pf@gmx.de">dl9pf@gmx.de</a>&gt; wrote:<br>
&gt; Comments inline ...<br>
&gt; --<br>
&gt;<br>
&gt; Dipl.-Ing.<br>
&gt; Jan-Simon Möller<br>
&gt;<br>
&gt; <a href="mailto:jansimon.moeller@gmx.de">jansimon.moeller@gmx.de</a><br>
&gt; On Monday 24 June 2013 20:57:00 Eduard Bachmakov wrote:<br>
&gt;&gt; Hey everyone,<br>
&gt;&gt;<br>
&gt;&gt; After what felt like a million do-overs I think I found a workable<br>
&gt;&gt; location for the integration of clang-analyzer. See patch below.<br>
&gt;&gt;<br>
&gt;&gt; The GOOD: x64 works. How?<br>
&gt;&gt;<br>
&gt;&gt;     cd targets/x86_64; make kernel-scan-build; scan-view &lt;watch end of<br>
&gt;&gt; output, last line before time statistics&gt;<br>
&gt;&gt;<br>
&gt;&gt; The BAD: Should work for other targets, however, it seems some flags<br>
&gt;&gt; aren&#39;t passed down in cases of cross-compilation, I&#39;m ironing that<br>
&gt;&gt; out. Feel free to try though!<br>
&gt;<br>
&gt; Check:<br>
&gt; ccc-analyzer ~ line 693 .  Seems like &quot;@Archs&quot; is empty in the ARM case and<br>
&gt; thus we don&#39;t set it properly (and seem like to default to x86).<br>
&gt;<br>
&gt;&gt; The UGLY: takes forever. However, JSM might donate a stripped down<br>
&gt;&gt; .config soon. That would speed things up a bit.<br>
&gt;<br>
&gt; Best,<br>
&gt; 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>