• Marko Mäkelä's avatar
    MDEV-20386 WITH_MSAN fails due to inline asm · 31e6c96b
    Marko Mäkelä authored
    In commit 94d0bb4d (MDEV-20377)
    we replaced some inline assembler code with calls to GCC-style
    builtin functions. These functions would only be available if
    the target allows SSE4.2 instructions to be used. Hence, the
    cmake -DWITH_MSAN=ON build would fail unless the default x86 (IA-32)
    or AMD64 target was overridden.
    
    It turns out that the problem can be solved by overriding the default
    target architecture for specific functions with the help of GCC function
    attributes.
    
    ut_crc32c_8(), ut_crc32c_64(): Use the compiler-builtin intrinsic
    functions. For GCC before 5, the header file <nmmintrin.h> does not
    really work, and we must keep using the compiler built-in functions.
    
    For the Microsoft compiler, we will keep using <intrin.h> because
    we will also need the definition of the __cpuid() function.
    On GCC and clang, we prefer to invoke inline assembler for that.
    
    Curiously, the inline assembler in has_sse4_2() or crc32_pclmul()
    is not causing any trouble for MSAN. Also, the inline assembler
    in WolfSSL appears to be fine now. Something might have changed
    between clang-8 and clang-10 (10.0.1).
    31e6c96b
ut0crc32.cc 11.7 KB