llvm-windres fails on quad-`\` containing paths on windows.
When trying to build a profiled hls on windows like this:
andi@Ryzen MINGW64 ~/repos/haskell-language-server
$ cabal build -w /c/ghcup/ghcup/bin/ghc-9.4.1.exe --enable-profiling -j1 exe:haskell-language-server -v
I get this error:
llvm-rc: Error in 24 statement (ID 1):
No such file or directory
ghc-9.4.1.exe: `llvm-windres.exe' failed in phase `Windres'. (Exit code: 1)
Which is the product of an invocation like this:
$ "C:\ghcup\ghcup\ghc\9.4.1\lib\../mingw/bin/llvm-windres.exe" "--input=C:\ghc\msys64\tmp\ghc78568_0\ghc_6.rc" "--output=C:\ghc\msys64\tmp\ghc78568_0\ghc_7.p_o" "--output-format=coff"
llvm-rc: Error in 24 statement (ID 1):
No such file or directory
Where the input .rc file looks like this:
1 24 MOVEABLE PURE "C:\\\\ghc\\\\msys64\\\\home\\\\andi\\\\repos\\\\haskell-language-server\\\\dist-newstyle\\\\build\\\\x86_64-windows\\\\ghc-9.4.2\\\\haskell-language-server-1.8.0.0\\\\x\\\\haskell-language-server\\\\build\\\\haskell-language-server\\\\haskell-language-server.exe.manifest"
Essentially \
having been quoted twice.
Replacing \\\\
with \\
in that file allows llvm-windres to run as expected. I'm not sure if that is a shortcomming of llvm-windres or how we quote paths.
A path containing \\\\
works for tools like ls
. But I'm not sure if these tools are just lenient in the input they accept or if double slashes are valid path separators on windows.
At least powershell accepts (seemingly) arbitrary amounts of slashes:
PS C:\Users\andi> cd .\\\\\\anaconda3\
PS C:\Users\andi\anaconda3>
So perhaps an upstream bug.