llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.09k stars 12k forks source link

[LLD] lld-link does not handle paths with backslashes correctly #55948

Open alexchandel opened 2 years ago

alexchandel commented 2 years ago

When targeting Windows/MSVC, many build tools pass call link.exe (=> lld-link) with paths with backslashes.

LLD does not handle these correctly. For example, passing the global library path /libpath:\opt\sysroot\windows\…etc…\lib\um\x64 to lld-link causes it look for the file \opt\sysroot\windows\…etc…\lib\um\x64. lld-link should behave like link.exe does, and handle paths with backslashes, converting this to /opt/sysroot/windows/…etc…/lib/um/x64, if that path exists.

llvmbot commented 2 years ago

@llvm/issue-subscribers-lld-coff

rnk commented 2 years ago

Can you expand on the context for this? As I understand it, on Windows, if you run cd \Users\rnk, it will work. \Users\rnk is a relative (ish?) path based in the current working drive (usually C:). So, if LLD is looking for C:\opt\sysroot\..., I think that's intended behavior. How would changing the slash direction make LLD behave any differently? Slash direction is generally interchangeable for most APIs, just not some command line tools.

mstorsjo commented 2 years ago

Given the path /opt/sysroot/... that you're referencing, are you running lld-link on unix, and passing it the option /libpath:\opt\sysroot\... there?