<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 21, 2014 at 12:06 AM, Evgeniy Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't this adding builddir/lib to linker search path would be right.<br></blockquote><div><br></div><div>Why not?</div>
<div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Would it make sense to move libc++.so to lib/clang/3.5/lib/linux/?<br></blockquote><div><br></div><div>This is a good question.</div><div><br></div><div>Historically, GCC has considered libstdc++ to be "part of" the compiler or toolchain, and distributed them together. We lookup libstdc++ out of GCC's installation tree for example.</div>
<div><br></div><div>Also historically, libc++ has *not* been distributed as "part of" the compiler or toolchain. On OS X it is actually more part of the OS than the toolchain. Even on Linux, some care has been taken to try to make it effective to use libc++ with a GCC host just as much as with a Clang host.</div>
<div><br></div><div>I'm not trying to endorse either of these approaches, but that's what they have been historically. To my mind, that makes lib/clang/<version> inapropriate for libc++. If we want to switch to shipping libc++ as merely an implementation detail of Clang itself, then I would suggest installing *both* headers and libraries under lib/clang/<version>. But that would be a reasonably radical departure from current trends etc.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On Mon, Jan 20, 2014 at 7:23 PM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
> Hi Chandler,<br>
><br>
> Fixing include paths is not enough - you should also fix library<br>
> lookup paths for dynamic linker in Clang driver. Currently if the<br>
> build tree has both Clang binary and built libc++ like this:<br>
> <...>/bin/clang++<br>
> <...>/lib/libc++.so<br>
><br>
> Clang binary is not able to locate libc++.so with -stdlib=libc++<br>
> provided. Therefore the following brute-force bootstrap process<br>
> wouldn't work:<br>
> (1) configure a new build tree with default options and build Clang and libc++<br>
> (2) configure a new build tree with just-built Clang as c/c++ compiler<br>
> and specify LLVM_ENABLE_LIBCXX=ON<br>
><br>
> I'll try to take a closer look at this (and potentially fix the<br>
> driver) tomorrow, unless someone who has more understanding picks it<br>
> up from here.<br>
><br>
><br>
><br>
> On Mon, Jan 20, 2014 at 1:42 PM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>> wrote:<br>
>> Author: chandlerc<br>
>> Date: Mon Jan 20 03:42:24 2014<br>
>> New Revision: 199632<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=199632&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=199632&view=rev</a><br>
>> Log:<br>
>> Make the Linux support for finding libc++ somewhat less braindead.<br>
>><br>
>> Now instead of just looking in the system root for it, we also look<br>
>> relative to the clang binary's directory. This should "just work" in<br>
>> almost all cases. I've added test cases accordingly.<br>
>><br>
>> This is probably *very* worthwhile to backport to the 3.4 branch so that<br>
>> folks can check it out, build it, and use that as their host compiler<br>
>> going forward.<br>
>><br>
>> Modified:<br>
>>     cfe/trunk/lib/Driver/ToolChains.cpp<br>
>>     cfe/trunk/test/Driver/linux-header-search.cpp<br>
>><br>
>> Modified: cfe/trunk/lib/Driver/ToolChains.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=199632&r1=199631&r2=199632&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=199632&r1=199631&r2=199632&view=diff</a><br>

>> ==============================================================================<br>
>> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)<br>
>> +++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Jan 20 03:42:24 2014<br>
>> @@ -2945,9 +2945,24 @@ void Linux::AddClangCXXStdlibIncludeArgs<br>
>><br>
>>    // Check if libc++ has been enabled and provide its include paths if so.<br>
>>    if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {<br>
>> -    // libc++ is always installed at a fixed path on Linux currently.<br>
>> -    addSystemInclude(DriverArgs, CC1Args,<br>
>> -                     getDriver().SysRoot + "/usr/include/c++/v1");<br>
>> +    const std::string LibCXXIncludePathCandidates[] = {<br>
>> +      // The primary location is within the Clang installation.<br>
>> +      // FIXME: We shouldn't hard code 'v1' here to make Clang future proof to<br>
>> +      // newer ABI versions.<br>
>> +      getDriver().Dir + "/../include/c++/v1",<br>
>> +<br>
>> +      // We also check the system as for a long time this is the only place Clang looked.<br>
>> +      // FIXME: We should really remove this. It doesn't make any sense.<br>
>> +      getDriver().SysRoot + "/usr/include/c++/v1"<br>
>> +    };<br>
>> +    for (unsigned i = 0; i < llvm::array_lengthof(LibCXXIncludePathCandidates);<br>
>> +         ++i) {<br>
>> +      if (!llvm::sys::fs::exists(LibCXXIncludePathCandidates[i]))<br>
>> +        continue;<br>
>> +      // Add the first candidate that exists.<br>
>> +      addSystemInclude(DriverArgs, CC1Args, LibCXXIncludePathCandidates[i]);<br>
>> +      break;<br>
>> +    }<br>
>>      return;<br>
>>    }<br>
>><br>
>> @@ -2971,7 +2986,7 @@ void Linux::AddClangCXXStdlibIncludeArgs<br>
>>                                 MIPSABIDirSuffix, DriverArgs, CC1Args))<br>
>>      return;<br>
>><br>
>> -  const std::string IncludePathCandidates[] = {<br>
>> +  const std::string LibStdCXXIncludePathCandidates[] = {<br>
>>      // Gentoo is weird and places its headers inside the GCC install, so if the<br>
>>      // first attempt to find the headers fails, try these patterns.<br>
>>      InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." +<br>
>> @@ -2984,8 +2999,9 @@ void Linux::AddClangCXXStdlibIncludeArgs<br>
>>      LibDir.str() + "/../include/c++",<br>
>>    };<br>
>><br>
>> -  for (unsigned i = 0; i < llvm::array_lengthof(IncludePathCandidates); ++i) {<br>
>> -    if (addLibStdCXXIncludePaths(IncludePathCandidates[i],<br>
>> +  for (unsigned i = 0; i < llvm::array_lengthof(LibStdCXXIncludePathCandidates);<br>
>> +       ++i) {<br>
>> +    if (addLibStdCXXIncludePaths(LibStdCXXIncludePathCandidates[i],<br>
>>                                   TripleStr + MIPSABIDirSuffix + BiarchSuffix,<br>
>>                                   DriverArgs, CC1Args))<br>
>>        break;<br>
>><br>
>> Modified: cfe/trunk/test/Driver/linux-header-search.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-header-search.cpp?rev=199632&r1=199631&r2=199632&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-header-search.cpp?rev=199632&r1=199631&r2=199632&view=diff</a><br>

>> ==============================================================================<br>
>> --- cfe/trunk/test/Driver/linux-header-search.cpp (original)<br>
>> +++ cfe/trunk/test/Driver/linux-header-search.cpp Mon Jan 20 03:42:24 2014<br>
>> @@ -1,6 +1,29 @@<br>
>>  // General tests that the header search paths detected by the driver and passed<br>
>>  // to CC1 are sane.<br>
>>  //<br>
>> +// Test a simulated installation of libc++ on Linux, both through sysroot and<br>
>> +// the installation path of Clang.<br>
>> +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \<br>
>> +// RUN:     -target x86_64-unknown-linux-gnu \<br>
>> +// RUN:     -stdlib=libc++ \<br>
>> +// RUN:     -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \<br>
>> +// RUN:     --sysroot=%S/Inputs/basic_linux_libcxx_tree \<br>
>> +// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-SYSROOT %s<br>
>> +// CHECK-BASIC-LIBCXX-SYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1"<br>
>> +// CHECK-BASIC-LIBCXX-SYSROOT: "-isysroot" "[[SYSROOT:[^"]+]]"<br>
>> +// CHECK-BASIC-LIBCXX-SYSROOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"<br>
>> +// CHECK-BASIC-LIBCXX-SYSROOT: "-internal-isystem" "[[SYSROOT]]/usr/local/include"<br>
>> +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \<br>
>> +// RUN:     -target x86_64-unknown-linux-gnu \<br>
>> +// RUN:     -stdlib=libc++ \<br>
>> +// RUN:     -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \<br>
>> +// RUN:     --sysroot=%S/Inputs/basic_linux_libcxx_tree \<br>
>> +// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-INSTALL %s<br>
>> +// CHECK-BASIC-LIBCXX-INSTALL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"<br>
>> +// CHECK-BASIC-LIBCXX-INSTALL: "-isysroot" "[[SYSROOT:[^"]+]]"<br>
>> +// CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" "[[SYSROOT]]/usr/bin/../include/c++/v1"<br>
>> +// CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" "[[SYSROOT]]/usr/local/include"<br>
>> +//<br>
>>  // Test a very broken version of multiarch that shipped in Ubuntu 11.04.<br>
>>  // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \<br>
>>  // RUN:     -target i386-unknown-linux \<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
><br>
><br>
> --<br>
> Alexey Samsonov, MSK<br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>