_Builtin_intrinsics.intel module is not available on Windows PC with Intel CPU

I am trying to use swift-png package on Windows PC with Intel CPU. This package uses _Builtin_intrinsics.intel module, which seems to be unavailable on Windows on PC with CPU Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz 2.59 GHz.

Here's error I get:

c:\Users\*****\swift-png\sources\png\dictionary.swift:3:8: error: no such module '_Builtin_intrinsics.intel'
import _Builtin_intrinsics.intel
       ^

Version of swift:

swift --version -v
compnerd.org Swift version 5.7.1 (swift-5.7.1-RELEASE)
Target: x86_64-unknown-windows-msvc
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swift-frontend.exe --version
compnerd.org Swift version 5.7.1 (swift-5.7.1-RELEASE)
Target: x86_64-unknown-windows-msvc

Does unknown appear here because toolchain cannot detect CPU manufacture?

Is above error of missing _Builtin_intrinsics.intel module the consequence of this unknown?

Regards,
Valeriy Van

Seems another problem related to apple/swift#60534, hopefully the workaround provided here can help.

The fix was submitted months before but received no review, cc @mishal_shah @compnerd

you can work around this by disabling x86 intrinsics with the NO_INTRINSICS build flag:

This is what I actually do Add define of NO_INTRINSICS for Windows platform · valeriyvan/swift-png@122f05a · GitHub.

I'll make this PR after you approve/merge 3 other waiting.

But more interesting to make _Builtin_intrinsics.intel module work.

actually on second thought it might be better to exclude windows in the #if os(Windows) in that file because swiftSettings will trip SPM's "unsafe build flags" rule

hi @valeriyvan thanks for your interest in swift-png!

to be honest, the library was in pretty bad shape, and in my opinion, your (giant) PR did not go far enough, so i used it as a starting point for my own (even more expansive) update:

no more symlinked submodules! (what a terrible idea those were…)

i have some more windows fixes in the pipeline here:

let me know if the update works for you! :slight_smile:

Have you tried the workaround here? I checked out v4.0.1 locally and the PNG library can compile with only warnings from “unsupported platform”.

I don’t think this is the correct way to work around though — judging by #if canImport(_Builtin_intrinsics) should be more reliable. The library is fully functional on Windows, just like on other platforms.

1 Like

good point, pushed another PR here: