Windows x86-64 Clang compiler fails to compile because of lacking -mavx2
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 2.4k
- Forks
- 363
- PR merge metrics
- No merged PRs in 30d
Description
I'm compileing flac on Windows x86-64 with Clang version 17.0.1 and targeting at x86_64-pc-windows-msvc with Visual Studio 2022 installed. This is the command I used to configure:
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DWITH_OGG=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DBUILD_DOCS=OFF -DINSTALL_MANPAGES=OFF -DINSTALL_PKGCONFIG_MODULES=OFF -DCMAKE_INSTALL_PREFIX="D:\flac"
and I got the error
C:/Users/Administrator/Downloads/Compressed/flac-master/src/libFLAC/stream_encoder_intrin_avx2.c:65:5: error: use of undeclared identifier '__m256i'
65 | __m256i sum256 = _mm256_setzero_si256();
| ^
C:/Users/Administrator/Downloads/Compressed/flac-master/src/libFLAC/stream_encoder_intrin_avx2.c:70:6: error: use of undeclared identifier '__m256i'
70 | __m256i res256 = _mm256_abs_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(residual+residual_sample)));
|
It seems you need to add compile flag -mavx2 to the compiler, where I add the -DCMAKE_CXX_FLAGS="-mavx2" -DCMAKE_C_FLAGS="-mavx2" to the command and everthing works well.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/libFLAC/stream_encoder_intrin_avx2.c around the reported __m256i errors, then inspect the CMake configuration used for Windows x86-64 builds. Reproduce the Ninja/Clang configuration without manually adding -mavx2, and verify that the build succeeds with the project’s normal configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cmake
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100