From 4a283fcc311035ed8db8044dcbeb9a75dd452cab Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 3 Jun 2022 09:24:03 -0400 Subject: librhash: Explicitly enable large file support on 32-bit targets `_LARGEFILE_SOURCE` is needed at least on SunOS i386 if compiler extensions are not enabled. --- Utilities/cmlibrhash/librhash/rhash.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Utilities/cmlibrhash/librhash/rhash.c b/Utilities/cmlibrhash/librhash/rhash.c index ce6ace4..2530112 100644 --- a/Utilities/cmlibrhash/librhash/rhash.c +++ b/Utilities/cmlibrhash/librhash/rhash.c @@ -20,6 +20,7 @@ #endif /* macros for large file support, must be defined before any include file */ +#define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE #define _FILE_OFFSET_BITS 64 -- cgit v0.12 From 3ba324b6b6acf8db34bde5a79563fe9161f9896c Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 3 Jun 2022 09:26:00 -0400 Subject: libarchive: Remove a system preprocessor macro that conflicts with a local var On SunOS i386, the system headers sometimes define macro names corresponding to register names, short and with no prefix. Undefine one that conflicts with our code. --- Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c b/Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c index b913a4d..4f9b2d9 100644 --- a/Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c +++ b/Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c @@ -28,6 +28,9 @@ #define PARALLELISM_DEGREE 8 +/* Remove system-defined preprocessor defintions that conflict with us. */ +#undef FS + /* blake2sp_init_param defaults to setting the expecting output length from the digest_length parameter block field. -- cgit v0.12 From c7c3e39e4faa6fe4f6868b8bf83ee20bda5a5faf Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 2 Jun 2022 16:14:20 -0400 Subject: Utilities: Activate POSIX APIs even without compiler extensions Compile some third-party libraries with preprocessor definitions that activate POSIX APIs even when compiler extensions are not enabled. We already do this in libuv, inherited from the upstream buildsystem. This extends commit f034b0f663 (CMake compilation: do not use compiler extensions, 2020-03-14, v3.18.0-rc1~494^2). Issue: #20454 --- Utilities/cmbzip2/CMakeLists.txt | 8 ++++++++ Utilities/cmcurl/CMakeLists.txt | 14 ++++++++++++++ Utilities/cmlibarchive/CMakeLists.txt | 10 ++++++++++ Utilities/cmliblzma/CMakeLists.txt | 8 ++++++++ 4 files changed, 40 insertions(+) diff --git a/Utilities/cmbzip2/CMakeLists.txt b/Utilities/cmbzip2/CMakeLists.txt index 52efe14..1d7b265 100644 --- a/Utilities/cmbzip2/CMakeLists.txt +++ b/Utilities/cmbzip2/CMakeLists.txt @@ -8,6 +8,14 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") endif() +# Activate POSIX APIs. +if(CMAKE_SYSTEM_NAME MATCHES "^(AIX|OS400)$") + add_definitions(-D_ALL_SOURCE) +endif() +if(NOT CMAKE_SYSTEM_NAME MATCHES "BSD|Darwin|Windows") + add_definitions(-D_XOPEN_SOURCE=600) +endif() + add_definitions(-D_FILE_OFFSET_BITS=64) add_library(cmbzip2 blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 2c0e873..f842270 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -119,6 +119,20 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") endif() +# Activate POSIX APIs. +if(CMAKE_SYSTEM_NAME MATCHES "^(AIX|OS400)$") + add_definitions(-D_ALL_SOURCE) +endif() +if(CMAKE_SYSTEM_NAME MATCHES "^(Linux)$") + add_definitions(-D_DEFAULT_SOURCE -D_BSD_SOURCE) +endif() +if(CMAKE_SYSTEM_NAME MATCHES "^(SunOS)$") + add_definitions(-D__EXTENSIONS__) +endif() +if(NOT CMAKE_SYSTEM_NAME MATCHES "BSD|Darwin|Windows") + add_definitions(-D_XOPEN_SOURCE=600) +endif() + #*************************************************************************** # _ _ ____ _ # Project ___| | | | _ \| | diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index 9ab7cec..eea472f 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -103,6 +103,16 @@ ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") ENDIF() +# Activate POSIX APIs. +if(CMAKE_SYSTEM_NAME MATCHES "^(Linux)$") + add_definitions(-D_DEFAULT_SOURCE -D_BSD_SOURCE) + string(APPEND CMAKE_REQUIRED_DEFINITIONS " -D_DEFAULT_SOURCE -D_BSD_SOURCE") +endif() +if(NOT CMAKE_SYSTEM_NAME MATCHES "BSD|Darwin|Windows") + add_definitions(-D_XOPEN_SOURCE=600) + string(APPEND CMAKE_REQUIRED_DEFINITIONS " -D_XOPEN_SOURCE=600") +endif() + IF(0) # CMake does not need flags specific to libarchive upstream development. if (CMAKE_BUILD_TYPE STREQUAL "Debug") OPTION(ENABLE_WERROR "Treat warnings as errors - default is ON for Debug, OFF otherwise." ON) diff --git a/Utilities/cmliblzma/CMakeLists.txt b/Utilities/cmliblzma/CMakeLists.txt index 0de1e97..3121fbe 100644 --- a/Utilities/cmliblzma/CMakeLists.txt +++ b/Utilities/cmliblzma/CMakeLists.txt @@ -166,6 +166,14 @@ ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") ENDIF() +# Activate POSIX APIs. +if(CMAKE_SYSTEM_NAME MATCHES "^(AIX|OS400)$") + add_definitions(-D_ALL_SOURCE) +endif() +if(NOT CMAKE_SYSTEM_NAME MATCHES "BSD|Darwin|Windows") + add_definitions(-D_XOPEN_SOURCE=600) +endif() + ADD_LIBRARY(cmliblzma STATIC ${LZMA_SRCS}) IF(CMAKE_C_COMPILER_ID STREQUAL "XL") -- cgit v0.12