Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.21 error on compilation: simd.c:140:30: error: incompatible types when initializing type ‘__m128i’ using type ‘int’ #2112 #1838

Closed
lindenb opened this issue Sep 12, 2024 · 11 comments

Comments

@lindenb
Copy link

lindenb commented Sep 12, 2024

Please specify the steps taken to generate the issue, the command you are running and the relevant output.

Hi all, I'm trying to compile 1.21 , I get the following error:

cd htslib-1.21 && make
make[1]: Entering directory `/path/to/packages/htslib-1.21'
(...)
gcc -g -Wall -O2 -fvisibility=hidden  -I.  -c -o simd.o simd.c
simd.c: In function ‘nibble2base_ssse3’:
simd.c:126:5: warning: implicit declaration of function ‘_mm_lddqu_si128’ [-Wimplicit-function-declaration]
     __m128i nuc_lookup_vec = _mm_lddqu_si128((__m128i *)seq_nt16_str);
     ^
simd.c:126:30: error: incompatible types when initializing type ‘__m128i’ using type ‘int’
     __m128i nuc_lookup_vec = _mm_lddqu_si128((__m128i *)seq_nt16_str);
                              ^
simd.c:135:27: error: incompatible types when initializing type ‘__m128i’ using type ‘int’
         __m128i encoded = _mm_lddqu_si128((__m128i *)nibble_cursor);
                           ^
simd.c:139:9: warning: implicit declaration of function ‘_mm_shuffle_epi8’ [-Wimplicit-function-declaration]
         __m128i nucs_upper = _mm_shuffle_epi8(nuc_lookup_vec, encoded_upper);
         ^
simd.c:139:30: error: incompatible types when initializing type ‘__m128i’ using type ‘int’
         __m128i nucs_upper = _mm_shuffle_epi8(nuc_lookup_vec, encoded_upper);
                              ^
simd.c:140:30: error: incompatible types when initializing type ‘__m128i’ using type ‘int’
         __m128i nucs_lower = _mm_shuffle_epi8(nuc_lookup_vec, encoded_lower);
                              ^

Please describe your environment.

x86_64 x86_64 x86_64 GNU/Linux

gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

$ grep HAVE_SS config.h
#define HAVE_SSE4_1 1
#define HAVE_SSSE3 1

I first tried without .configure. When I run now with .configure:

 htslib-1.21]$ ./configure 
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... -std=gnu11
checking for ranlib... ranlib
checking for grep that handles long lines and -e... /bin/grep
checking for C compiler warning flags... unknown
checking for gcc -std=gnu11 options needed to detect all undeclared functions... none needed
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for sys/param.h... yes
checking whether _XOPEN_SOURCE is declared... no
checking whether __get_cpuid_max is declared... yes
checking whether __cpuid_count is declared... yes
checking C compiler flags needed for sse4.1... -msse4.1 -mssse3 -mpopcnt
checking C compiler flags needed for avx2... -mavx2 -mpopcnt
checking C compiler flags needed for avx512f... unsupported
checking for working __builtin_cpu_supports("ssse3")... yes
checking for __attribute__((target))... yes
checking for pkg-config... /bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gcc -std=gnu11 option to enable large file support... none needed
checking shared library type for unknown-Linux... plain .so
checking whether the linker supports versioned symbols... yes
checking whether the compiler accepts -fvisibility=hidden... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for getpagesize... yes
checking for working mmap... yes
checking for gmtime_r... yes
checking for fsync... yes
checking for drand48... yes
checking for srand48_deterministic... no
checking whether fdatasync is declared... yes
checking for fdatasync... yes
checking for __attribute__((constructor))... yes
checking for clock_gettime with CLOCK_PROCESS_CPUTIME_ID... yes
checking for library containing log... -lm
checking for zlib.h... yes
checking for inflate in -lz... yes
checking for library containing recv... none required
checking for bzlib.h... yes
checking for BZ2_bzBuffToBuffCompress in -lbz2... yes
checking for lzma.h... yes
checking for lzma_easy_buffer_encode in -llzma... yes
checking whether htscodecs files are present... yes
checking for libdeflate.h... no
checking for libdeflate_deflate_compress in -ldeflate... no
checking for curl/curl.h... yes
checking for curl_easy_pause in -lcurl... yes
checking for CCHmac... no
checking for library containing HMAC... -lcrypto
checking for library containing regcomp... none required
configure: creating ./config.status
config.status: creating config.mk
config.status: creating htslib.pc.tmp
config.status: creating config.h
config.status: config.h is unchanged
config.status: linking htscodecs_bundled.mk to htscodecs.mk
[lindenbaum-p@login-01 htslib-1.21]$ make
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o kfunc.o kfunc.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o kstring.o kstring.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o bcf_sr_sort.o bcf_sr_sort.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o bgzf.o bgzf.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o errmod.o errmod.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o faidx.o faidx.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o header.o header.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o hfile.o hfile.c
echo '#define HTS_VERSION_TEXT "1.21"' > version.h
printf '#define HTS_CC "%s"\n#define HTS_CPPFLAGS "%s"\n#define HTS_CFLAGS "%s"\n#define HTS_LDFLAGS "%s"\n#define HTS_LIBS "%s"\n' \
'gcc -std=gnu11' \
'' \
'-g -O2 -fvisibility=hidden' \
'-fvisibility=hidden ' \
'-llzma -lbz2 -lz -lm   -lcurl -lcrypto' > config_vars.h
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o hts.o hts.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o hts_expr.o hts_expr.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o hts_os.o hts_os.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o md5.o md5.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o multipart.o multipart.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o probaln.o probaln.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o realn.o realn.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o regidx.o regidx.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o region.o region.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o sam.o sam.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o sam_mods.o sam_mods.c
gcc -std=gnu11 -g -O2 -fvisibility=hidden  -I.  -c -o simd.o simd.c
simd.c: In function ‘nibble2base_ssse3’:
simd.c:126:5: warning: implicit declaration of function ‘_mm_lddqu_si128’ [-Wimplicit-function-declaration]
     __m128i nuc_lookup_vec = _mm_lddqu_si128((__m128i *)seq_nt16_str);
     ^
simd.c:126:30: error: incompatible types when initializing type ‘__m128i’ using type ‘int’
     __m128i nuc_lookup_vec = _mm_lddqu_si128((__m128i *)seq_nt16_str);
                              ^
simd.c:135:27: error: incompatible types when initializing type ‘__m128i’ using type ‘int’
         __m128i encoded = _mm_lddqu_si128((__m128i *)nibble_cursor);
                           ^
simd.c:139:9: warning: implicit declaration of function ‘_mm_shuffle_epi8’ [-Wimplicit-function-declaration]
         __m128i nucs_upper = _mm_shuffle_epi8(nuc_lookup_vec, encoded_upper);
         ^
simd.c:139:30: error: incompatible types when initializing type ‘__m128i’ using type ‘int’
         __m128i nucs_upper = _mm_shuffle_epi8(nuc_lookup_vec, encoded_upper);
                              ^
simd.c:140:30: error: incompatible types when initializing type ‘__m128i’ using type ‘int’
         __m128i nucs_lower = _mm_shuffle_epi8(nuc_lookup_vec, encoded_lower);
                              ^
make: *** [simd.o] Error 1
@whitwham
Copy link
Contributor

whitwham commented Sep 13, 2024

That's interesting. We don't have a Red Hat box to test on. We did test it on Centos but there were no problems there.

@whitwham
Copy link
Contributor

Also, that is an old version of GCC. I think the oldest we normally run is 7.5.

@lindenb
Copy link
Author

lindenb commented Sep 13, 2024

@lindenb ah ! I'm now running with gcc/11.2.0 and it looks like it's running now ! Thanks !

@lindenb lindenb closed this as completed Sep 13, 2024
@jmarshall
Copy link
Member

It is to be sure an ancient compiler. It is also probably the CentOS 7 system compiler (@lindenb please confirm) — if so, it would behoove htslib to disable this code during configure.

@whitwham
Copy link
Contributor

We don't do the tests on Centos 7 any more. I know we like supporting everything, everywhere, all the time (and yes, when I find my first gen Raspberry Pi I will try samtools on that too) but how old a compiler do we want to handle?

@whitwham
Copy link
Contributor

Out of curiosity, I dug out an old CentOS 7 iso I had around and spun up a VM. End of life for CentOS 7 was the 30th June 2024. The old repositories are now offline and my quick attempts to try to look for RPMs in the CentOS vault failed. I'll see what the general consensus is before I put any more time into this.

@lindenb
Copy link
Author

lindenb commented Sep 13, 2024

@whitwham please don't, On my side I know we're still using this old server and we should move to a newer machine in the comings weeks... months...

@whitwham
Copy link
Contributor

@lindenb I know how it goes.

@jkbonfield
Copy link
Contributor

There are other C features we want to use which would break this compiler too, such as:

for (int i = 0; i < 100; i++) { ... }

However even gcc 4.8 works for this if you define CC=gcc -std=gnu99

It would be interesting to test whether this also adds the SIMD support. If not I think maybe it should be in autoconf so we omit it for old compilers, perhaps with a warning, The INSTALL file ideally needs to be explicit on the minimum compiler too (or configure).

@daviesrob
Copy link
Member

Centos 7 is no longer supported, but it appears to limp on in the form of Oracle Linux 7. RedHat Enterprise Linux 7 is now in extended life cycle support, so it's possible some instances could still be in use. Anyway, configure really should have caught this. It looks like supporting __builtin_cpu_supports("ssse3") doesn't necessarily mean your compiler tool-chain can actually output ssse3 instructions. Adding a few ssse3 intrinsics into the test ought to sort it out.

jmarshall added a commit to jmarshall/htslib that referenced this issue Feb 10, 2025
GCC 4.8.5 and earlier accept SSSE3 intrinsics with -mssse3; these
compiler versions also accept __attribute__((target("ssse3"))) but
the attribute fails to enable compilation of the intrinsics.

Refactor the check to HAVE_ATTRIBUTE_TARGET_SSSE3, and check both
the attribute and that the SSSE3 intrinsics used (in simd.c) are
in fact compilable in a function with the attribute. Fixes samtools#1838.
@jmarshall
Copy link
Member

FYI a recent pysam release updated to HTSlib et al 1.21 — and this was immediately reported again, as a bug against pysam. 😬

This motivated me to make PR #1886 which adds some SSSE3 intrinsics to the relevant configure test as suggested by @daviesrob above. (Sadly defining CC='gcc -std=gnu99' does not enable SIMD intrinsics within __attribute__((target)) on this ancient compiler.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants