diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -617,13 +617,13 @@ dnl Check for pthread compile/link requirements AX_PTHREAD -# Check for off_t vs off64_t before AC_SYS_LARGEFILE gets called as it will -# change the output -AC_MSG_CHECKING(for if type off_t equals off64_t) +# Check for Large File Supprot before AC_SYS_LARGEFILE gets called as it will +# change the output. +AC_MSG_CHECKING(for if LFS is enabled) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include #include ]], - [[ static_assert(std::is_same::value, ""); ]])], - [ AC_MSG_RESULT(yes); need_wrap_fcntl=no; AC_DEFINE(OFF_T_EQUALS_OFF64_T, 1,[Define this symbol if type off_t equals off64_t]) ], + [[ static_assert(sizeof(off_t) == 8, ""); ]])], + [ AC_MSG_RESULT(yes); need_wrap_fcntl=no; AC_DEFINE(HAVE_LARGE_FILE_SUPPORT, 1,[Define this symbol if LFS is enabled]) ], [ AC_MSG_RESULT(no); need_wrap_fcntl=yes] ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -298,13 +298,19 @@ add_linker_flags(-Wl,--wrap=__divmoddi4) add_linker_flags(-Wl,--wrap=log2f) - if(NOT OFF_T_EQUALS_OFF64_T) + if(NOT HAVE_LARGE_FILE_SUPPORT) add_linker_flags(-Wl,--wrap=fcntl -Wl,--wrap=fcntl64) endif() target_sources(util PRIVATE compat/glibc_compat.cpp) endif() +# Enable LFS (Large File Support) on targets that don't have it natively. +if(NOT HAVE_LARGE_FILE_SUPPORT) + add_compiler_flags(-D_FILE_OFFSET_BITS=64) + add_linker_flags(-Wl,--large-address-aware) +endif() + # Target specific configs if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(Boost_USE_STATIC_LIBS ON) diff --git a/src/compat/glibc_compat.cpp b/src/compat/glibc_compat.cpp --- a/src/compat/glibc_compat.cpp +++ b/src/compat/glibc_compat.cpp @@ -83,7 +83,7 @@ * compatibility symbol for these architectures. We can link the new `fcntl()` * and `fcntl64()` against this symbol with the help of a wrapper. */ -#if defined(HAVE_CONFIG_H) && !defined(OFF_T_EQUALS_OFF64_T) +#if defined(HAVE_CONFIG_H) && !defined(HAVE_LARGE_FILE_SUPPORT) extern "C" int fcntl_old(int fd, int cmd, ...); #ifdef __i386__ __asm(".symver fcntl_old,fcntl@GLIBC_2.0"); diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -162,10 +162,10 @@ #include #include int main() { - static_assert(std::is_same::value, \"\"); + static_assert(sizeof(off_t) == 8, \"\"); return 0; } -" OFF_T_EQUALS_OFF64_T) +" HAVE_LARGE_FILE_SUPPORT) check_cxx_source_compiles(" __attribute__((visibility(\"default\"))) int main() { diff --git a/src/config/bitcoin-config.h.cmake.in b/src/config/bitcoin-config.h.cmake.in --- a/src/config/bitcoin-config.h.cmake.in +++ b/src/config/bitcoin-config.h.cmake.in @@ -53,7 +53,7 @@ #cmakedefine HAVE_SYSCTL_ARND 1 #cmakedefine CHAR_EQUALS_INT8 0 -#cmakedefine OFF_T_EQUALS_OFF64_T 1 +#cmakedefine HAVE_LARGE_FILE_SUPPORT 1 #cmakedefine HAVE_FUNC_ATTRIBUTE_VISIBILITY 1 #cmakedefine HAVE_FUNC_ATTRIBUTE_DLLEXPORT 1