From 387f82054c8ffa7d2b9e31d908586fbd47f34039 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Tue, 25 Jan 2022 12:16:48 -0500 Subject: [PATCH] Limit _XOPEN_SOURCE to Linux. POSIX feature macros are a mess. Reportedly, FreeBSD also breaks with _XOPEN_SOURCE, so try leaving it unset by default. Update-Note: It's possible this will break yet another obscure UNIX. Hopefully we can eventually find a combination that works? Bug: 471 Change-Id: I103f8093110d343789b9c5a22eb056ab78d9cd14 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51145 Reviewed-by: Adam Langley --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f74e233754..36bc8ec793 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,10 +257,11 @@ if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") endif() -# pthread_rwlock_t on Linux requires a feature flag. However, it should not be -# set on Apple platforms, where it instead disables APIs we use. See compat(5) -# and sys/cdefs.h. -if(NOT WIN32 AND NOT APPLE) +# pthread_rwlock_t on Linux requires a feature flag. We limit this to Linux +# because, on Apple platforms, it instead disables APIs we use. See compat(5) +# and sys/cdefs.h. Reportedly, FreeBSD also breaks when this is set. See +# https://crbug.com/boringssl/471. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700") endif()