Index: lib/Core/Reproduce.cpp =================================================================== --- lib/Core/Reproduce.cpp +++ lib/Core/Reproduce.cpp @@ -53,7 +53,9 @@ // Converts path to use unix path separators so the cpio can be extracted on // both unix and windows. static void convertToUnixPathSeparator(SmallString<128> &Path) { +#ifdef LLVM_ON_WIN32 std::replace(Path.begin(), Path.end(), '\\', '/'); +#endif } void CpioFile::append(StringRef Path, StringRef Data) { Index: test/ELF/reproduce-backslash.s =================================================================== --- /dev/null +++ test/ELF/reproduce-backslash.s @@ -0,0 +1,13 @@ +# REQUIRES: x86, cpio, shell + +# Test that we don't erroneously replace \ with / on UNIX, as it's +# legal for a filename to contain backslashes. +# RUN: rm -rf %t.dir +# RUN: mkdir -p %t.dir/build +# RUN: llvm-mc %s -o %t.dir/build/foo\\.o -filetype=obj -triple=x86_64-pc-linux +# RUN: cd %t.dir +# RUN: ld.lld build/foo\\.o --reproduce repro +# RUN: cpio -t < repro.cpio | FileCheck %s + +# CHECK: repro/response.txt +# CHECK: repro/{{.*}}/build/foo\.o