Index: lib/Core/Reproduce.cpp =================================================================== --- lib/Core/Reproduce.cpp +++ lib/Core/Reproduce.cpp @@ -76,6 +76,8 @@ // Makes a given pathname an absolute path first, and then remove // beginning /. For example, "../foo.o" is converted to "home/john/foo.o", // assuming that the current directory is "/home/john/bar". +// Returned string is a backslash-separated path even on Windows to avoid +// a mess with backslash-as-escape and backslash-as-path-separator. std::string lld::relativeToRoot(StringRef Path) { SmallString<128> Abs = Path; if (sys::fs::make_absolute(Abs)) @@ -93,6 +95,7 @@ Res = Root.substr(2); path::append(Res, path::relative_path(Abs)); + std::replace(Res.begin(), Res.end(), '\\', '/'); return Res.str(); } Index: test/ELF/reproduce-windows2.s =================================================================== --- test/ELF/reproduce-windows2.s +++ test/ELF/reproduce-windows2.s @@ -0,0 +1,11 @@ +# REQUIRES: windows, x86, cpio + +# Test that a response.txt file always uses / instead of \. +# 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: echo "*response.txt" > list.txt +# RUN: cpio -i --to-stdout --pattern-file=list.txt < repro.cpio | FileCheck %s +# CHECK: {{.*}}/build/foo.o Index: test/lit.cfg =================================================================== --- test/lit.cfg +++ test/lit.cfg @@ -207,6 +207,10 @@ if platform.system() in ['FreeBSD', 'Linux']: config.available_features.add('system-linker-elf') +# Running on Windows +if platform.system() in ['Windows']: + config.available_features.add('windows') + # Set if host-cxxabi's demangler can handle target's symbols. if platform.system() not in ['Windows']: config.available_features.add('demangler')