bkaradzic / bx

Base library used across multiple projects
BSD 2-Clause "Simplified" License
565 stars 433 forks source link

Can't avoid BX_CRT_NONE=1 with musl libc environment #142

Closed Klowner closed 7 years ago

Klowner commented 7 years ago

I wouldn't even be submitting this bug if I didn't see you were trying to account for musl libc runtimes in your platform.h with BX_CRT_MUSL, but due to musl not exposing any sort of identifying #defines, I'm not quite sure how to deal with this. Simply defining BX_CRT_MUSL=1 in an else clause seems less than optimal.

Maybe my best solution is just to ditch my Alpine Linux / musl libc test pipeline for something more sensible?

This "works" in bx/include/platform.h

#if !BX_CRT_NONE
// https://sourceforge.net/p/predef/wiki/Libraries/
#   if defined(__BIONIC__)
#       undef  BX_CRT_BIONIC
#       define BX_CRT_BIONIC 1
#   elif defined(_MSC_VER)
#       undef  BX_CRT_MSVC
#       define BX_CRT_MSVC 1
#   elif defined(__GLIBC__)
#       undef  BX_CRT_GLIBC
#       define BX_CRT_GLIBC (__GLIBC__ * 10000 + __GLIBC_MINOR__ * 100)
#   elif defined(__MINGW32__) || defined(__MINGW64__)
#       undef  BX_CRT_MINGW
#       define BX_CRT_MINGW 1
#   elif defined(__apple_build_version__) || defined(__ORBIS__) || defined(__EMSCRIPTEN__)
#       undef  BX_CRT_LIBCXX
#       define BX_CRT_LIBCXX 1
#   else
#       undef  BX_CRT_MUSL            // THIS SEEMS LIKE
#       define BX_CRT_MUSL 1          // A POOR SOLUTION
#   endif //
bkaradzic commented 7 years ago

Yeah muslc not providing define is annoying (their justification doesn't consider cross platform projects at all). Solution is just define BX_CRT_MUSL from project file...

With GENie it would be something like this:

defines {
    "BX_CRT_MUSL=1",
}