JustasMasiulis / xorstr

heavily vectorized c++17 compile time string encryption.
Apache License 2.0
1.19k stars 193 forks source link

error: inlining failed in call to ‘always_inline’ ‘void _mm256_store_si256(__m256i*, __m256i)’: target specific option mismatch #38

Closed BullyWiiPlaza closed 3 years ago

BullyWiiPlaza commented 3 years ago

I've been trying to apply the XOR string to various strings but I ran into a compilation error for GCC if the string is longer than a certain length (15 characters):

std::stringstream string_stream;
string_stream << xorstr_("This is a test "); // Works
string_stream << xorstr_("This is a test a"); // Fails to compile

Error message:

/usr/lib/gcc/x86_64-linux-gnu/10/include/avxintrin.h: In member function ‘void jm::xor_string<T, Keys>::_crypt_256_single(const uint64_t*, uint64_t*) [with T = jm::detail::tstring_<'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ', 't', 'e', 's', 't', ' ', 'a', '\000'>; Keys = {jm::detail::_ki<0, 9086496320168851267>, jm::detail::_ki<1, 8285867810101015964>, jm::detail::_ki<2, 13789257918876304453>, jm::detail::_ki<3, 2926636422472167702>}]’:
/usr/lib/gcc/x86_64-linux-gnu/10/include/avxintrin.h:914:1: error: inlining failed in call to ‘always_inline’ ‘void _mm256_store_si256(__m256i*, __m256i)’: target specific option mismatch
  914 | _mm256_store_si256 (__m256i *__P, __m256i __A)
      | ^~~~~~~~~~~~~~~~~~

Defining JM_XORSTR_DISABLE_AVX_INTRINSICS or not does not matter.

On MSVC this compiles successfully regardless of length so it seems to be a GCC standard library issue related to string length (as indicated by the compilation error).

Any ideas on how to overcome this error for GCC (on Linux)?

JustasMasiulis commented 3 years ago

Are you sure you defined JM_XORSTR_DISABLE_AVX_INTRINSICS correctly? Because the error you linked should only happen with them enabled.

Either way, you could fix this by just settings -march=native (for what your local CPU supports) or whatever CPU series you want that supports AVX2 instruction set.

BullyWiiPlaza commented 3 years ago

Either way, you could fix this by just settings -march=native (for what your local CPU supports) or whatever CPU series you want that supports AVX2 instruction set.

That did the trick, thank you.