[lld] r286589 - [ELF] - Use backward slashes inside response files

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 10:41:38 PST 2016


Note that the commit message is the opposite to what this patch does. It
replaces backslashes with forward slashes.

On Fri, Nov 11, 2016 at 5:23 AM, George Rimar via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: grimar
> Date: Fri Nov 11 07:23:13 2016
> New Revision: 286589
>
> URL: http://llvm.org/viewvc/llvm-project?rev=286589&view=rev
> Log:
> [ELF] - Use backward slashes inside response files
>
> Patch replaces forward slashes with backward inside response.txt
>
> This is https://llvm.org/bugs/show_bug.cgi?id=30951.
>
> Differential revision: https://reviews.llvm.org/D26443
>
> Added:
>     lld/trunk/test/ELF/reproduce-windows2.s
> Modified:
>     lld/trunk/lib/Core/Reproduce.cpp
>     lld/trunk/test/lit.cfg
>
> Modified: lld/trunk/lib/Core/Reproduce.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/
> Reproduce.cpp?rev=286589&r1=286588&r2=286589&view=diff
> ============================================================
> ==================
> --- lld/trunk/lib/Core/Reproduce.cpp (original)
> +++ lld/trunk/lib/Core/Reproduce.cpp Fri Nov 11 07:23:13 2016
> @@ -50,6 +50,12 @@ static void writeMember(raw_fd_ostream &
>    OS << Data;                            // c_filedata
>  }
>
> +// Converts path to use unix path separators so the cpio can be extracted
> on
> +// both unix and windows.
> +static void convertToUnixPathSeparator(SmallString<128> &Path) {
> +  std::replace(Path.begin(), Path.end(), '\\', '/');
> +}
> +
>  void CpioFile::append(StringRef Path, StringRef Data) {
>    if (!Seen.insert(Path).second)
>      return;
> @@ -59,10 +65,7 @@ void CpioFile::append(StringRef Path, St
>    // (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(), '\\', '/');
> +  convertToUnixPathSeparator(Fullpath);
>
>    writeMember(*OS, Fullpath, Data);
>
> @@ -76,6 +79,8 @@ void CpioFile::append(StringRef Path, St
>  // 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 +98,7 @@ std::string lld::relativeToRoot(StringRe
>      Res = Root.substr(2);
>
>    path::append(Res, path::relative_path(Abs));
> +  convertToUnixPathSeparator(Res);
>
>    return Res.str();
>  }
>
> Added: lld/trunk/test/ELF/reproduce-windows2.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> reproduce-windows2.s?rev=286589&view=auto
> ============================================================
> ==================
> --- lld/trunk/test/ELF/reproduce-windows2.s (added)
> +++ lld/trunk/test/ELF/reproduce-windows2.s Fri Nov 11 07:23:13 2016
> @@ -0,0 +1,11 @@
> +# REQUIRES: system-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
>
> Modified: lld/trunk/test/lit.cfg
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/lit.
> cfg?rev=286589&r1=286588&r2=286589&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/lit.cfg (original)
> +++ lld/trunk/test/lit.cfg Fri Nov 11 07:23:13 2016
> @@ -207,6 +207,10 @@ if platform.system() in ['Darwin']:
>  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('system-windows')
> +
>  # Set if host-cxxabi's demangler can handle target's symbols.
>  if platform.system() not in ['Windows']:
>      config.available_features.add('demangler')
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161111/e5c72bfc/attachment.html>


More information about the llvm-commits mailing list