[lld] r353300 - Merging r353250:

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 6 06:47:32 PST 2019


Author: hans
Date: Wed Feb  6 06:47:31 2019
New Revision: 353300

URL: http://llvm.org/viewvc/llvm-project?rev=353300&view=rev
Log:
Merging r353250:
------------------------------------------------------------------------
r353250 | zturner | 2019-02-06 01:50:35 +0100 (Wed, 06 Feb 2019) | 24 lines

[PDB] Remove dots and normalize slashes with /PDBSOURCEPATH.

In a previous patch, I made changes so that PDBs which were
generated on non-Windows platforms contained sensical paths
for the host.  While this is an esoteric use case, we need
it to be supported for certain cross compilation scenarios
especially with LLDB, which can debug things on non-Windows
platforms.

However, this regressed a case where you specify /PDBSOURCEPATH
and use a windows-style path.  Previously, we would still remove
dots and canonicalize slashes to backslashes, but since my
change intentionally tried to support non-backslash paths, this
was broken.

This patch fixes the situation by trying to guess which path
style the user is specifying when /PDBSOURCEPATH is passed.
It is intentionally conservative, erring on the side of a
Windows path style unless absolutely certain.  All dots are
removed and slashes canonicalized to whatever the deduced
path style is after appending the file path to the /PDBSOURCEPATH
argument.

Differential Revision: https://reviews.llvm.org/D57769
------------------------------------------------------------------------

Modified:
    lld/branches/release_80/   (props changed)
    lld/branches/release_80/COFF/PDB.cpp
    lld/branches/release_80/test/COFF/pdb-relative-source-lines.test

Propchange: lld/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb  6 06:47:31 2019
@@ -1 +1 @@
-/lld/trunk:351326,351335,351898-351899,352068,352082,352257,352302,352407,352413,352435,352459,352482,352606,352928-352929
+/lld/trunk:351326,351335,351898-351899,352068,352082,352257,352302,352407,352413,352435,352459,352482,352606,352928-352929,353250

Modified: lld/branches/release_80/COFF/PDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/COFF/PDB.cpp?rev=353300&r1=353299&r2=353300&view=diff
==============================================================================
--- lld/branches/release_80/COFF/PDB.cpp (original)
+++ lld/branches/release_80/COFF/PDB.cpp Wed Feb  6 06:47:31 2019
@@ -288,18 +288,24 @@ static void pdbMakeAbsolute(SmallVectorI
   // It's not absolute in any path syntax.  Relative paths necessarily refer to
   // the local file system, so we can make it native without ending up with a
   // nonsensical path.
-  sys::path::native(FileName);
   if (Config->PDBSourcePath.empty()) {
+    sys::path::native(FileName);
     sys::fs::make_absolute(FileName);
     return;
   }
-  // Only apply native and dot removal to the relative file path.  We want to
-  // leave the path the user specified untouched since we assume they specified
-  // it for a reason.
-  sys::path::remove_dots(FileName, /*remove_dot_dots=*/true);
 
+  // Try to guess whether /PDBSOURCEPATH is a unix path or a windows path.
+  // Since PDB's are more of a Windows thing, we make this conservative and only
+  // decide that it's a unix path if we're fairly certain.  Specifically, if
+  // it starts with a forward slash.
   SmallString<128> AbsoluteFileName = Config->PDBSourcePath;
-  sys::path::append(AbsoluteFileName, FileName);
+  sys::path::Style GuessedStyle = AbsoluteFileName.startswith("/")
+                                      ? sys::path::Style::posix
+                                      : sys::path::Style::windows;
+  sys::path::append(AbsoluteFileName, GuessedStyle, FileName);
+  sys::path::native(AbsoluteFileName, GuessedStyle);
+  sys::path::remove_dots(AbsoluteFileName, true, GuessedStyle);
+
   FileName = std::move(AbsoluteFileName);
 }
 

Modified: lld/branches/release_80/test/COFF/pdb-relative-source-lines.test
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/test/COFF/pdb-relative-source-lines.test?rev=353300&r1=353299&r2=353300&view=diff
==============================================================================
--- lld/branches/release_80/test/COFF/pdb-relative-source-lines.test (original)
+++ lld/branches/release_80/test/COFF/pdb-relative-source-lines.test Wed Feb  6 06:47:31 2019
@@ -37,26 +37,26 @@ RUN: llvm-pdbutil pdb2yaml -modules -mod
 RUN: ./lld-link -debug "-pdbsourcepath:/usr/src" -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj
 RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=POSIX %s
 
-CHECK-LABEL:  - Module:          'c:\src{{[\\/]}}pdb_lines_1_relative.obj'
-CHECK-NEXT:     ObjFile:         'c:\src{{[\\/]}}pdb_lines_1_relative.obj'
+CHECK-LABEL:  - Module:          'c:\src\pdb_lines_1_relative.obj'
+CHECK-NEXT:     ObjFile:         'c:\src\pdb_lines_1_relative.obj'
 CHECK:          SourceFiles:
-CHECK-NEXT:       - 'c:\src{{[\\/]}}pdb_lines_1.c'
-CHECK-NEXT:       - 'c:\src{{[\\/]}}foo.h'
+CHECK-NEXT:       - 'c:\src\pdb_lines_1.c'
+CHECK-NEXT:       - 'c:\src\foo.h'
 CHECK:          Subsections:
-CHECK:                - FileName:        'c:\src{{[\\/]}}pdb_lines_1.c'
-CHECK:                - FileName:        'c:\src{{[\\/]}}foo.h'
+CHECK:                - FileName:        'c:\src\pdb_lines_1.c'
+CHECK:                - FileName:        'c:\src\foo.h'
 CHECK:            - !FileChecksums
-CHECK:                - FileName:        'c:\src{{[\\/]}}pdb_lines_1.c'
-CHECK:                - FileName:        'c:\src{{[\\/]}}foo.h'
+CHECK:                - FileName:        'c:\src\pdb_lines_1.c'
+CHECK:                - FileName:        'c:\src\foo.h'
 
-CHECK-LABEL:  - Module:          'c:\src{{[\\/]}}pdb_lines_2_relative.obj'
-CHECK-NEXT:     ObjFile:         'c:\src{{[\\/]}}pdb_lines_2_relative.obj'
+CHECK-LABEL:  - Module:          'c:\src\pdb_lines_2_relative.obj'
+CHECK-NEXT:     ObjFile:         'c:\src\pdb_lines_2_relative.obj'
 CHECK:          SourceFiles:
-CHECK-NEXT:       - 'c:\src{{[\\/]}}pdb_lines_2.c'
+CHECK-NEXT:       - 'c:\src\pdb_lines_2.c'
 CHECK:          Subsections:
-CHECK:                - FileName:        'c:\src{{[\\/]}}pdb_lines_2.c'
+CHECK:                - FileName:        'c:\src\pdb_lines_2.c'
 CHECK:            - !FileChecksums
-CHECK:                - FileName:        'c:\src{{[\\/]}}pdb_lines_2.c'
+CHECK:                - FileName:        'c:\src\pdb_lines_2.c'
 
 CHECK-LABEL:  - Kind:            S_ENVBLOCK
 CHECK-NEXT:     EnvBlockSym:     
@@ -64,33 +64,33 @@ CHECK-NEXT:       Entries:
 CHECK-NEXT:         - cwd
 CHECK-NEXT:         - 'c:\src'
 CHECK-NEXT:         - exe
-CHECK-NEXT:         - 'c:\src{{[\\/]}}lld-link'
+CHECK-NEXT:         - 'c:\src\lld-link'
 CHECK-NEXT:         - pdb 
-CHECK-NEXT:         - 'c:\src{{[\\/]}}out.pdb'
+CHECK-NEXT:         - 'c:\src\out.pdb'
 CHECK-NEXT:         - cmd
 CHECK-NEXT:         - '-debug -pdbsourcepath:c:\src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj'
 
 
-POSIX-LABEL:  - Module:          '/usr/src{{[\\/]}}pdb_lines_1_relative.obj'
-POSIX-NEXT:     ObjFile:         '/usr/src{{[\\/]}}pdb_lines_1_relative.obj'
+POSIX-LABEL:  - Module:          '/usr/src/pdb_lines_1_relative.obj'
+POSIX-NEXT:     ObjFile:         '/usr/src/pdb_lines_1_relative.obj'
 POSIX:          SourceFiles:
-POSIX-NEXT:       - '/usr/src{{[\\/]}}pdb_lines_1.c'
-POSIX-NEXT:       - '/usr/src{{[\\/]}}foo.h'
+POSIX-NEXT:       - '/usr/src/pdb_lines_1.c'
+POSIX-NEXT:       - '/usr/src/foo.h'
 POSIX:          Subsections:
-POSIX:                - FileName:        '/usr/src{{[\\/]}}pdb_lines_1.c'
-POSIX:                - FileName:        '/usr/src{{[\\/]}}foo.h'
+POSIX:                - FileName:        '/usr/src/pdb_lines_1.c'
+POSIX:                - FileName:        '/usr/src/foo.h'
 POSIX:            - !FileChecksums
-POSIX:                - FileName:        '/usr/src{{[\\/]}}pdb_lines_1.c'
-POSIX:                - FileName:        '/usr/src{{[\\/]}}foo.h'
+POSIX:                - FileName:        '/usr/src/pdb_lines_1.c'
+POSIX:                - FileName:        '/usr/src/foo.h'
 
-POSIX-LABEL:  - Module:          '/usr/src{{[\\/]}}pdb_lines_2_relative.obj'
-POSIX-NEXT:     ObjFile:         '/usr/src{{[\\/]}}pdb_lines_2_relative.obj'
+POSIX-LABEL:  - Module:          '/usr/src/pdb_lines_2_relative.obj'
+POSIX-NEXT:     ObjFile:         '/usr/src/pdb_lines_2_relative.obj'
 POSIX:          SourceFiles:
-POSIX-NEXT:       - '/usr/src{{[\\/]}}pdb_lines_2.c'
+POSIX-NEXT:       - '/usr/src/pdb_lines_2.c'
 POSIX:          Subsections:
-POSIX:                - FileName:        '/usr/src{{[\\/]}}pdb_lines_2.c'
+POSIX:                - FileName:        '/usr/src/pdb_lines_2.c'
 POSIX:            - !FileChecksums
-POSIX:                - FileName:        '/usr/src{{[\\/]}}pdb_lines_2.c'
+POSIX:                - FileName:        '/usr/src/pdb_lines_2.c'
 
 POSIX-LABEL:  - Kind:            S_ENVBLOCK
 POSIX-NEXT:     EnvBlockSym:     
@@ -98,8 +98,8 @@ POSIX-NEXT:       Entries:
 POSIX-NEXT:         - cwd
 POSIX-NEXT:         - '/usr/src'
 POSIX-NEXT:         - exe
-POSIX-NEXT:         - '/usr/src{{[\\/]}}lld-link'
+POSIX-NEXT:         - '/usr/src/lld-link'
 POSIX-NEXT:         - pdb 
-POSIX-NEXT:         - '/usr/src{{[\\/]}}out.pdb'
+POSIX-NEXT:         - '/usr/src/out.pdb'
 POSIX-NEXT:         - cmd
 POSIX-NEXT:         - '-debug -pdbsourcepath:/usr/src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj'




More information about the llvm-commits mailing list