Skip to content

Commit

Permalink
Merge pull request from upstream JUCE repo to support builds on musl …
Browse files Browse the repository at this point in the history
…libc (#6)

This commit squashes the four GLIBC/MUSL commits from juce-framework#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 <vimproved@inventati.org>
  • Loading branch information
catarial and vimproved authored Jun 28, 2024
1 parent 8ac8b3e commit f065f04
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/juce_core/juce_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
#include <net/if.h>
#include <sys/ioctl.h>

#if ! (JUCE_ANDROID || JUCE_WASM)
#if ! (JUCE_ANDROID || JUCE_WASM || JUCE_MUSL)
#include <execinfo.h>
#endif
#endif
Expand Down
12 changes: 6 additions & 6 deletions modules/juce_core/native/juce_linux_SystemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,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_IDENTIFICATION_LANGUAGE);
#endif
}

String SystemStats::getUserRegion()
{
#if JUCE_BSD
return {};
#if JUCE_GLIBC
return getLocaleValue (_NL_ADDRESS_COUNTRY_AB2);
#else
return getLocaleValue (_NL_IDENTIFICATION_TERRITORY);
return {};
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion modules/juce_core/native/juce_posix_SharedCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int juce_siginterrupt ([[maybe_unused]] int sig, [[maybe_unused]] int flag)
//==============================================================================
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
Expand Down
2 changes: 1 addition & 1 deletion modules/juce_core/system/juce_SystemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ String SystemStats::getStackBacktrace()
{
String result;

#if JUCE_ANDROID || JUCE_MINGW || JUCE_WASM
#if JUCE_ANDROID || JUCE_MINGW || JUCE_WASM || JUCE_MUSL
jassertfalse; // sorry, not implemented yet!

#elif JUCE_WINDOWS
Expand Down
9 changes: 9 additions & 0 deletions modules/juce_core/system/juce_TargetPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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.
*/

//==============================================================================
Expand Down Expand Up @@ -183,6 +184,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

//==============================================================================
Expand Down

0 comments on commit f065f04

Please sign in to comment.