Hi, In Autoconf 2.70 the following bug was fixed: "AC_CHECK_DECL and AC_CHECK_DECLS will now detect missing declarations for library functions that are also Clang compiler builtins." For example, the AC_CHECK_DECLS([strndup]) invocation, on a glibc system, with CC="clang -D_POSIX_C_SOURCE=200112L" (with clang versions < 16), reported checking whether strndup is declared... yes Now, in Autoconf 2.70 and newer, it correctly reports checking whether strndup is declared... no
Now, there is also a different bug, that occurs only on macOS: clang, on macOS, compiles for a certain "minimum macOS version" or "target macOS version". This macOS version is <= the SDK version. The SDK is the set of include files and linkable libraries. It is important to note that while this "minimum macOS version" can be set through a command line option https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-mmacos-version-min or through an environment variable https://clang.llvm.org/docs/CommandGuide/clang.html#envvar-MACOSX_DEPLOYMENT_TARGET it can also be different from the SDK version *by default*. For instance, on the machine cfarm104.cfarm.net, which has a macOS 12.6 OS (according to `sw_vers`), the default SDK of the 'clang', 'cc', or 'gcc' command (all equivalent), visible in /Library/Developer/CommandLineTools/SDKs/ is the macOS 13.1 SDK, but the "minimum macOS version" is 12.0, as can be seen by running $ echo 'int main () {}' > foo.c $ clang foo.c $ otool -l a.out | grep min minos 12.0 So, this compiler, while using a macOS 13.1 SDK, is meant to produce binaries that run on macOS 12.0 and newer. There are 3 new functions in macOS 13 that did not exist in macOS 12: freadlink, mkfifoat, mknodat. Let's concentrate on mkfifoat here. It's declared in <sys/stat.h> through int mkfifoat(int, const char *, mode_t) __API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0), watchos(9.0)); So, the compiler knows that when compiling for macOS 12.x, this function is not available. Here's a test program with GNU Build System (attached). After unpacking, run $ aclocal && autoconf && automake -a -c $ CC=clang ./configure ... checking whether mkfifoat is declared... yes ... $ make ... foo.c:17:10: warning: 'mkfifoat' is only available on macOS 13.0 or newer [-Wunguarded-availability-new] return mkfifoat (dfd, name, mode); ^~~~~~~~ $ ./foo Segmentation fault: 11 For comparison: $ CC="clang -Werror=unguarded-availability-new" ./configure ... checking whether mkfifoat is declared... no ... $ make $ ./foo $ echo $? 0 What are the possible workarounds? 1) A workaround could be to tell people on macOS to use CC="clang -Werror=unguarded-availability-new". But even if we document this, maybe only 5% of the users will read and follow this advice, and the remaining 95% of the users will still experience crashes in this situation. 2) Another workaround could be to tell people to use gnulib's gl_CHECK_FUNCS_MACOS instead of AC_CHECK_DECLS. The problem with that is that we don't know in advance for which functions. For instance, https://github.com/Homebrew/homebrew-core/issues/224205 is a manifestation of this bug for the strchrnul() function, which was added in macOS 15.4. We don't know in advance which functions will be added in future macOS versions. So, effectively, it means to use gl_CHECK_FUNCS_MACOS instead of AC_CHECK_DECLS for all functions that don't already exist in macOS for a long time. 3) Another workaround could be to add the '-Werror=unguarded-availability-new' compiler option for AC_CHECK_DECL's compiler invocations, just like Autoconf already adds the '-Werror' option as a workaround against the first bug mentioned above. Bruno
minos.tar.gz
Description: application/compressed-tar