From b2a0ffb5e98aa534682031a95af42de6fc184338 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cristi=20V=C3=AEjdea?= Date: Fri, 4 Apr 2025 16:32:36 +0300 Subject: [PATCH] Pass POSIX_C_SOURCE for std::alligned_alloc try_compile checks On FreeBSD 11, definining POSIX_C_SOURCE to a lower level has the efect of inhibiting the language level (__ISO_C_VISIBLE ) to be lower than C11, even in the presence of -std=c11 Since the check_symbol_exists runs without setting POSIX_C_SOURCE, this means that we will spuriously define HAVE_ALIGNED_ALLOC, while in the actual build it is not going to be defined ref: https://github.com/freebsd/freebsd-src/blob/stable/11/sys/sys/cdefs.h#L738 --- CMakeLists.txt | 4 ++-- configure | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5243251a..f6e2b32a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -450,7 +450,7 @@ set(CMAKE_REQUIRED_FLAGS) # # Check for aligned memory allocation support: POSIX # -set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L) +set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L -D_ISOC11_SOURCE=1) set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}") check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) if(HAVE_POSIX_MEMALIGN) @@ -462,7 +462,7 @@ set(CMAKE_REQUIRED_DEFINITIONS) # # Check for aligned memory allocation support: C11 # -set(CMAKE_REQUIRED_DEFINITIONS -D_ISOC11_SOURCE=1) +set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L -D_ISOC11_SOURCE=1) set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}") check_symbol_exists(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC) if(HAVE_ALIGNED_ALLOC) diff --git a/configure b/configure index e29ccddd..4fa8d44e 100755 --- a/configure +++ b/configure @@ -728,6 +728,7 @@ echo >> configure.log # check for aligned memory allocation support: POSIX cat > $test.c < int main(void) { void *ptr = 0; @@ -748,6 +749,7 @@ echo >> configure.log # check for aligned memory allocation support: C11 cat > $test.c < int main(void) { -- 2.47.3