Commit 4cf189f
committed
shims: add a workaround for
When building for Windows x86, we have a few conspiring issues to
contend with. `__builtin_sqrtf` is treated by clang as a `__builtin_`
prefixed libm call. On windows, there is no libm, with the role being
taken up by ucrt. However, on 32-bit x86 targets, ucrt does not provide
an implementation of `sqrtf` instead defining it inline as a wrapper
which widens the argument to a double precision and invokes `sqrt`, the
result of which is narrowed to the result. This function is locally
defined and expected to be inlined and no out-of-line definition is
provided by ucrt that can be referenced.
Adjusting the shims to use the intrinsics would be the next option
(thanks @stephentyrone!) which would work. However, when building the
standard library, we need to combine the system headers which results in
the use of the MSVCRT headers for `xmmintrin.h` rather than clang. As a
result, we cannot directly use the intrinsics.
Opt to instead open-code the intrinsic path by using the compiler
builtin for sqrt. This both yields the optimal implementation and
avoids providing an additional entry point in the runtime. It also has
code size benefits.
A special thanks to @stephentyrone for all the discussion and help with
this!sqrtf on Windows x861 parent f4e74f7 commit 4cf189f
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
132 | 136 | | |
| 137 | + | |
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
| |||
0 commit comments