[DebugInfo] Fix file path separator when targeting windows.
authorZequan Wu <zequanwu@google.com>
Thu, 30 Mar 2023 19:01:21 +0000 (15:01 -0400)
committerZequan Wu <zequanwu@google.com>
Mon, 17 Apr 2023 17:07:42 +0000 (13:07 -0400)
commitab8f622c79b27bc606da043e8dcbd417b8ade725
tree3bedfa0ddf71791be883538825e865d5f3e78a70
parent676a96f768e1101ed5187c7751e56e1e11ebe593
[DebugInfo] Fix file path separator when targeting windows.

This fixes two problems:

1. When crossing compiling for windows on linux, source file path in debug info is concatenated with directory by host native separator ('/'). For windows local build, they are concatenated by '\'. This causes non-determinism bug.

  The solution here is to let `LangOptions.UseTargetPathSeparator` to control if we should use host native separator or not.

2. Objectfile path in CodeView also uses host native separator when generated.

 It's fixed by changing the path separator in `/Fo` to '\' if the path is not an absolute path when adding the `-object-file-name=` flag.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D147256
clang/include/clang/Basic/LangOptions.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/debug-info-slash.c [new file with mode: 0644]
clang/test/Driver/cl-outputs.c
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp