[lld] r267497 - [ELF] Introduce --reproduce flag.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 26 11:18:14 PDT 2016
On Tue, Apr 26, 2016 at 11:04 AM, Rui Ueyama <ruiu at google.com> wrote:
> I think we want to implement what Reid suggested, but at the same time we
> need to fix the code in LLD so that it will concatenate two paths while
> stripping the drive letter from the second path. I'll send patches shortly.
>
> On Tue, Apr 26, 2016 at 10:27 AM, Rui Ueyama <ruiu at google.com> wrote:
>>
>> It wouldn't work if your current drive is different from the directory
>> where the LLVM source code is in. I'm not sure why it is failing, so I'll
>> try to reproduce the issue locally on my Windows machine. Please hold on.
>>
>> On Tue, Apr 26, 2016 at 10:11 AM, Davide Italiano via llvm-commits
>> <llvm-commits at lists.llvm.org> wrote:
>>>
>>> On Tue, Apr 26, 2016 at 9:47 AM, Reid Kleckner <rnk at google.com> wrote:
>>> > My best idea is to add a new lit substitution, like %:t, meaning "the
>>> > path
>>> > %t without the driver separator colon".
>>> >
>>>
>>> I can go and implement it. I'll just wait if anybody raises an objection.
>>> Thanks Reid!
>>>
>>> --
>>> Davide
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>>
>
This is the fix I have locally:
diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp
index 5298159..c43b9d3 100644
--- a/ELF/Driver.cpp
+++ b/ELF/Driver.cpp
@@ -98,16 +98,33 @@ LinkerDriver::getArchiveMembers(MemoryBufferRef MB) {
return V;
}
+std::string appendDir(StringRef A, StringRef B) {
+ SmallString<128> PathName;
+
+ // Replace root name on Windows. When we try to append two paths both
+ // have drive name and the resulting path is invalid. Transform the second
+ // path in this way:
+ // c: -> /c
+ if (sys::path::has_root_name(B)) {
+ std::string N;
+ N += "/";
+ N += B[0];
+ N += B.substr(2);
+ sys::path::append(PathName, A, N);
+ } else {
+ sys::path::append(PathName, A, B);
+ }
+ return PathName.str();
+}
+
static void dumpFile(StringRef SrcPath) {
- SmallString<128> DirName;
- sys::path::append(DirName, Config->Reproduce,
sys::path::parent_path(SrcPath));
+ std::string DirName = appendDir(Config->Reproduce,
sys::path::parent_path(SrcPath));
if (std::error_code EC = sys::fs::create_directories(DirName)) {
error(EC, "--reproduce: can't create directory");
return;
}
- SmallString<128> DestPathName;
- sys::path::append(DestPathName, Config->Reproduce, SrcPath);
+ std::string DestPathName = appendDir(Config->Reproduce, SrcPath);
if (std::error_code EC = sys::fs::copy_file(SrcPath, DestPathName))
error(EC, "--reproduce: can't copy file");
}
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the llvm-commits
mailing list