<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;}
/* 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:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
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-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="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I suspect most of your issues are related to Clang not understanding the triple you want, and falling back to host-related defaults.<o:p></o:p></p>
<p class="MsoNormal">You can tell cmake `-DLLVM_DEFAULT_TARGET_TRIPLE=mips-sgi-irix` so at least that part would be your default. And once you define the triple components, you can set up a ToolChain in the driver that can probably set up most or all of the
rest of that stuff.<o:p></o:p></p>
<p class="MsoNormal">HTH,<o:p></o:p></p>
<p class="MsoNormal">--paulr<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> cfe-dev <cfe-dev-bounces@lists.llvm.org> <b>On Behalf Of
</b>Chris Hanson via cfe-dev<br>
<b>Sent:</b> Wednesday, November 6, 2019 3:11 PM<br>
<b>To:</b> cfe-dev@lists.llvm.org<br>
<b>Subject:</b> [cfe-dev] Forcing default target, linker, includes<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve built clang, compiler_rt, and lld on Linux from LLVM master as of last night targeting MIPS like so:<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">cmake \<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> -G Ninja \<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> $CMHPROJECTS/llvm-project/llvm \<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;lld" \<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> -DCMAKE_INSTALL_PREFIX="/opt/llvm-mips" \<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> -DLLVM_TARGETS_TO_BUILD="Mips"<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">ninja -j8 -k8<o:p></o:p></p>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">(A couple things fail to link but clang, lld, etc. do get built.)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Unfortunately the built clang does two things I don’t want: It looks in my Linux system’s / for headers even when I specify -isysroot and it uses my Linux system’s ld instead of the built lld even when I specify -fuse-ld=lld.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Are there CMake flags that I can use to force the built clang to only ever use headers from the provided sysroot? (And of course, I’d love the same for forcing lld to only look in sysroot for libraries.) How about CMake flags to force the
built clang to only use its paired lld?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I also have to specify a number of options to get the (IRIX MIPS IV n64 ABI) code generation I desire; I’m compiling hello.c in my LLVM build directory with:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<blockquote style="margin-left:30.0pt;margin-right:0in">
<blockquote style="margin-left:30.0pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">./bin/clang -g --std=c99 -D_LANGUAGE_C=1 -D__sgi=1 -D_SGIAPI=1 -D_SGI_SOURCE=1 -D_MIPSABI_SOURCE=1 --target=mips-sgi-irix -march=mips4 -m64 -isysroot $IRIXSDK -isystem $IRIXSDK/usr/include -c hello.c<o:p></o:p></p>
</div>
</div>
</blockquote>
</blockquote>
</blockquote>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Obviously the target tuple mips-sgi-irix isn’t supported, it does at least result in MIPS codegen and the rest winds up getting me MIPS IV n64. If I eventually add support for the sgi-irix part of the target tuple I know I can easily make
it imply the preprocessor macros, but is that also necessary to force the use of the MIPS n64 ABI? Or is there some other way to select which MIPS ABI that I get? And is there a CMake option I can use to make all of that the default for the built clang?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> — Chris<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Sent from my iPad<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>