Skip to content

x86 CPUID compile errors on Windows with Clang and GCC compilers #767

@p0lymeric

Description

@p0lymeric

Prerequisites

Description

There are some compilation errors relating to recently added x86 CPUID detection code.

ClangCL (Clang 20.1.8):

  • Looks like <intrin.h> should be included in files that call __cpuid. (I guess MSVC magically recognizes __cpuid without a header, but ClangCL needs the header.)
<...>\cpp\lib\libtomcrypt\src\hashes\sha2\sha256_desc.c(12,4): error : call to undeclared library function '__cpuid' with type 'void (int *, int)'; <...>
<...>\cpp\lib\libtomcrypt\src\hashes\sha2\sha256_desc.c(12,4): message : include the header <intrin.h> or explicitly provide a declaration for '__cpuid' <...>

MinGW-UCRT64 (GCC 15.2.0) / MinGW-Clang64 (Clang 21.1.7):

  • Looks like asm should be changed to __asm__, to allow building without GNU C extensions.
  • I wonder if this issue also manifests on other x86 targets (e.g. Linux) that compile with -std=c##.
<...>/cpp/lib/libtomcrypt/src/hashes/sha2/sha256_desc.c:18:5: error: use of undeclared identifier 'asm'
   18 |     asm volatile ("cpuid"
      |     ^~~

I am open to submitting a fix if desired, or an existing contributor could do so. Thanks for the recent work on adding x86 acceleration to the library.

Version

a68fa19 (top of develop tree May 19)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions