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

    <tr>
        <th>Summary</th>
        <td>
            Flang can't find hypotf on Windows on Arm
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:driver,
            platform:windows
      </td>
    </tr>

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

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

<pre>
    Flang fails to compile this simple snippet (reduced from OpenBLAS by Everton Constantino):
```
! RUN: flang-new.exe hypot.f90 -flang-experimental-exec -o hypot
program hello
    real(4) :: x = 1.e0_4, y = 0.5e0_4
    x = hypot(x,y)
    print *, 'Hello, World!'
end program hello
```
The error message is: "lld-link: error: undefined symbol: hypotf"
Note that `clang-cl.exe` manages to compile an equivalent C snippet. The link command generated by `clang-cl.exe` is very similar to that generated by `flang-new.exe`; however the CC1 command used by `clang-cl.exe` contains `"--dependent-lib=libcmt" "--dependent-lib=oldnames"`, which essentially embeds this information for the linker in the object files (I haven't actually inspected the object files, but removing those flags from the CC1 line results in link-time errors). 
Note that at the moment [we intentionally refrain](https://github.com/llvm/llvm-project/blob/1f550d86b236de88d684aeecfde3cc7738640bb7/clang/lib/Driver/ToolChains/MSVC.cpp#L84) from adding `libcmt` and `oldnames` to flang's linker invocation. Adding them to the linker invocation doesn't seem to solve the issue. OTOH, adding `-defaultlib:libucrt` produces errors about duplicate symbols. We should probably be getting hypotf from some of [MSVC's libraries](https://docs.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=msvc-170), but I'm not entirely sure how.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVU2P2zYQ_TXyhZAgS7ZkH3xwvF0kQJoATdocC0ocWWwoUiUpe_3v-0bybpDt9lBDsPgxnHkz7w3VOHU7PBppz6KT2gQRnWjdMGpDIvY6iKCHEeNg9ThSFEmx86SmlpT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