<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 11, 2015 at 9:13 AM, Chao Yan <span dir="ltr"><<a href="mailto:yanchao2012@gmail.com" target="_blank">yanchao2012@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><h1 style="margin:0px 0px 1em;padding:0px;border:0px;font-size:21px;line-height:1.3;word-wrap:break-word;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">Purpose:</h1><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">I implemented a pass on LLVM backend that changes the output format of <em style="margin:0px;padding:0px;border:0px">ARM</em> assembly/binary (e.g add a jump at the end of each basic block to eliminate fall through). By calling:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">llc -march=arm somefile.bc
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">it generates expected arm assembly/binary that runs properly on arm gnu linux (I use qemu-arm and gem5 to simulate it). Now I want to do the same thing on standard c library, but here are problems. </p><h1 style="margin:0px 0px 1em;padding:0px;border:0px;font-size:21px;line-height:1.3;word-wrap:break-word;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">Problems:</h1><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">According to:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><a href="http://article.gmane.org/gmane.comp.compilers.llvm.devel/77025" target="_blank">http://article.gmane.org/gmane.comp.compilers.llvm.devel/77025</a> 
<a href="https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_14/docs/OpenProjects.html#glibc" target="_blank">https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_14/docs/OpenProjects.html#glibc</a>   
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">compiling glibc using llvm may not be a proper option. </p></div></blockquote><div>Not an option /yet/, but it's a work in progress, by the sounds of it. Kostya's been working on it recently & it sounds like there's one or two things in the source code to tackle, then some build issues?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">On the other hand, according to:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-January/047088.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-January/047088.html</a>
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">llvm could be able to compile newlib, thus people consider newlib as an alternative. However, according to:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><a href="http://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#id2711887" target="_blank">http://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#id2711887</a>
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">newlib intends to support binaries for bare metal (no OS) software. It implements only the hardware independent parts (e.g libc and libm) and leave a stub for each hardware dependent syscall (e.g everything in libgloss). </p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">In fact I tried to compile a simple "hello world" c program using arm-none-eabi-gcc which was configured with "--with-newlib" option, the program execution ends up with segmentation faults on both qemu-arm and gem5. </p><h1 style="margin:0px 0px 1em;padding:0px;border:0px;font-size:21px;line-height:1.3;word-wrap:break-word;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">Questions:</h1><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">I'm not sure if the newlib is compatible with glibc. I'm wondering if I could use llvm to cross-compile the machine independent parts (at the same time change the arm output format) from newlib and use arm-none-linux-gnueabi-gcc to cross-compile the machine dependent parts from glibc and put these two parts together to generate my own standard c library?</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19px">There might be mistakes/misunderstandings in my work. Are there any other possible methods that could add my changes to at least part of the standard c libraries, and make the program run on qemu-arm or gem5?</p></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div></div>