Would it be possible to remove Clang dependencies from swift-numerics?

Since Swift Playgrounds 4 on iPad won’t allow any package dependencies that have non-Swift code in them, I’m wondering how feasible it is to separate whatever C dependencies that the swift-numerics package currently has. When I try to import any of the three products from the package I get

The target type, “ClangTarget”, is not supported.

I can’t figure out what is there that’s not pure Swift. I see a bunch of CMake files but no actual C code in the repository. Anybody with more familiarity with the project know what’s in there that’s not pure Swift?


Numerics depends on the _NumericsShims target, which is a header-only C library, providing bindings for the underlying system math library and relaxed floating-point operations that cannot currently be expressed in pure Swift.

1 Like

Is that true as of Swift 5.9? What is Swift missing to make it work?

Yes, this is still true as for Swift 5.9.

All the shims that wrap __builtin_* could be replaced now (now that the Builtin module is exposed), but there's still a bunch of shims that wrap operations that are not just builtins.

We can add additional operations to the Builtin module to support this and eventually eliminate the shims, but Swift 5.9 does not have everything that we would need.


I found the C code in the repo and it’s a lot of functions.

1 Like