<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
{font-family:"Book Antiqua";
panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.gmail-m4479191712290079065msoplaintext, li.gmail-m4479191712290079065msoplaintext, div.gmail-m4479191712290079065msoplaintext
{mso-style-name:gmail-m_4479191712290079065msoplaintext;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
p.gmail-m4479191712290079065msolistparagraph, li.gmail-m4479191712290079065msolistparagraph, div.gmail-m4479191712290079065msolistparagraph
{mso-style-name:gmail-m_4479191712290079065msolistparagraph;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Book Antiqua",serif;
font-variant:normal !important;
color:windowtext;
text-transform:none;
font-weight:normal;
font-style:normal;
text-decoration:none none;
vertical-align:baseline;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-IE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'>Thanks Brian, these are helpful pointers.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'> MartinO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Brian Cain [mailto:brian.cain@gmail.com] <br><b>Sent:</b> 24 March 2017 03:04<br><b>To:</b> Martin J. O'Riordan <martin.oriordan@movidius.com><br><b>Cc:</b> LLVM Developers <llvm-dev@lists.llvm.org><br><b>Subject:</b> Re: [llvm-dev] Building LLVM on Linux, executing on Windows 10 Linux Subsystem<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Wed, Mar 22, 2017 at 10:29 AM, Martin J. O'Riordan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'>Our out-of-tree LLVM compiler is configured and built on Linux, but I cannot get it to run under the Windows 10 Linux Subsystem.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'>When run in this context it reports a crash:</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'> </span><o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>warning: Error disabling address space randomisation: Success<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>warning: linux_ptrace_test_ret_to_nx: PTRACE_KILL waitpid returned -1: <o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>Interrupted system call<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'> <o:p></o:p></p></div></div></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#24292E'>The above messages are due to a bug in how windows handles ptrace(PTRACE_GETSIGINFO). I think if you downgrade gdb you might not see this error. Does it still segfault when you don't run it in the debugger? Can you do your compile with "-###" and see the "clang -cc1" command and run that one separately?</span><o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>Program received signal SIGSEGV, Segmentation fault.<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>0x0000000003b31e1b in __ctype_init ()<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>(gdb) bt<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>#0 0x0000000003b31e1b in __ctype_init ()<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>#1 0x0000000003b2ed4e in __libc_start_main ()<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>#2 0x00000000004022ad in _start ()<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>(gdb) list<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>302<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'><<i>myPathTo</i>>/llvm/tools/clang/tools/driver/driver.cpp: <o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>No such file or directory.<o:p></o:p></p><p class=gmail-m4479191712290079065msoplaintext style='margin-left:36.0pt'>(gdb)<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'>However, the Linux version from the LLVM website works perfectly, so it must be something to do with how I am configuring LLVM. The following are the OS and tool versions I am using:</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'> </span><o:p></o:p></p></div></div></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Would it work any better if you tried building the compiler natively with this unique configuration on WSL? If it did it might help you isolate the problem.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Also, Microsoft looks like they have a history of reviewing and addressing compatibility bugs just like this one on their GH repo. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>e.g. <a href="https://github.com/Microsoft/BashOnWindows/issues/1373">https://github.com/Microsoft/BashOnWindows/issues/1373</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Sometimes it comes down to them not quite supporting a particular critical syscall quite the same way it behaves on linux.<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=gmail-m4479191712290079065msolistparagraph><span style='font-family:Symbol;color:black'>·</span><span style='font-size:7.0pt;color:black'> </span><span style='font-family:"Book Antiqua",serif;color:black'>CentOS Linux release 7.1.1503 (Core)</span><o:p></o:p></p><p class=gmail-m4479191712290079065msolistparagraph><span style='font-family:Symbol;color:black'>·</span><span style='font-size:7.0pt;color:black'> </span><span style='font-family:"Book Antiqua",serif;color:black'>gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)</span><o:p></o:p></p><p class=gmail-m4479191712290079065msolistparagraph><span style='font-family:Symbol;color:black'>·</span><span style='font-size:7.0pt;color:black'> </span><span style='font-family:"Book Antiqua",serif;color:black'>cmake version 3.5.2</span><o:p></o:p></p><p class=gmail-m4479191712290079065msolistparagraph><span style='font-family:Symbol;color:black'>·</span><span style='font-size:7.0pt;color:black'> </span><span style='font-family:"Book Antiqua",serif;color:black'>GNU Make 3.82</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'>and I am configuring with the following options:</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:36.0pt'><span style='font-family:"Courier New";color:black'>mkdir -p build/linux64</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:36.0pt'><span style='font-family:"Courier New";color:black'>cd build/linux64</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:36.0pt'><span style='font-family:"Courier New";color:black'>cmake -Wno-dev -G “Unix Makefiles” ../../llvm \</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:72.0pt'><span style='font-family:"Courier New";color:black'>"-DCMAKE_BUILD_TYPE:STRING=Debug" \</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:72.0pt'><span style='font-family:"Courier New";color:black'>"-DCMAKE_INSTALL_PREFIX:STRING=$(CLANG_INSTALL_ROOT)/Debug" \</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:72.0pt'><span style='font-family:"Courier New";color:black;background:yellow'>"-DCMAKE_EXE_EXPORTS_C_FLAG:STRING=" \</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:72.0pt'><span style='font-family:"Courier New";color:black;background:yellow'>"-DCMAKE_EXE_EXPORTS_CXX_FLAG:STRING=" \</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:72.0pt'><span style='font-family:"Courier New";color:black;background:yellow'>"-DCMAKE_EXE_LINKER_FLAGS:STRING=-static-libgcc -static-libstdc++ -static" \</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:72.0pt'><span style='font-family:"Courier New";color:black'>-DLLVM_TARGETS_TO_BUILD="OURTARGET" \</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:72.0pt'><span style='font-family:"Courier New";color:black'>-DLLVM_DEFAULT_TARGET_TRIPLE=ourtarget</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'>Only the <span style='background:yellow'>highlighted</span> options are perhaps unusual as I need to build with statically linked GCC libraries, and the ‘</span><span style='font-family:"Courier New";color:black'>DCMAKE_EXE_EXPORTS</span><span style='font-family:"Book Antiqua",serif;color:black'>’ flags were required to prevent another problem with dynamic libraries, though I have forgotten what this was now.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua",serif;color:black'>The resulting compiler works perfectly on Linux, but when I run the same binary in the Windows 10 Linux Subsystem, I get the crash report above.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><o:p> </o:p></p></div></div></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>It's always a good idea to make sure your environment matches when you're comparing two different systems. "env -i clang++ test_case.cpp" on both can help neutralize any funny business that might creep in.<o:p></o:p></p></div></div></div></div></body></html>