[cfe-dev] Patch to find libc++ in the prefix/lib directory
Joseph Galbraith
galb at vandyke.com
Thu May 10 17:15:14 PDT 2012
Hi,
I have attached a patch that allowed me to use libc++
installed in the same prefix as I installed clang+llvm
on ubuntu 12.04 . ($HOME/local for example.)
I would be surprised if it is correct :-) But hopefully
it isn't to hard to fix it up into something usable if someone has
some advice on what would be correct. (Though I will be offline for
a week starting Saturday.)
Thanks,
Joseph
-------------- next part --------------
Index: lib/Frontend/InitHeaderSearch.cpp
===================================================================
--- lib/Frontend/InitHeaderSearch.cpp (revision 156545)
+++ lib/Frontend/InitHeaderSearch.cpp (working copy)
@@ -213,7 +213,7 @@
break;
default:
// FIXME: temporary hack: hard-coded paths.
- AddPath("/usr/local/include", System, true, false, false);
+ AddPath(LLVM_INCLUDEDIR, System, true, false, false);
break;
}
}
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp (revision 156545)
+++ lib/Driver/ToolChains.cpp (working copy)
@@ -2073,6 +2073,20 @@
}
addPathIfExists(SysRoot + "/lib", Paths);
addPathIfExists(SysRoot + "/usr/lib", Paths);
+
+ std::string InstallPath(SysRoot + LLVM_LIBDIR);
+ bool AlreadyThere = false;
+ for (ToolChain::path_list::const_iterator it = Paths.begin(),
+ ie = Paths.end(); it != ie; ++it) {
+ if ( *it == InstallPath )
+ {
+ AlreadyThere = true;
+ break;
+ }
+ }
+
+ if ( ! AlreadyThere )
+ addPathIfExists(InstallPath, Paths);
}
bool Linux::HasNativeLLVMSupport() const {
@@ -2238,7 +2252,7 @@
if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
// libc++ is always installed at a fixed path on Linux currently.
addSystemInclude(DriverArgs, CC1Args,
- getDriver().SysRoot + "/usr/include/c++/v1");
+ getDriver().SysRoot + LLVM_INCLUDEDIR + "/c++/v1");
return;
}
Index: include/clang/Config/config.h.in
===================================================================
--- include/clang/Config/config.h.in (revision 156545)
+++ include/clang/Config/config.h.in (working copy)
@@ -21,4 +21,10 @@
/* Directory where gcc is installed. */
#undef GCC_INSTALL_PREFIX
+/* Installation directory for include files */
+#undef LLVM_INCLUDEDIR
+
+/* Installation directory for libraries */
+#undef LLVM_LIBDIR
+
#endif
Index: include/clang/Config/config.h.cmake
===================================================================
--- include/clang/Config/config.h.cmake (revision 156545)
+++ include/clang/Config/config.h.cmake (working copy)
@@ -12,3 +12,10 @@
/* Directory where gcc is installed. */
#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}"
+
+/* Installation directory for include files */
+#cmakedefine LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}"
+
+/* Installation directory for libraries */
+#cmakedefine LLVM_LIBDIR "${LLVM_LIBDIR}"
+
More information about the cfe-dev
mailing list