[PATCH] D44447: Treat libclang_rt.* as normal library if the user uses --sysroot=

2018-03-16 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

Will it work on Windows? If sysroot is provided, `Prefix` is "-l", but I'm not 
sure that link.exe accepts "-l" notation.


Repository:
  rC Clang

https://reviews.llvm.org/D7



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


[PATCH] D44447: Treat libclang_rt.* as normal library if the user uses --sysroot=

2018-03-13 Thread Tom Rix via Phabricator via cfe-commits
trixirt created this revision.
trixirt added reviewers: rsmith, atanasyan, vkalintiris.
trixirt added a project: clang.
Herald added a subscriber: cfe-commits.

In cross compiling, one normally assumes that the user supplied sysroot 
contains all of the libraries needed in the link.  And so the linker adjusts 
the -L paths to look in the sysroot.
However because libclang_rt.* is supplied at link time as a full path, the link 
can not find it in the sysroot.

This change will churn the user's current experience and the unit tests.
I will take take of the tests, if folks are ok with the change.


Repository:
  rC Clang

https://reviews.llvm.org/D7

Files:
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -356,11 +356,17 @@
   TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
-  const char *Prefix = IsITANMSVCWindows ? "" : "lib";
-  const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
+  const char *Prefix = "-l";
+  const char *Suffix = "";
+  SmallString<128> Path;
+
+  if (getDriver().SysRoot.empty()) {
+Prefix = IsITANMSVCWindows ? "" : "lib";
+Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
+Path = getCompilerRTPath();
+  }
 
-  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -356,11 +356,17 @@
   TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
-  const char *Prefix = IsITANMSVCWindows ? "" : "lib";
-  const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
+  const char *Prefix = "-l";
+  const char *Suffix = "";
+  SmallString<128> Path;
+
+  if (getDriver().SysRoot.empty()) {
+Prefix = IsITANMSVCWindows ? "" : "lib";
+Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
+Path = getCompilerRTPath();
+  }
 
-  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits