From a1cb3654fb0802ae28327cc521dc0600a341b75d Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Wed, 10 Jul 2024 10:16:17 -0400 Subject: [PATCH] Merge pull request from upstream JUCE repo to support builds on musl libc (#6) This commit squashes the four GLIBC/MUSL commits from https://github.com/juce-framework/JUCE/pull/1239 into our branch as a single commit (retaining a single commit to make future rebasing easier etc). Those commits were: * SystemStats: Only use locales on glibc * Linux: Add JUCE_GLIBC and JUCE_MUSL macros * SystemStats: Do not use execinfo.h on JUCE_MUSL * Native: Only use stat64 on glibc and iOS Musl 1.2.4 made the LFS64 interfaces only available when _LARGEFILE64_SOURCE is defined, and they will be removed altogether in Musl 1.2.5. --------- Co-authored-by: Violet Purcell Rebase to 7.0.12 by baconpaul --- modules/juce_core/juce_core.cpp | 2 +- modules/juce_core/native/juce_SharedCode_posix.h | 2 +- modules/juce_core/native/juce_SystemStats_linux.cpp | 12 ++++++------ modules/juce_core/system/juce_SystemStats.cpp | 2 +- modules/juce_core/system/juce_TargetPlatform.h | 9 +++++++++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/juce_core/juce_core.cpp b/modules/juce_core/juce_core.cpp index 8382283f918e..e7d7e69a5fc4 100644 --- a/modules/juce_core/juce_core.cpp +++ b/modules/juce_core/juce_core.cpp @@ -108,7 +108,7 @@ #include #include - #if ! (JUCE_ANDROID || JUCE_WASM) + #if ! (JUCE_ANDROID || JUCE_WASM || JUCE_MUSL) #include #endif #endif diff --git a/modules/juce_core/native/juce_SharedCode_posix.h b/modules/juce_core/native/juce_SharedCode_posix.h index c53ef0fff6f3..ba9f4c5e8f8b 100644 --- a/modules/juce_core/native/juce_SharedCode_posix.h +++ b/modules/juce_core/native/juce_SharedCode_posix.h @@ -178,7 +178,7 @@ inline int juce_siginterrupt ([[maybe_unused]] int sig, [[maybe_unused]] int fla //============================================================================== namespace { - #if JUCE_LINUX || (JUCE_IOS && (! TARGET_OS_MACCATALYST) && (! __DARWIN_ONLY_64_BIT_INO_T)) // (this iOS stuff is to avoid a simulator bug) + #if JUCE_GLIBC || (JUCE_IOS && (! TARGET_OS_MACCATALYST) && (! __DARWIN_ONLY_64_BIT_INO_T)) // (this iOS stuff is to avoid a simulator bug) using juce_statStruct = struct stat64; #define JUCE_STAT stat64 #else diff --git a/modules/juce_core/native/juce_SystemStats_linux.cpp b/modules/juce_core/native/juce_SystemStats_linux.cpp index 3d6bebc74c9a..6a21c6fbd56f 100644 --- a/modules/juce_core/native/juce_SystemStats_linux.cpp +++ b/modules/juce_core/native/juce_SystemStats_linux.cpp @@ -210,22 +210,22 @@ String SystemStats::getComputerName() String SystemStats::getUserLanguage() { - #if JUCE_BSD + #if JUCE_GLIBC + return getLocaleValue (_NL_ADDRESS_LANG_AB); + #else if (auto langEnv = getenv ("LANG")) return String::fromUTF8 (langEnv).upToLastOccurrenceOf (".UTF-8", false, true); return {}; - #else - return getLocaleValue (_NL_ADDRESS_LANG_AB); #endif } String SystemStats::getUserRegion() { - #if JUCE_BSD - return {}; - #else + #if JUCE_GLIBC return getLocaleValue (_NL_ADDRESS_COUNTRY_AB2); + #else + return {}; #endif } diff --git a/modules/juce_core/system/juce_SystemStats.cpp b/modules/juce_core/system/juce_SystemStats.cpp index 6dafa07185f6..f44bb8f8a053 100644 --- a/modules/juce_core/system/juce_SystemStats.cpp +++ b/modules/juce_core/system/juce_SystemStats.cpp @@ -190,7 +190,7 @@ String SystemStats::getStackBacktrace() { String result; - #if JUCE_ANDROID || JUCE_WASM + #if JUCE_ANDROID || JUCE_MINGW || JUCE_WASM || JUCE_MUSL jassertfalse; // sorry, not implemented yet! #elif JUCE_WINDOWS diff --git a/modules/juce_core/system/juce_TargetPlatform.h b/modules/juce_core/system/juce_TargetPlatform.h index 0c55ad7c586a..19941a8685e0 100644 --- a/modules/juce_core/system/juce_TargetPlatform.h +++ b/modules/juce_core/system/juce_TargetPlatform.h @@ -45,6 +45,7 @@ - Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. - Either JUCE_INTEL or JUCE_ARM - Either JUCE_GCC or JUCE_CLANG or JUCE_MSVC + - Either JUCE_GLIBC or JUCE_MUSL will be defined on Linux depending on the system's libc implementation. */ //============================================================================== @@ -212,6 +213,14 @@ #elif __MMX__ || __SSE__ || __amd64__ #define JUCE_INTEL 1 #endif + + #if JUCE_LINUX + #ifdef __GLIBC__ + #define JUCE_GLIBC 1 + #else + #define JUCE_MUSL 1 + #endif + #endif #endif //==============================================================================