On OpenBSD 6.8, there are two compilers available: cc (= clang) and gcc. With gcc, the test 'test-aligned_alloc' crashes. This is due to a missing function declaration, which produces warnings:
../../gltests/test-aligned_alloc.c: In function 'main': ../../gltests/test-aligned_alloc.c:51: warning: implicit declaration of function 'aligned_alloc' ../../gltests/test-aligned_alloc.c:51: warning: assignment makes pointer from integer without a cast ../../gltests/test-aligned_alloc.c:56: warning: assignment makes pointer from integer without a cast ../../gltests/test-aligned_alloc.c:61: warning: assignment makes pointer from integer without a cast ../../gltests/test-aligned_alloc.c:66: warning: assignment makes pointer from integer without a cast ../../gltests/test-aligned_alloc.c:71: warning: assignment makes pointer from integer without a cast ../../gltests/test-aligned_alloc.c:76: warning: assignment makes pointer from integer without a cast This function declaration exists in <stdlib.h>, but only when standards macros ensure that it is visible. The macro to enable this (and other) declarations is _ISOC11_SOURCE. While this macro (or an equivalent) is probably automatically enabled with 'gcc -std=gnu11' [1], the particular GCC version (4.2.1) does not support -std=gnu11, only -std=gnu99. [1] https://man7.org/linux/man-pages/man7/feature_test_macros.7.html This could go into Autoconf's AC_USE_SYSTEM_EXTENSIONS at some point. But probably not now; it may be too risky now. 2021-01-01 Bruno Haible <br...@clisp.org> aligned_alloc: Fix test failure on OpenBSD 6.8. * m4/extensions.m4 (gl_USE_SYSTEM_EXTENSIONS): On OpenBSD, define _ISOC11_SOURCE. * m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Update comment. diff --git a/m4/aligned_alloc.m4 b/m4/aligned_alloc.m4 index f16ad15..54253ed 100644 --- a/m4/aligned_alloc.m4 +++ b/m4/aligned_alloc.m4 @@ -1,4 +1,4 @@ -# aligned_alloc.m4 serial 1 +# aligned_alloc.m4 serial 2 dnl Copyright (C) 2020-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_ALIGNED_ALLOC], AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - dnl Persuade glibc <stdlib.h> to declare aligned_alloc(). + dnl Persuade glibc and OpenBSD <stdlib.h> to declare aligned_alloc(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) AC_CHECK_FUNCS_ONCE([aligned_alloc]) diff --git a/m4/extensions.m4 b/m4/extensions.m4 index f7333ac..5792a95 100644 --- a/m4/extensions.m4 +++ b/m4/extensions.m4 @@ -1,4 +1,4 @@ -# serial 21 -*- Autoconf -*- +# serial 22 -*- Autoconf -*- # Enable extensions on systems that normally disable them. # Copyright (C) 2003, 2006-2021 Free Software Foundation, Inc. @@ -212,4 +212,16 @@ dnl it should only be defined when necessary. AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], [ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl On OpenBSD 6.8 with GCC, the include files contain a couple of + dnl definitions that are only activated with an explicit -D_ISOC11_SOURCE. + dnl That's because this version of GCC (4.2.1) supports the option + dnl '-std=gnu99' but not the option '-std=gnu11'. + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + openbsd*) + AC_DEFINE([_ISOC11_SOURCE], [1], + [Define to enable the declarations of ISO C 11 types and functions.]) + ;; + esac ])