Skip to content

Conversation

daviesrob
Copy link
Member

Adds a configure check for fstatat( , , , AT_SYMLINK_NOFOLLOW) so that the ref-cache can be disabled automatically on platforms that lack this interface. Also adjusts the position of the BUILDING_SIMD_NIBBLE2BASE guard in simd.c so that it doesn't try to include immintrin.h when the code that uses it is not going to be built.

Fixes #1941

Disable ref-cache if fstatat() doesn't work.  Allows builds of
the rest of HTSlib to complete if this interface is not available.
This mainly affects fairly old systems, notable MacOS X 10.9,
which is still supported by MacPorts.
@jmarshall
Copy link
Member

Moving the #ifdef BUILDING_SIMD_NIBBLE2BASE check up would make adding a second SIMD implementation to this source file more difficult, as the two quite likely would want to be independently activated but the #includes and cpu_supports_neon() would need to be there when any of them are activated. (One of these days I'll finish up my base2nibble() branch…)

Instead of the second commit, IMHO it would be better to also probe in configure for presence of the header file and conditionalise #include <immintrin.h> independently. Something like this immintrin-check commit.

daviesrob and others added 2 commits October 2, 2025 14:07
Add checks for `x86intrin.h` for both configure and make-only
builds, and use it to gate x86intrin.h inclusion.

Update `simd.c` to use it in preference to `immintrin.h`.
While the latter is the one preferred by Intel, and possibly
more portable than `x86intrin.h` (which was introduced by gcc
and clang), htscodecs consistently uses `x86intrin.h` so it's
easier to standardise on that one.  The intel compiler now supports
both, so the portability issue is less of a problem than it used
to be.
Prevents failures on older compilers that don't have this
builtin, or don't support using it to test for ssse3.
@daviesrob
Copy link
Member Author

I've pushed an improved version of this with, as suggested, configure checks for the intrinsics header. The file used has changed from immintrin.h to x86intrin.h as the latter is the one used by htscodecs. While the latter isn't strictly the standard one, it is supported by gcc, clang, and recent Intel compilers.

I've also added a check for __builtin_cpu_supports("ssse3") on make-only builds so that they don't fall over if the compiler is too old to understand "ssse3" as a valid input for the builtin.

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

Successfully merging this pull request may close these issues.

error: use of undeclared identifier 'AT_SYMLINK_NOFOLLOW'
2 participants