<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/126954>126954</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lld-link library search should be case-insensitive for compatibility with MSVC artifacts
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld:COFF
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rnk
</td>
</tr>
</table>
<pre>
MSVC tools produce `.obj` files that refer to `MSVCRT`, `OLDNAMES`, and `LIBCMT`, but they distribute files with lower-cased names:
```
$ cl -c t.cpp && dumpbin -directives t.obj | grep -i defaul
Microsoft (R) C/C++ Optimizing Compiler Version 19.41.34123 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
t.cpp
/DEFAULTLIB:libcpmt
/DEFAULTLIB:LIBCMT
/DEFAULTLIB:OLDNAMES
$ cl -MD -c t.cpp && dumpbin -directives t.obj | grep -i defaul
Microsoft (R) C/C++ Optimizing Compiler Version 19.41.34123 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
t.cpp
/DEFAULTLIB:msvcprt
/DEFAULTLIB:MSVCRT
/DEFAULTLIB:OLDNAMES
$ ls /c/Program\ Files/Microsoft\ Visual\ Studio/2022/Professional/VC/Tools/MSVC/14.41.34120/lib/x64/
aligned_new.lib libcmt.lib msvcmrtd.lib
...
clang_rt.fuzzer_MT-x86_64.lib libconcrtd1.amd64.pdb oldnames.lib
```
Clang and LLVM use lower-cased filenames for auto-linking:
```
$ git grep -i oldnames ../clang ../llvm
../clang/lib/Driver/ToolChains/Clang.cpp: CmdArgs.push_back("--dependent-lib=oldnames");
...
```
This presents a portability problem when cross-linking for Windows from Linux or other case-sensitive platforms. Ideally, LLD should be able to handle MSVC-produced artifacts as they are. We could make this as simple as checking for lower-cased filenames as part of our `findFile` implementation.
I was almost certain there was already an issue covering this, but github issue search isn't that great, and I hoped that as I started to file this one, it would magically point me to "similar issues", but I've made it this far and it hasn't done that yet, so I'm hitting Create...
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkVsFu2zgQ_Rr6MrAgU7YTH3xQ5AoI4GwXTTY9BpQ4kthQpEBSdt2vXwwlO2iRw943CGCJ1AzfPL43pPBetQZxzzYPbHNYiDF01u2deV9UVl72T8-vBQRrtYfBWTnWCGybJrb6wbYpNEqjh9CJAA4bdBAsTVPQtxe2TRkv6P3r8fBX_vTleR4RRtLo8fGheLp-VY0BQocXkMoHp6ox4Jz9rEIH2p7RLWvhUYIRPXqW5SzNKXj6T3PG11BrgGUNIamHAQAY3zK-BTn2Q6UMLKVyWAd1IsxUArC7AlqHAywVSGzEqFmaP6naWW-bAIzff2N8BwXjZcH4A-MP8HUIqle_lGmhsP2gNDp4ReeVNbDaJetVkq1XPIPGOvi5XbM0L-xwcartYr6C8n2sUFg3WCeCsiaBXGuIH3pw6NGdUCZUWJrHgliax5rKw5cy_-f4cnx8YFmuVVUPfaDJP6dmgj8Nu21JzD9zt3w6_O_46_2pHtyn_M0y_o_8aU8f1YyXfzvbOtGzTQElSZjx8oaYBl-VH4Wmp-cwSmUZL3nK-RTZoCcuhGa8fCXiXsh8lOI5vq7WV45SxkutKsZL4omXLM2FJjPLN4PnRKsKSBx9iI9UZ--CpBeW5klC1NRamPbNhaQZf_1C9_b0svx5v33brm_R1tQuyFUierldJ4Os4PpntYxOnBP-ZsU0LyhzdPrx-PoEo8ffPEzWjtFxn8UY7FIr865M-7mxWxVuQrsuDElChMeF4qPWpz6Wdh2-EXRw6oRuJrPohDLEaMQYlZHlUPQyd61PhtF3b5Wo3xm_Z5wvlxIHNBJNWFKu7HBdntGO7Vj2cGPzDwpeOkVNEz2a4EHAYF0QldIqXKiXVhp7OHdogKThr_VHQr4rI-3ZQ-NsD0dlxp9gHdjQoQMicOnReEVOhEGL0FjX-wQeJQqtL9ROj8cD-M6OWkKFICqN1Jo7YaRGICUt524uQbigGlETRD-1YOEwge8IdYzvxTtCoFqEB6_6QSM91R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