Skip to content

Commit

Permalink
Ensure configure-less builds still enable NEON where available
Browse files Browse the repository at this point in the history
Add lines to the Makefile-generated config.h so HAVE_GETAUXVAL
or HAVE_ELF_AUX_INFO is set when appropriate.

Add lines to Makefile and simd.c to set HAVE_ELF_AUX_INFO
on a recent enough OpenBSD.  Part of this check needs to be
in simd.c because it pulls in sys/param.h, which defines
some macros (notable MIN and MAX) that don't get on with the
rest of HTSlib, and so need to be limited in scope.  This
can be simplified later once OpenBSD versions without
elf_aux_info() are no longer supported.
  • Loading branch information
daviesrob committed Sep 23, 2024
1 parent b0986df commit f2e1a2c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ config.h:
echo '#define HAVE_ATTRIBUTE_TARGET 1' >> $@
echo '#define HAVE_BUILTIN_CPU_SUPPORT_SSSE3 1' >> $@
echo '#endif' >> $@
echo '#if defined __linux__' >> $@
echo '#define HAVE_GETAUXVAL' >> $@
echo '#elif defined __FreeBSD__' >> $@
echo '#define HAVE_ELF_AUX_INFO' >> $@
echo '#elif defined __OpenBSD__' >> $@
echo '// Enable extra OpenBSD checks (see simd.c)' >> $@
echo '#define HAVE_OPENBSD' >> $@
echo '#endif' >> $@

# And similarly for htslib.pc.tmp ("pkg-config template"). No dependency
# on htslib.pc.in listed, as if that file is newer the usual way to regenerate
Expand Down
12 changes: 12 additions & 0 deletions simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ DEALINGS IN THE SOFTWARE. */

#if defined __arm__ || defined __aarch64__

#ifdef HAVE_OPENBSD
/*
* Extra check for elf_aux_info() on configure-less OpenBSD builds. Once
* version 7.5 has dropped off support, this can be changed to an assumption
* that the function exists in the Makefile-generated config.h.
*/
#include <sys/param.h>
#if OpenBSD >= 202409
#define HAVE_ELF_AUX_INFO
#endif
#endif

#if defined HAVE_GETAUXVAL || defined HAVE_ELF_AUX_INFO
#include <sys/auxv.h>
#elif defined __APPLE__
Expand Down

0 comments on commit f2e1a2c

Please sign in to comment.