<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><br><div><div>On Jun 3, 2014, at 1:35 PM, Rick Mann <<a href="mailto:rmann@latencyzero.com">rmann@latencyzero.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">The host is the latest released OS X. I do not have a working sysroot; that's what I'm trying to achieve. I thought compiler-rt was part of getting that into shape.<br></div></blockquote><br></div><div><br></div><div><br></div><div><div>‘sysroot’ is not your toolchain. sysroot is the rough equivalent of an Apple SDK. That is where your system headers and libraries are located so that the compiler can find them. I have successfully built a mac/clang cross compiler for powerpc-unknown-linux. I got my sysroot out of the yocto/openembedded project build for my board. If you don’t have a sysroot, you can probably create one just by creating a directory on OSX that contains the contents of /usr/include and /usr/lib and maybe /lib.</div><div><br></div><div>What worked for me was to:</div><div><br></div><div><br></div><div>1) build clang for OSX (host platform) as usual. </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>a) configure it to install into a specific directory that will hold your tool chain.</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>b) compile a simple program for OSX and make sure that works.</div><div>2) setup your sysroot in some way.</div><div>3) determine from clang the target triplet it requires. mine is 'powerpc-unknown-linux’</div><div>4) get the source code for binutils. There are online tutorials for cross compiling binutils. </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>a) configure it to target your platform as the default platform. If you don’t, it will assume OSX is the target and not build pieces like ‘ld’. use the triplet from #3</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>b) when you configure, set the PREFIX value so that you don’t install it into your OSX system</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>c) install it. you end up with a directory that has all the pieces staged.</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>d) manually merge those pieces into the directory you have clang installed</div><div><br></div><div>5) set up a simple C program that includes nothing. just have a main function that returns argc;</div><div>6) get that to build. here is my redacted compile line to show you how to call your compiler:</div><div><br></div><div><br></div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">“<some path>/linux_toolchain_root_3.8/bin/clang++" -target powerpc-unknown-linux -m32 -mcpu=e500v2 --sysroot="<some path>/linux_sysroot_3.8" -I "<some path>/linux_sysroot_3.8/usr/include/c++" -I "<some path>/usr/include/c++/powerpc-fsl_networking-linux-gnuspe" -ggdb -Os -std=gnu++11 -MD -MP -pthread -c "../../Embedded/SysCommon/<a href="http://VSysLog.cc">VSysLog.cc</a>" -o "../../Embedded/SysCommon/VSysLog.o"</div></div><div><br></div><div><br></div><div><br></div><div>redacted linker line:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">“<some path>/linux_toolchain_root_3.8/bin/clang++" main.o whatever.o ... -lgcc_s -lstdc++ -lrt -lpthread -target powerpc-unknown-linux --sysroot=“<some path>/linux_sysroot_3.8" -stdlib=libstdc++ -std=gnu++11 -o SuperNodeDmxUpdater.elf</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div>“<some path>” just means some arbitrary path. depends on how you want to structure your layout.</div><div><br></div><div><br></div><div><br></div><div>I don’t believe I’m using compiler-rt. I don’t see it in my toolchain or sysroot. I don’t recall doing anything special to build it. It was straightforward to set up clang and llvm. My strategy is to use my platform’s runtime rather than what comes with llvm & clang. The unwinder library doesn’t work on linux. that is why you see me using -lgcc_s. I believe that that component is supplied by libgcc in my setup. If I do a verbose link, I get…</div><div><br></div><div><br></div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">“<some path>/linux_toolchain_root_3.8/bin/powerpc-unknown-linux-ld" —sysroot=<some path>/linux_sysroot_3.8 --eh-frame-hdr -m elf32ppclinux -dynamic-linker /lib/ld.so.1 -o myexe <some path>/linux_sysroot_3.8/usr/lib/crt1.o <some path>/linux_sysroot_3.8/usr/lib/crti.o <some path>/linux_sysroot_3.8/usr/lib/crtbegin.o -L<some path>/linux_sysroot_3.8/lib -L<some path>/linux_sysroot_3.8/usr/lib <some path>/main.o ... -lgcc_s -lstdc++ -lrt -lpthread -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc <some path> linux_sysroot_3.8/usr/lib/crtend.o <some path>/linux_sysroot_3.8/usr/lib/crtn.o</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div>7) when you go to build a simple program, you’ll get errors telling you what is missing, you then have to find those missing elements and adjust your compile/linker lines to find them. In some cases, I added symlinks to my sysroot tree to map low-level runtime files like <span style="font-family: Menlo; font-size: 11px;">crt1.o to where my toolchain was expecting to find them.</span></div><div><span style="font-family: Menlo; font-size: 11px;"><br></span></div><div><span style="font-family: Menlo; font-size: 11px;">8) keep using trial and error until you can build a c++ program with dependencies.</span></div><div><span style="font-family: Menlo; font-size: 11px;"><br></span></div><div><span style="font-family: Menlo; font-size: 11px;"><br></span></div><div><font face="Menlo"><span style="font-size: 11px;">9) I did get libc++ to build using the libstdc++.so option and with the system’s unwinder (libgcc_s). I haven’t tested it out yet. I had a little trouble with libc++ because I don’t speak CMAKE. So, I had to unravel some of that to get all the compiler/linker flags right. When you get to that stage, let me know and I’ll give you my notes. I made it a point to take notes by the time I got to libc++.</span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;">Hopefully, this will give you enough info to muddle your way through it. it isn’t hard, but it can be hard to know where to go since there is no one authoritative list of steps. You have to look at all the tutorials and documentation and cherry-pick what you need as you go.</span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;">-James</span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div><br></div><div><br></div><br></body></html>