[PATCH] D147256: [DebugInfo] Fix file path separator when targeting windows.

Zequan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 11 09:08:33 PDT 2023


zequanwu added a comment.

In D147256#4257797 <https://reviews.llvm.org/D147256#4257797>, @hans wrote:

> In D147256#4249527 <https://reviews.llvm.org/D147256#4249527>, @zequanwu wrote:
>
>> - Add a `-use-target-path-separator` flag for llc.
>> - Add test for llc with that flag.
>
> But where does `TM.Options.ObjectFilenameForDebug` come from? Presumably it comes from Clang at some point, so is there any chance we can fix it "at the source" instead?

`TM.Options.ObjectFilenameForDebug` either comes from llc's `-o` or clang-cl's `object-file-name=` which is translated from `/Fo[ObjectFileName]`.

For Chromium, the `/Fo[ObjectFileName]` we pass to clang-cl is the same when building on Windows and targeting Windows from Linux. The problem comes `llvm::sys::path::remove_dots(PathStore, /*remove_dot_dot=*/true);` in `CodeViewDebug.cpp`. That function always convert the path to use host's path separator. And I don't think we can write a `remove_dots` function that doesn't change path separator, because `\` can only be used as path separator on Windows but is a valid path character on Linux.

Or we could just not use `llvm::sys::path::remove_dots`, use the user's input as it is for object file path.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147256/new/

https://reviews.llvm.org/D147256



More information about the cfe-commits mailing list