When configuring with CXXFLAGS="-O1 -ggdb -Wall -mno-avx2"
…
configure detects AVX by passing the -mavx -mavx2
flags after CXXFLAGS, so succeeds:
0configure:19622: checking whether C++ compiler accepts -mavx -mavx2
1configure:19641: g++ -std=c++11 -c -O1 -ggdb -Wall -mno-avx2 -Werror -mavx -mavx2 conftest.cpp >&5
2configure:19641: $? = 0
But then the build uses -mavx -mavx2
before CXXFLAGS, which fails:
0/usr/bin/ccache g++ -std=c++11 -DHAVE_CONFIG_H -I. -I../src/config -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DENABLE_AVX2 -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -Wstack-protector -fstack-protector-all -fPIE -mavx -mavx2 -O1 -ggdb -Wall -mno-avx2 -MT crypto/crypto_libbitcoin_crypto_avx2_a-sha256_avx2.o -MD -MP -MF crypto/.deps/crypto_libbitcoin_crypto_avx2_a-sha256_avx2.Tpo -c -o crypto/crypto_libbitcoin_crypto_avx2_a-sha256_avx2.o `test -f 'crypto/sha256_avx2.cpp' || echo './'`crypto/sha256_avx2.cpp
1In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/immintrin.h:43:0,
2 from crypto/sha256_avx2.cpp:4:
3/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/avx2intrin.h: In function ‘__m256i sha256d64_avx2::{anonymous}::Add(__m256i, __m256i)’:
4/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/avx2intrin.h:119:1: error: inlining failed in call to always_inline ‘__m256i _mm256_add_epi32(__m256i, __m256i)’: target specific option mismatch
5 _mm256_add_epi32 (__m256i __A, __m256i __B)
6 ^~~~~~~~~~~~~~~~
7crypto/sha256_avx2.cpp:14:72: note: called from here
8 __m256i inline Add(__m256i x, __m256i y) { return _mm256_add_epi32(x, y); }
9 ^
10make[2]: *** [Makefile:4533: crypto/crypto_libbitcoin_crypto_avx2_a-sha256_avx2.o] Error 1
IMO the better solution is to fix the build (ie, continue to build AVX support even with the contradicting CXXFLAGS) by passing -mavx -mavx2
after CXXFLAGS.