Thermadiag/seq

Compiler errors gcc-12.2.0

foolnotion opened this issue · 4 comments

Hi,

There's a couple of compile errors with gcc-12.2.0

First, an include seems to be missing:

cmake --build build
[ 14%] Building CXX object CMakeFiles/seq.dir/seq/internal/block_codec.cpp.o
[ 28%] Building CXX object CMakeFiles/seq.dir/seq/internal/lz4small.cpp.o
[ 42%] Building CXX object CMakeFiles/seq.dir/seq/internal/transpose.cpp.o
[ 57%] Building CXX object CMakeFiles/seq.dir/seq/internal/charconv.cpp.o
In file included from /home/bogdb/seq/seq/internal/../charconv.hpp:123,
                 from /home/bogdb/seq/seq/internal/charconv.cpp:26:
/home/bogdb/seq/seq/internal/../tiny_string.hpp: In function ‘size_t seq::detail::traits_string_find_first_of(const Char*, size_t, size_t, const Char*, size_t, size_t)’:
/home/bogdb/seq/seq/internal/../tiny_string.hpp:280:58: error: ‘CHAR_BIT’ was not declared in this scope
  280 |                                 unsigned char buff[256 / CHAR_BIT];

This is fixed by adding #include <climits> in tiny_string.hpp.

Another build error occurs if the user fails to provide appropriate compile flags:

[ 14%] Building CXX object CMakeFiles/seq.dir/seq/internal/block_codec.cpp.o
[ 28%] Building CXX object CMakeFiles/seq.dir/seq/internal/transpose.cpp.o
[ 42%] Building CXX object CMakeFiles/seq.dir/seq/internal/hash.cpp.o
[ 85%] Building CXX object CMakeFiles/seq.dir/seq/internal/lz4small.cpp.o
[ 85%] Building CXX object CMakeFiles/seq.dir/seq/internal/charconv.cpp.o
[ 85%] Building CXX object CMakeFiles/seq.dir/seq/internal/simd.cpp.o
/build/source/seq/internal/transpose.cpp: In function '__m128i seq::transpose_4x4(__m128i)':
/build/source/seq/internal/transpose.cpp:66:24: error: '_mm_shuffle_epi8' was not declared in this scope; did you mean '_mm_shuffle_epi32'?
   66 |                 return _mm_shuffle_epi8(m, _mm_setr_epi8(0, 4, 8, 12,
      |                        ^~~~~~~~~~~~~~~~
      |                        _mm_shuffle_epi32
/build/source/seq/internal/transpose.cpp: In function 'void seq::detail::extract2Bytes_sse3(const char*, seq::hse_vector (*)[16])':
/build/source/seq/internal/transpose.cpp:187:48: error: '_mm_shuffle_epi8' was not declared in this scope; did you mean '_mm_shuffle_epi32'?
  187 |                                 __m128i val0 = _mm_shuffle_epi8(v0, sh0);
      |                                                ^~~~~~~~~~~~~~~~
      |                                                _mm_shuffle_epi32
/build/source/seq/internal/transpose.cpp: In function 'void seq::detail::extract4Bytes_sse3(const char*, seq::hse_vector (*)[16])':
/build/source/seq/internal/transpose.cpp:214:48: error: '_mm_shuffle_epi8' was not declared in this scope; did you mean '_mm_shuffle_epi32'?
  214 |                                 __m128i val0 = _mm_shuffle_epi8(v0, sh0);
      |                                                ^~~~~~~~~~~~~~~~
      |                                                _mm_shuffle_epi32
make[2]: *** [CMakeFiles/seq.dir/build.make:104: CMakeFiles/seq.dir/seq/internal/transpose.cpp.o] Error 1

This is because the user has to provide at least -mssse3 (I think) as a compile flag.

Thanks for the amazing library!

Hi, thank you for the report!
I guess that was included by other system headers on the tested platform, I added it explicitly in tiny_string.hpp as you suggested.

I use -march=native flag on gcc, so that's strange you get this compilation error (at least if SSE4 is available on your machine). To avoid such compilation error, the cvector related source files are now only compiled if SSE4_1 is defined. This works well with msvc and gcc 10.1.0 (msys2), let me know if you experience any issue with this.
Bests

Hi,

Thanks for the fix. There are still some compilation issues with certain flags:

[ 14%] Building CXX object CMakeFiles/seq.dir/seq/internal/block_codec.cpp.o
[ 28%] Building CXX object CMakeFiles/seq.dir/seq/internal/lz4small.cpp.o
In file included from /home/bogdb/src/seq/seq/internal/lz4small.cpp:37:
/home/bogdb/src/seq/seq/internal/lz4small.h: In static member function ‘static unsigned int seq::Lz4FlatEncoder::compress(void*, unsigned int, unsigned int, unsigned int, unsigned int)’:
/home/bogdb/src/seq/seq/internal/lz4small.h:69:73: error: ‘get_comp_buffer’ was not declared in this scope
   69 |                         int r = lz4_compress_fast((char*)in_out, (char*)get_comp_buffer(dst_size), block_size * BPP , dst_size, acceleration + 1, NULL);
      |                                                                         ^~~~~~~~~~~~~~~
/home/bogdb/src/seq/seq/internal/lz4small.h: In static member function ‘static unsigned int seq::Lz4TransposeEncoder::compress(void*, unsigned int, unsigned int, unsigned int, unsigned int)’:
/home/bogdb/src/seq/seq/internal/lz4small.h:97:65: error: ‘get_comp_buffer’ was not declared in this scope
   97 |                         transpose_generic((char*)in_out, (char*)get_comp_buffer(BPP * block_size ), block_size, BPP);
      |                                                                 ^~~~~~~~~~~~~~~
/home/bogdb/src/seq/seq/internal/lz4small.h:97:25: error: ‘transpose_generic’ was not declared in this scope
   97 |                         transpose_generic((char*)in_out, (char*)get_comp_buffer(BPP * block_size ), block_size, BPP);
      |                         ^~~~~~~~~~~~~~~~~
/home/bogdb/src/seq/seq/internal/lz4small.h: In static member function ‘static void seq::Lz4TransposeEncoder::restore(void*, void*, unsigned int, unsigned int’:
/home/bogdb/src/seq/seq/internal/lz4small.h:106:54: error: ‘get_comp_buffer’ was not declared in this scope
  106 |                         transpose_inv_generic((char*)get_comp_buffer(0), (char*)dst, block_size, BPP);
      |                                                      ^~~~~~~~~~~~~~~
/home/bogdb/src/seq/seq/internal/lz4small.h:106:25: error: ‘transpose_inv_generic’ was not declared in this scope
  106 |                         transpose_inv_generic((char*)get_comp_buffer(0), (char*)dst, block_size, BPP);
      |                         ^~~~~~~~~~~~~~~~~~~~~
/home/bogdb/src/seq/seq/internal/lz4small.h: In static member function ‘static unsigned int seq::Lz4TransposeEncoder::decompress(const void*, unsigned int, unsigned int, unsigned int, void*)’:
/home/bogdb/src/seq/seq/internal/lz4small.h:111:78: error: ‘get_comp_buffer’ was not declared in this scope
  111 |                         int r = lz4_decompress_fast((const char*)src, (char*)get_comp_buffer(BPP * block_size ), BPP * block_size );
      |                                                                              ^~~~~~~~~~~~~~~
/home/bogdb/src/seq/seq/internal/lz4small.h:114:25: error: ‘transpose_inv_generic’ was not declared in this scope
  114 |                         transpose_inv_generic((char*)get_comp_buffer(0), (char*)dst, block_size, BPP);
      |                         ^~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/seq.dir/build.make:90: CMakeFiles/seq.dir/seq/internal/lz4small.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/seq.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

This happens with -DCMAKE_CXX_FLAGS="-march=x86-64" (using x86-64-v2 or x86-64-v3 is fine).
I don't really have a problem with this as I will use at least x86-64-v3 but probably the header check should be extended.

Ok, I added the same guards in lz4small.h/cpp, it should (hopefully) build now. Thank you for your help!

it builds now, thanks!