Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-11-09 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

r252514


Repository:
  rL LLVM

http://reviews.llvm.org/D12382



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
eugenis marked an inline comment as done.
eugenis added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D12382



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
eugenis set the repository for this revision to rL LLVM.
eugenis updated this revision to Diff 39587.

Repository:
  rL LLVM

http://reviews.llvm.org/D12382

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/bin/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/include/c++/v1/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/include/c++/v2/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/lib/.keep
  test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/bin/.keep
  
test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/include/c++/4.8/backward/.keep
  
test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/include/c++/v1/.keep
  
test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/include/c++/v2/.keep
  test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/lib/.keep
  test/Driver/linux-header-search.cpp

Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -26,6 +26,42 @@
 // CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/bin/../include/c++/v1"
 // CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
 //
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxxv2_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXXV2-SYSROOT %s
+// CHECK-BASIC-LIBCXXV2-SYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-BASIC-LIBCXXV2-SYSROOT: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-BASIC-LIBCXXV2-SYSROOT: "-internal-isystem" 
"[[SYSROOT]]/usr/include/c++/v2"
+// CHECK-BASIC-LIBCXXV2-SYSROOT: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxxv2_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxxv2_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXXV2-INSTALL %s
+// CHECK-BASIC-LIBCXXV2-INSTALL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-BASIC-LIBCXXV2-INSTALL: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-BASIC-LIBCXXV2-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/bin/../include/c++/v2"
+// CHECK-BASIC-LIBCXXV2-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
+//
+// Test Linux with both libc++ and libstdc++ installed.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libstdcxx_libcxxv2_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT %s
+// CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT: "-internal-isystem" 
"[[SYSROOT]]/usr/include/c++/v2"
+// CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
+//
 // Test a very broken version of multiarch that shipped in Ubuntu 11.04.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target i386-unknown-linux \
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3846,6 +3846,25 @@
 }
 
 
+static std::string DetectLibcxxIncludePath(StringRef base) {
+  std::error_code EC;
+  int MaxVersion = 0;
+  std::string MaxVersionString = "";
+  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
+   LI = LI.increment(EC)) {
+StringRef VersionText = llvm::sys::path::filename(LI->path());
+int Version;
+if (VersionText[0] == 'v' &&
+!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+  if (Version > MaxVersion) {
+MaxVersion = Version;
+MaxVersionString = VersionText;
+  }
+}
+  }
+  return MaxVersion ? (base + "/" + MaxVersionString).str() : "";
+}
+
 void Linux::AddClangCXXStdlibIncludeArgs(const ArgList ,
  ArgStringList ) const {
   if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
@@ -3855,17 +3874,14 @@
   // Check if libc++ has been enabled and provide its include paths if so.
   if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
 const std::string LibCXXIncludePathCandidates[] = {
-// The primary location is within the Clang installation.
-// 

Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-10-26 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

LGTM



Comment at: lib/Driver/ToolChains.cpp:3545
@@ +3544,3 @@
+!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+  if (Version > MaxVersion) {
+MaxVersion = Version;

Since you've got logic here to pick the newest headers, you should also have a 
tree that has both `usr/include/c++/v1` and `usr/include/c++/v2` to test that 
part of this change.

It's probably also a good idea to have a tree laid out as if libstdc++ and 
libc++ were both installed, i.e. both `usr/include/c++/v1` and 
`usr/include/c++/5.0` in it.


http://reviews.llvm.org/D12382



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-10-26 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

ping
We will need this when libc++ is bumped to v2. There are no plans to do this 
AFAIK but the ABI version macros are in so it is possible and clang should be 
ready.


http://reviews.llvm.org/D12382



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-08-26 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added reviewers: mclow.lists, EricWF, rsmith.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

This goes with the ABI versioning support in libc++ in 
http://reviews.llvm.org/D11740

Repository:
  rL LLVM

http://reviews.llvm.org/D12382

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/bin/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/include/c++/v2/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/lib/.keep
  test/Driver/linux-header-search.cpp

Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -26,6 +26,29 @@
 // CHECK-BASIC-LIBCXX-INSTALL: -internal-isystem 
[[SYSROOT]]/usr/bin/../include/c++/v1
 // CHECK-BASIC-LIBCXX-INSTALL: -internal-isystem 
[[SYSROOT]]/usr/local/include
 //
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 21 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxxv2_tree \
+// RUN: --gcc-toolchain= \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXXV2-SYSROOT %s
+// CHECK-BASIC-LIBCXXV2-SYSROOT: {{[^]*}}clang{{[^]*}} -cc1
+// CHECK-BASIC-LIBCXXV2-SYSROOT: -isysroot [[SYSROOT:[^]+]]
+// CHECK-BASIC-LIBCXXV2-SYSROOT: -internal-isystem 
[[SYSROOT]]/usr/include/c++/v2
+// CHECK-BASIC-LIBCXXV2-SYSROOT: -internal-isystem 
[[SYSROOT]]/usr/local/include
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 21 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxxv2_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxxv2_tree \
+// RUN: --gcc-toolchain= \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXXV2-INSTALL %s
+// CHECK-BASIC-LIBCXXV2-INSTALL: {{[^]*}}clang{{[^]*}} -cc1
+// CHECK-BASIC-LIBCXXV2-INSTALL: -isysroot [[SYSROOT:[^]+]]
+// CHECK-BASIC-LIBCXXV2-INSTALL: -internal-isystem 
[[SYSROOT]]/usr/bin/../include/c++/v2
+// CHECK-BASIC-LIBCXXV2-INSTALL: -internal-isystem 
[[SYSROOT]]/usr/local/include
+//
 // Test a very broken version of multiarch that shipped in Ubuntu 11.04.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 21 \
 // RUN: -target i386-unknown-linux \
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3532,6 +3532,25 @@
   return true;
 }
 
+static std::string DetectLibcxxIncludePath(const std::string base) {
+  std::error_code EC;
+  int MaxVersion = 0;
+  std::string MaxVersionString = ;
+  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC  LI != LE;
+   LI = LI.increment(EC)) {
+StringRef VersionText = llvm::sys::path::filename(LI-path());
+int Version;
+if (VersionText[0] == 'v' 
+!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+  if (Version  MaxVersion) {
+MaxVersion = Version;
+MaxVersionString = VersionText;
+  }
+}
+  }
+  return MaxVersion ? base + / + MaxVersionString : ;
+}
+
 void Linux::AddClangCXXStdlibIncludeArgs(const ArgList DriverArgs,
  ArgStringList CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
@@ -3544,14 +3563,14 @@
 // The primary location is within the Clang installation.
 // FIXME: We shouldn't hard code 'v1' here to make Clang future proof 
to
 // newer ABI versions.
-getDriver().Dir + /../include/c++/v1,
+DetectLibcxxIncludePath(getDriver().Dir + /../include/c++),
 
 // We also check the system as for a long time this is the only place
 // Clang looked.
 // FIXME: We should really remove this. It doesn't make any sense.
-getDriver().SysRoot + /usr/include/c++/v1};
+DetectLibcxxIncludePath(getDriver().SysRoot + /usr/include/c++)};
 for (const auto IncludePath : LibCXXIncludePathCandidates) {
-  if (!llvm::sys::fs::exists(IncludePath))
+  if (IncludePath.empty() || !llvm::sys::fs::exists(IncludePath))
 continue;
   // Add the first candidate that exists.
   addSystemInclude(DriverArgs, CC1Args, IncludePath);


Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -26,6 +26,29 @@
 // CHECK-BASIC-LIBCXX-INSTALL: -internal-isystem [[SYSROOT]]/usr/bin/../include/c++/v1
 // CHECK-BASIC-LIBCXX-INSTALL: -internal-isystem [[SYSROOT]]/usr/local/include
 //
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 21 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN:  

Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-08-26 Thread Evgeniy Stepanov via cfe-commits
eugenis marked 2 inline comments as done.
eugenis added a comment.

http://reviews.llvm.org/D12382



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-08-26 Thread Evgeniy Stepanov via cfe-commits
eugenis removed rL LLVM as the repository for this revision.
eugenis updated this revision to Diff 33259.

http://reviews.llvm.org/D12382

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/bin/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/include/c++/v2/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/lib/.keep
  test/Driver/linux-header-search.cpp

Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -26,6 +26,29 @@
 // CHECK-BASIC-LIBCXX-INSTALL: -internal-isystem 
[[SYSROOT]]/usr/bin/../include/c++/v1
 // CHECK-BASIC-LIBCXX-INSTALL: -internal-isystem 
[[SYSROOT]]/usr/local/include
 //
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 21 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxxv2_tree \
+// RUN: --gcc-toolchain= \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXXV2-SYSROOT %s
+// CHECK-BASIC-LIBCXXV2-SYSROOT: {{[^]*}}clang{{[^]*}} -cc1
+// CHECK-BASIC-LIBCXXV2-SYSROOT: -isysroot [[SYSROOT:[^]+]]
+// CHECK-BASIC-LIBCXXV2-SYSROOT: -internal-isystem 
[[SYSROOT]]/usr/include/c++/v2
+// CHECK-BASIC-LIBCXXV2-SYSROOT: -internal-isystem 
[[SYSROOT]]/usr/local/include
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 21 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxxv2_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxxv2_tree \
+// RUN: --gcc-toolchain= \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXXV2-INSTALL %s
+// CHECK-BASIC-LIBCXXV2-INSTALL: {{[^]*}}clang{{[^]*}} -cc1
+// CHECK-BASIC-LIBCXXV2-INSTALL: -isysroot [[SYSROOT:[^]+]]
+// CHECK-BASIC-LIBCXXV2-INSTALL: -internal-isystem 
[[SYSROOT]]/usr/bin/../include/c++/v2
+// CHECK-BASIC-LIBCXXV2-INSTALL: -internal-isystem 
[[SYSROOT]]/usr/local/include
+//
 // Test a very broken version of multiarch that shipped in Ubuntu 11.04.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 21 \
 // RUN: -target i386-unknown-linux \
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3532,6 +3532,25 @@
   return true;
 }
 
+static std::string DetectLibcxxIncludePath(StringRef base) {
+  std::error_code EC;
+  int MaxVersion = 0;
+  std::string MaxVersionString = ;
+  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC  LI != LE;
+   LI = LI.increment(EC)) {
+StringRef VersionText = llvm::sys::path::filename(LI-path());
+int Version;
+if (VersionText[0] == 'v' 
+!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+  if (Version  MaxVersion) {
+MaxVersion = Version;
+MaxVersionString = VersionText;
+  }
+}
+  }
+  return MaxVersion ? (base + / + MaxVersionString).str() : ;
+}
+
 void Linux::AddClangCXXStdlibIncludeArgs(const ArgList DriverArgs,
  ArgStringList CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
@@ -3542,16 +3561,14 @@
   if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
 const std::string LibCXXIncludePathCandidates[] = {
 // The primary location is within the Clang installation.
-// FIXME: We shouldn't hard code 'v1' here to make Clang future proof 
to
-// newer ABI versions.
-getDriver().Dir + /../include/c++/v1,
+DetectLibcxxIncludePath(getDriver().Dir + /../include/c++),
 
 // We also check the system as for a long time this is the only place
 // Clang looked.
 // FIXME: We should really remove this. It doesn't make any sense.
-getDriver().SysRoot + /usr/include/c++/v1};
+DetectLibcxxIncludePath(getDriver().SysRoot + /usr/include/c++)};
 for (const auto IncludePath : LibCXXIncludePathCandidates) {
-  if (!llvm::sys::fs::exists(IncludePath))
+  if (IncludePath.empty() || !llvm::sys::fs::exists(IncludePath))
 continue;
   // Add the first candidate that exists.
   addSystemInclude(DriverArgs, CC1Args, IncludePath);


Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -26,6 +26,29 @@
 // CHECK-BASIC-LIBCXX-INSTALL: -internal-isystem [[SYSROOT]]/usr/bin/../include/c++/v1
 // CHECK-BASIC-LIBCXX-INSTALL: -internal-isystem [[SYSROOT]]/usr/local/include
 //
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 21 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir