Skip to content

popcnt intrinsic error when building for arm 32 bit on Windows with MSVC #465

Description

@rpavlik

Just updated our project from 1.6.0 to 2.1.0 and our arm builds broke.

Build error:

conformance_framework_basisu.lib(basisu_transcoder.cpp.obj) : error LNK2019: unresolved external symbol __popcnt referenced in function "void __cdecl basist::astc_6x6_hdr::fast_encode_bc6h_2subsets(unsigned short const *,struct basist::vec3F const *,float const *,double &,struct basist::bc6h_logical_block &,__int64,int,int,int,float,float,float,struct basist::astc_6x6_hdr::fast_bc6h_params const &)" (?fast_encode_bc6h_2subsets@astc_6x6_hdr@basist@@YAXPBGPBUvec3F@2@PBMAANAAUbc6h_logical_block@2@_JHHHMMMABUfast_bc6h_params@12@@Z)
conformance_framework_basisu.lib(basisu_transcoder.cpp.obj) : error LNK2019: unresolved external symbol __popcnt16 referenced in function "int __cdecl basist::bc7f::pick_3subset_pat_index(unsigned char const *,unsigned int &)" (?pick_3subset_pat_index@bc7f@basist@@YAHPBEAAI@Z)
src\conformance\conformance_test\conformance_test.dll : fatal error LNK1120: 2 unresolved externals

In the default branch, there is relevant code here: https://github.com/BinomialLLC/basis_universal/blob/master/encoder/basisu_astc_ldr_fencode.h#L13 I think in the 2.1.0 we're using, it's coming from zstd.

and the docs for the intrinsic are here: https://learn.microsoft.com/en-us/cpp/intrinsics/popcnt16-popcnt-popcnt64?view=msvc-170

It's not super clear from the docs, but it is clear from the headers: in intrin0.inl.h, _popcnt and __popcnt16 are wrapped with a "__MACHINEX86_X64_ARM64" macro, while __popcnt64 is wrapped with "__MACHINEARM64_X64". I'm looking at headers from MSVC 14.44.35207 (looks like CI is actually back on MSVC 19.43.34810.0), which should contain 32-bit arm support (and which builds arm32 just fine previously to the upgrade MR).

What is the preferred way of handling this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions