<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/122152>122152</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Driver][Windows] Driver wants to link clang_rt.builtins.lib instead of clang_rt.builtins-x86_64.lib
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Meinersbur
      </td>
    </tr>
</table>

<pre>
    `clang::ToolChain::getCompilerRT(...)` searches for the location of the `clang_rt.builtins` library. It considers the paths with `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON` (`clang_rt.builtins.lib`) as well as `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF` (`clang_rt.builtins-x86_64.lib`). When it does not find it, it falls back to `clang_rt.builtins.lib`.

This might be fine for platforms such as Linux where `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON` is the default, but breaks for platforms where it is off by default. In particular, under Windows the file is usually located under `${prefix}/lib/clang/${version}/lib/windows/clang_rt.builtins-x86_64.lib`. If it is missing (e.g. in non-bootstrap builds), MSVC's toolchain also provides its own version e.g. `C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\lib\clang\18\lib\windows\clang_rt.builtins-x86_64.lib`. Since #87866 the driver tells the linker to use  `clang_rt.builtins.lib` which does not exist in any default configuration under Windows.

Also see https://github.com/llvm/llvm-project/pull/87866#issuecomment-2214034671

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVE1v4zYQ_TX0ZRBBoj4sH3Rw5LgIkGwXWTc5GpQ4kqahSIOk4uTfF5ScTVukQfckiOS8mXnvzQjnqNeIFcuvWb5bickPxlb3SBqtaya7aox8q1gRt0ronqVblm4Pxqh6EKSX3x59bcYTKbQPB8bLKIoY37AiBofCtgM66IwFPyAo0wpPRoPp5v933KP1UT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