<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=us-ascii">
<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:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
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-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">This seems to be related to:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><a href="https://bugs.llvm.org/show_bug.cgi?id=38025">https://bugs.llvm.org/show_bug.cgi?id=38025</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">/Riyaz<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Riyaz Puthiyapurayil <br>
<b>Sent:</b> Sunday, January 27, 2019 1:14 PM<br>
<b>To:</b> llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> Building libclang_rt.* results in error with -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:14.0pt">Building 32-bit libclang_rt.*.so libraries result in error when cmake is invoked with -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON. The error is due to a link line for 32-bit libclang_rt.*.so using libclang_rt.builtins-x86_64.a
instead of libclang_rt.builtins-i386.a. I am making an in-tree build of LLVM, clang, libc++ and compiler-rt (version 7.0.0). The compiler used for building is clang 5.0.2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">FAILED: lib64/clang/7.0.0/lib/linux/libclang_rt.ubsan_standalone-i386.so</span><span style="font-size:14.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt">….<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib64/clang/5.0.2/lib/linux/libclang_rt.builtins-x86_64.a(udivdi3.c.o)' is incompatible with i386 output<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib64/clang/5.0.2/lib/linux/libclang_rt.builtins-x86_64.a(udivmoddi4.c.o)' is incompatible with i386 output<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib64/clang/5.0.2/lib/linux/libclang_rt.builtins-x86_64.a(umoddi3.c.o)' is incompatible with i386 output<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt">I traced the problem to the following in projects/compiler-rt/cmake/config-ix.cmake (which was not there in version 5.0 of compiler-rt).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">if (COMPILER_RT_USE_BUILTINS_LIBRARY)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"> include(HandleCompilerRT)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"> <span style="background:yellow;mso-highlight:yellow">
find_compiler_rt_library(builtins COMPILER_RT_BUILTINS_LIBRARY)</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">else()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"> if (ANDROID)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"> check_library_exists(gcc __gcc_personality_v0 "" COMPILER_RT_HAS_GCC_LIB)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"> else()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"> check_library_exists(gcc_s __gcc_personality_v0 "" COMPILER_RT_HAS_GCC_S_LIB)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"> endif()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">endif()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt">find_compiler_rt_library set COMPILER_RT_BUILTINS_LIBRARY to …/libclang_rt.builtins-x86_64.a regardless of the architecture. This library then gets added to the sanitizer libs link line. There is an attempt
to specify the architecture in find_compiler_rt_library by passing –target=CMAKE_CXX_COMPILER_TARGET but I am not sure where that is supposed to be set. I cannot set it from my own cmake command line because I am building a 64-bit clang with both 64-bit and
32-bit target libraries. Building it this way worked without any issues in LLVM 5.0.
<b>But with 7.0, the intent seems to be use COMPILER_RT_USE_BUILTINS_LIBRARY but it does not set COMPILER_RT_BUILTINS_LIBRARY based on architecture of the output file (i.e. use libclang_rt.builtins-x86_64.a for creating libclang_rt.ubsan.standalone-x86_64.so
and libclang_rt.builtins-i386.a for creating libclang_rt.ubsan.standalone-i386.so).<o:p></o:p></b></span></p>
<p class="MsoNormal"><b><span style="font-size:14.0pt"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><span style="font-size:14.0pt">Any suggestions how to fix this cleanly? Or is there anything I should set besides or in lieu of COMPILER_RT_USE_BUILTINS_LIBRARY on cmake command line. Note that I want to make a self-contained clang/llvm
build with no dependencies on libgcc. This was something I was able to do with 5.0.0 with SANITIZER_USE_COMPILER_RT but that seems to not work anymore.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt"><o:p> </o:p></span></p>
</div>
</body>
</html>