Skip to content

Conversation

@candrews
Copy link

MSVC doesn't define BMI2 so it must be defined by by CMake. It was being set whenever GGML_BMI2 is set, but that results in a failure (error LNK2019: unresolved external symbol __pdep_u64) when targeting x86 (aka 32 bit) Windows. The fix is to only set BMI2 when targeting amd64.

Make sure to read the contributing guidelines before submitting a PR

MSVC doesn't define __BMI2__ so it must be defined by by CMake. It was being set  whenever GGML_BMI2 is set, but that results in a failure (`error LNK2019: unresolved external symbol __pdep_u64`) when targeting x86 (aka 32 bit) Windows. The fix is to only set __BMI2__ when targeting amd64.
@candrews candrews requested a review from ggerganov as a code owner November 26, 2025 18:16
@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label Nov 26, 2025
@angt
Copy link
Collaborator

angt commented Nov 27, 2025

Thanks!
I don’t know about MSVC, but all the features I see around BMI2 are also AMD64 only.
Can you share more about the target configuration and the build failure?

@candrews
Copy link
Author

Here's a build log in GitHub Actions which I believe provides all that info, demonstrating the failure when targeting win32:
https://github.com/candrews/pywhispercpp/actions/runs/19691916887/job/56409457483#step:5:431

@angt
Copy link
Collaborator

angt commented Nov 27, 2025

Ok i guess it's because of this line:

option(GGML_BMI2 "ggml: enable BMI2" ${INS_ENB})

As a quick hack, maybe you can set the env SOURCE_DATE_EPOCH and select the flags you want?

A normal build gives:

-- x86 detected
-- Adding CPU backend variant ggml-cpu: -msse4.2;-mf16c;-mfma;-mbmi2;-mavx;-mavx2 GGML_SSE42;GGML_F16C;GGML_FMA;GGML_BMI2;GGML_AVX;GGML_AVX2

But with SOURCE_DATE_EPOCH=1:

-- x86 detected
-- Adding CPU backend variant ggml-cpu:

Then add the flags you want (GGML_AVX , etc)

edit: not GGML_AVX2 :)

@candrews
Copy link
Author

That's a workaround, but that won't fix the GGML_CPU_ALL_VARIANTS=1 GGML_BACKEND_DL=1 case, which I'm eager to use :-)

@angt
Copy link
Collaborator

angt commented Nov 27, 2025

after taking a look, i think its just because of the missing -DGGML_NATIVE=OFF flag:

https://github.com/angt/pywhispercpp/actions/runs/19744492579/job/56575850622

code: angt/pywhispercpp@d287338

@angt
Copy link
Collaborator

angt commented Nov 29, 2025

@candrews, can we close this PR?

@candrews
Copy link
Author

candrews commented Dec 2, 2025

@candrews, can we close this PR?

If there's an approach I should be taking that would work, I'm not understanding it, sorry.

I'm trying: CIBW_ENVIRONMENT: CMAKE_ARGS="-DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON" which I believe it what #17528 (comment) advises. However, that still fails:
On Linux, the error is:

  /project/whisper.cpp/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp:36:35: error: ‘HWCAP2_SVE2’ was not declared in this scope; did you mean ‘HWCAP_SVE’?

https://github.com/candrews/pywhispercpp/actions/runs/19846422930/job/56864733852#step:5:449

And on Windows it fails with:

error LNK2019: unresolved external symbol __pdep_u64 referenced in function _ggml_vec_dot_iq1_m_q8_K [D:\a\pywhispercpp\pywhispercpp\build\temp.win32-cpython-39\Release\_pywhispercpp\whisper.cpp\ggml\src\ggml-cpu-skylakex.vcxproj]

https://github.com/candrews/pywhispercpp/actions/runs/19846422930/job/56864733855#step:5:534

Which is the 32 bit Windows problem.

The combination of -DGGML_NATIVE=OFF and -DGGML_CPU_ALL_VARIANTS=ON doesn't make sense to me that seems contradictory. One flag means "make a generic binary, not optimized for the host system" and the other means "make many binaries optimized for separate, specific target systems"

I'm happy to try and test things - thank you very much for working with me on this effort :)

angt added a commit to angt/llama.cpp that referenced this pull request Dec 2, 2025
Align with other HWCAP2 feature flags and define HWCAP2_SVE2 when it's
missing from system headers

See ggml-org#17528

Signed-off-by: Adrien Gallouët <[email protected]>
angt added a commit to angt/llama.cpp that referenced this pull request Dec 2, 2025
This align with other HWCAP2 feature flags

See ggml-org#17528

Signed-off-by: Adrien Gallouët <[email protected]>
@angt
Copy link
Collaborator

angt commented Dec 2, 2025

Here is the diff between our branches:

candrews/pywhispercpp@cpu-all-variants...angt:pywhispercpp:cpu-all-variants

I just made a PR to fix the HWCAP2_SVE2 issue, and the macOS issue is already known. I already had this one on FreeBSD: #17474

ggerganov pushed a commit that referenced this pull request Dec 2, 2025
This align with other HWCAP2 feature flags

See #17528

Signed-off-by: Adrien Gallouët <[email protected]>
@candrews
Copy link
Author

candrews commented Dec 4, 2025

Does #17474 need to make to https://github.com/ggml-org/whisper.cpp as well?

@angt
Copy link
Collaborator

angt commented Dec 4, 2025

Does #17474 need to make to https://github.com/ggml-org/whisper.cpp as well?

Yes, we need to wait the next ggml sync

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants