<html 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:12.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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">If you’re building with -stdlib=libc++, the Linux toolchain (which is used for e.g. Android) prefers libc++ headers installed alongside the compiler to those in the sysroot:
<a href="https://github.com/llvm/llvm-project/blob/d5f7196feb7da50564c5ad444f5fd3fecf08f340/clang/lib/Driver/ToolChains/Linux.cpp#L892">
https://github.com/llvm/llvm-project/blob/d5f7196feb7da50564c5ad444f5fd3fecf08f340/clang/lib/Driver/ToolChains/Linux.cpp#L892</a>. I have a use case where this doesn’t work: the Android NDK’s version of libc++ uses a different inline namespace, so I want to
 pair it with the corresponding headers from the sysroot, even though my toolchain also contains libc++ headers (for use with other platforms).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I’m looking for a way to turn off searching for libc++ headers installed alongside the compiler but still search for them in the sysroot. The closest I can get right now is building with -nostdinc++ and adding
 a manual -isystem for the sysroot’s libc++ header directory, but that breaks compiles that want to use -nostdinc++ themselves and specify an alternate libc++ header location (since my -isystem will always be present, so you’ll end up with two copies of the
 libc++ headers in your search paths and everything will break).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I can think of two ways to accomplish this. One is to add a new flag (and I’m looking for naming suggestions for this flag) to turn off searching for libc++ headers installed alongside the compiler. The other
 is to promote -cxx-isystem to a driver option, inhibit any -cxx-isystem paths from being added to the search paths when -nostdinc++ is passed, and make sure -cxx-isystem gets put on the include path before everything else (since C++ headers usually #include_next
 into other system headers). What’s the best option here?<o:p></o:p></span></p>
</div>
</body>
</html>