Use / instead of \ on windows created cpio files

Otherwise when extracting these files on a unix system one
ends up with files named like "repro\bar\foo.o".

llvm-svn: 274622
This commit is contained in:
Rafael Espindola 2016-07-06 12:09:51 +00:00
parent c359d5ca08
commit 1f6929bff6
2 changed files with 9 additions and 2 deletions

View File

@ -152,6 +152,11 @@ void CpioFile::append(StringRef Path, StringRef Data) {
// (i.e. in that case we are creating baz.cpio.)
SmallString<128> Fullpath;
path::append(Fullpath, Basename, Path);
// Use unix path separators so the cpio can be extracted on both unix and
// windows.
std::replace(Fullpath.begin(), Fullpath.end(), '\\', '/');
writeMember(*OS, Fullpath, Data);
// Print the trailer and seek back.

View File

@ -6,5 +6,7 @@
# RUN: llvm-mc %s -o %t.dir/build/foo.o -filetype=obj -triple=x86_64-pc-linux
# RUN: cd %t.dir
# RUN: not ld.lld build/foo.o --reproduce repro
# RUN: cpio -t < repro.cpio | grep -F 'repro\response.txt'
# RUN: cpio -t < repro.cpio | grep -F 'repro\%:t.dir\build\foo.o'
# RUN: cpio -t < repro.cpio | FileCheck %s
# CHECK: repro/response.txt
# CHECK: repro/{{.*}}/build/foo.o