<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Stefan<div class=""><br class=""></div><div class="">Add -ffreestanding to CFLAGS, kernel being a bare metal should use this flag globally IMO, it might cause problems</div><div class="">due to altered meanings of c99 types but try it. Second option would be to add -fno-builtin globally and if that does not work</div><div class="">then go to specific subsystem makefile and add it there.</div><div class=""><br class=""></div><div class="">Thanks</div><div class="">-Khem</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Aug 28, 2015, at 9:14 AM, Fürst Stefan &lt;<a href="mailto:dieb.stefan.96@gmail.com" class="">dieb.stefan.96@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">Hello, <br class=""><br class=""></div>i just build LLVM and Clang in release mod. Than i recompiled my kernel with it.<br class=""></div>But i stil get these errors.<br class=""><br class="">arch/arm/kernel/built-in.o: In function `copy_thread':<br class="">/home/stefan/build/kernels/one_plus_one/arch/arm/kernel/process.c:576: undefined reference to `__aeabi_memcpy4'<br class="">arch/arm/kernel/built-in.o: In function `elf_core_copy_regs':<br class="">/home/stefan/build/kernels/one_plus_one/include/linux/elfcore.h:113: undefined reference to `__aeabi_memcpy4'<br class="">arch/arm/kernel/built-in.o: In function `put_user_reg':<br class="">/home/stefan/build/kernels/one_plus_one/arch/arm/kernel/ptrace.c:177: undefined reference to `__aeabi_memcpy4'<br class="">arch/arm/kernel/built-in.o: In function `gpr_set':<br class="">/home/stefan/build/kernels/one_plus_one/arch/arm/kernel/ptrace.c:610: undefined reference to `__aeabi_memcpy4'<br class="">arch/arm/kernel/built-in.o: In function `ptrace_sethbpregs':<br class="">/home/stefan/build/kernels/one_plus_one/arch/arm/kernel/ptrace.c:551: undefined reference to `__aeabi_memcpy8'<br class="">arch/arm/kernel/built-in.o: In function `gpr_set':<br class="">/home/stefan/build/kernels/one_plus_one/arch/arm/kernel/ptrace.c:610: undefined reference to `__aeabi_memcpy4'<br class="">arch/arm/kernel/built-in.o: In function `vfp_set':<br class="">/home/stefan/build/kernels/one_plus_one/arch/arm/kernel/ptrace.c:710: undefined reference to `__aeabi_memcpy8'<br class=""></div><div class="">and<br class=""></div><div class="">__aeabi_memclr<br class="">__aeabi_memclr4<br class="">__aeabi_memclr8<br class=""></div><br class=""><br class=""></div><a href="http://llvm.org/docs/GettingStarted.html#requirements" class="">http://llvm.org/docs/GettingStarted.html#requirements</a><br class=""></div>Followed steps till step 8<br class=""></div>Than i applied your patch and compiled clang in release mode.<br class=""></div><div class=""><br class=""></div><div class="">Than i compiled ther kernel with my build command<br class="">make ARCH=arm CROSS_COMPILE=/home/stefan/build/toolchains/UBERTC-arm-eabi-4.9/bin/arm-eabi- -l4 -j5 COMPILER_PATH=/home/stefan/build/toolchains/UBERTC-arm-eabi-4.9 GCC_TOOLCHAIN=/home/stefan/build/toolchains/UBERTC-arm-eabi-4.9 HOSTCC="/home/stefan/clang/Release/bin/clang" CC="/home/stefan/clang/Release/bin/clang -target arm-none-eabi -march=armv7-a -mfpu=neon -no-integrated-as -fcolor-diagnostics -I/home/stefan/llvmlinux/toolchain/clang/head/src/clang/lib/Headers -Wno-unused-parameter --gcc-toolchain=/home/stefan/build/toolchains/UBERTC-arm-eabi-4.9 "<br class=""></div><br class=""></div>I am interested in this one<br class=""><br class=""><span class="im"><div class="">3. Add -fno-builtin-&lt;value&gt; to compiler flags to disable compiler from emitting it</div><br class=""></span><div class="">&nbsp;&nbsp;
 That is what I am doing. I have added a hidden flag on LLVM side 
"-arm-memcpy". If you set "-arm-memcpy=false" it will not emit them. I 
will add something like on clang as well. Probably as you suggested and 
some other sources "-no-builtin-memcpy" and so.<br class=""><br class=""></div><div class="">This seems to be the best solution if that is possible. How can i do that? Is there already a patch available?<br class=""><br class=""></div><div class="">Kind regards<br class=""></div><div class="">Stefan Fürst<br class=""></div><br class=""><div class=""><br class="">
  </div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2015-08-27 13:11 GMT+02:00 Vinicius Tinti <span dir="ltr" class="">&lt;<a href="mailto:viniciustinti@gmail.com" target="_blank" class="">viniciustinti@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="">On Tue, Aug 25, 2015 at 10:22 AM, Fürst Stefan <span dir="ltr" class="">&lt;<a href="mailto:dieb.stefan.96@gmail.com" target="_blank" class="">dieb.stefan.96@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class=""><div class=""><div class="">Hello,<br class=""><br class=""></div>thank you very much for investigating that problem. Take your time.<br class=""></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Hi all,<br class=""><br class=""></div><div class="">Please find attached the patch. I have not yet sent do LLVM because it is still missing the test cases for LLVM. I think it will be upstreamable by the weeked.<br class=""></div><div class="">Suggestions?<br class=""><br class=""></div><div class="">Basically I am separating EABI and GNUEABI.<br class=""></div><div class=""><br class=""></div><div class="">Regards,<br class=""></div><div class="">Vinicius<br class="">&nbsp;</div><div class=""><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class=""><div class=""></div>Kind regards<span class=""><font color="#888888" class=""><br class=""></font></span></div><span class=""><font color="#888888" class="">Stefan Fürst</font></span><div class=""><div class=""><br class=""><div class=""><div class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2015-08-25 12:41 GMT+02:00 Vinicius Tinti <span dir="ltr" class="">&lt;<a href="mailto:viniciustinti@gmail.com" target="_blank" class="">viniciustinti@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="">On Tue, Aug 25, 2015 at 6:22 AM, Fürst Stefan <span dir="ltr" class="">&lt;<a href="mailto:dieb.stefan.96@gmail.com" target="_blank" class="">dieb.stefan.96@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class=""><div class=""><div class="">Thank you guys for your answers,<br class=""><br class=""></div>Where can i find that fix for eabi-arm.patch ? <br class=""></div>Here not <a href="http://lists.linuxfoundation.org/pipermail/llvmlinux/2015-August/thread.html#start" target="_blank" class="">http://lists.linuxfoundation.org/pipermail/llvmlinux/2015-August/thread.html#start</a><br class=""></div>Was it an internal discussion ? <br class=""><div class=""><div class=""><br class="">-fno-builtin is already in the makefile but it does not seem to solve my errors.<br class=""><br class=""></div><div class="">As a hobby developer this seems to be to difficult for me because my coding skills aren't that good yet. There must be an easier way to do that.<br class=""><br class=""></div><div class=""><span class=""><div class="">"1. Implement this builtin in kernel&nbsp;</div><div class="">2. Alter the code in question so that compiler does not generate the call to builtin"<br class=""></div></span></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Hi Fûrst,<br class=""><br class=""></div><div class="">I am working on fixing aeabi issue. So far what I found is that LLVM/Clang does not check the flags mention by Jan-Simon when it is generating the code. It will instead check the triple and see if it satisfy the instruction and if it does it is emited. Moreover, I am not sure of that part, the linker does not seem to recognize __aeabi_memcpy, __aeabi_memmove, __aeabi_memset.<br class=""><br class=""></div><div class="">Regarding the solutions:<span class=""><br class=""><div class=""><br class="">1. Implement this builtin in kernel<br class=""></div></span><div class=""><br class="">&nbsp;&nbsp;&nbsp; I don't believe that is the best place for fixing it. It is not kernel's fault.<br class=""><br class=""></div><span class=""><div class="">2. Alter the code in question so that compiler does not generate the call to builtin<br class=""><br class=""></div></span><div class="">&nbsp;&nbsp; I don't think we have such control. If you check the below above you will se that there is no reference for memcpy and yet the compiler add it.<br class=""><br class="">&nbsp;&nbsp;&nbsp; // clang -target arm-none-gnueabihf -O2 -S -o foo.s foo.c<br class="">&nbsp;&nbsp;&nbsp; struct my_s {<br class="">&nbsp; &nbsp; &nbsp; unsigned long a[18];<br class="">&nbsp;&nbsp;&nbsp; };<br class=""><br class="">&nbsp;&nbsp;&nbsp; void foo(unsigned long *t) {<br class="">&nbsp; &nbsp; &nbsp; *(struct my_s *)t = *((struct my_s *)(1UL));<br class="">&nbsp;&nbsp;&nbsp; }</div><span class=""><div class=""><br class=""></div><div class="">3. Add -fno-builtin-&lt;value&gt; to compiler flags to disable compiler from emitting it</div><br class=""></span></div><div class="">&nbsp;&nbsp; That is what I am doing. I have added a hidden flag on LLVM side "-arm-memcpy". If you set "-arm-memcpy=false" it will not emit them. I will add something like on clang as well. Probably as you suggested and some other sources "-no-builtin-memcpy" and so.<br class=""><br class=""></div><div class="">Regards,<br class=""></div><div class="">Vinicius<br class=""></div><div class="">&nbsp;<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class=""><div class=""><span class=""></span></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><span class=""><div class=""></div></span><div class="">Kind regards,<br class=""></div><div class="">Stefan<br class=""></div><br class=""><br class=""></div></div></div><div class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2015-08-25 10:31 GMT+02:00 Jan-Simon Möller <span dir="ltr" class="">&lt;<a href="mailto:dl9pf@gmx.de" target="_blank" class="">dl9pf@gmx.de</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">See the archives (end of thread "Ugly test fix for eabi-arm.patch") , we just<br class="">
in the last 2 weeks discussed the case that LLVM/clang is wrongly adding the<br class="">
references for these and not<br class="">
obeys the -nostdic / -freestanding&nbsp; flags passed by the kernel's makefiles.<br class="">
<span class=""><font color="#888888" class=""><br class="">
--<br class="">
<br class="">
Dipl.-Ing.<br class="">
Jan-Simon Möller<br class="">
<br class="">
<a href="mailto:jansimon.moeller@gmx.de" target="_blank" class="">jansimon.moeller@gmx.de</a><br class="">
</font></span><div class=""><div class="">On Monday 24 August 2015 23:58:35 Khem Raj wrote:<br class="">
&gt; &gt; On Aug 24, 2015, at 6:14 AM, Fürst Stefan &lt;<a href="mailto:dieb.stefan.96@gmail.com" target="_blank" class="">dieb.stefan.96@gmail.com</a>&gt;<br class="">
&gt; &gt; wrote:<br class="">
&gt; &gt;<br class="">
&gt; &gt; drivers/built-in.o: In function `__video_do_ioctl':<br class="">
&gt; &gt; /home/stefan/llvmlinux/targets/nexus5/src/android_kernel_nexus5/drivers/me<br class="">
&gt; &gt; dia/video/v4l2-ioctl.c:1604: undefined reference to `__aeabi_memclr4'<br class="">
&gt; &gt; make[1]: *** [.tmp_vmlinux1] Error 1<br class="">
&gt; &gt; make: *** [sub-make] Error 2<br class="">
&gt;<br class="">
&gt; This means that compiler is finding a place where it can rely on builtins<br class="">
&gt; function implemented in compiler runtime which is compiler-rt or libgcc<br class="">
&gt; depending upon which runtime you use. if it was a user application, then<br class="">
&gt; simply linking with compiler-rt would have been sufficient but in kernel it<br class="">
&gt; does not require any C runtime and whatever is needed is implemented in<br class="">
&gt; kernel itself. So kernel has a small helper library which implements some<br class="">
&gt; of these builtins, you have two options,<br class="">
&gt;<br class="">
&gt; 1. Implement this builtin in kernel<br class="">
&gt; 2. Alter the code in question so that compiler does not generate the call to<br class="">
&gt; builtin 3. Add -fno-builtin-&lt;value&gt; to compiler flags to disable compiler<br class="">
&gt; from emitting it<br class="">
&gt;<br class="">
&gt; Thanks<br class="">
&gt; -Khem<br class="">
<br class="">
</div></div></blockquote></div><br class=""></div>
</div></div><br class=""></div></div><span class="">_______________________________________________<br class="">
LLVMLinux mailing list<br class="">
<a href="mailto:LLVMLinux@lists.linuxfoundation.org" target="_blank" class="">LLVMLinux@lists.linuxfoundation.org</a><br class="">
<a href="https://lists.linuxfoundation.org/mailman/listinfo/llvmlinux" rel="noreferrer" target="_blank" class="">https://lists.linuxfoundation.org/mailman/listinfo/llvmlinux</a><br class=""></span></blockquote></div><span class=""><font color="#888888" class=""><br class=""><br clear="all" class=""><br class="">-- <br class=""><div class=""><div dir="ltr" class="">Simplicity is the ultimate sophistication<br class=""></div></div>
</font></span></div></div>
</blockquote></div><br class=""></div></div></div></div></div></div>
</blockquote></div></div></div><div class=""><div class="h5"><br class=""><br clear="all" class=""><br class="">-- <br class=""><div class=""><div dir="ltr" class="">Simplicity is the ultimate sophistication<br class=""></div></div>
</div></div></div></div>
</blockquote></div><br class=""></div>
_______________________________________________<br class="">LLVMLinux mailing list<br class=""><a href="mailto:LLVMLinux@lists.linuxfoundation.org" class="">LLVMLinux@lists.linuxfoundation.org</a><br class="">https://lists.linuxfoundation.org/mailman/listinfo/llvmlinux</div></blockquote></div><br class=""></div></body></html>