Repository navigation
Musl build - #4580
Musl build#4580peppergrayxyz wants to merge 23 commits into
Conversation
|
Thank you for this. This is a huge change so I will need time to review it. To answer the question about the libc fallback: I guess this depend on ow you plan to use box64. If it's only to run musl x64 program (like Wine?) then fallback are not usefull. But if the musl x64 landscape is to small and the target is regular glibc x64 binaries, then fallback are a must. |
|
@peppergrayxyz I don't understand what |
|
@peppergrayxyz I found this PR anyway. Can we split it? You have already separated the commit in various chapter, so why not start with chapter 1 in a PR? Or we can go to 1+2+3 as a start. 4 should then be another PR then 5+6 together as a last one seems reasonable. |
|
I cannot create stacked PRs here, only in my repo. Also I cannot rebase each slice onto main (doesn't make much sense). I'll try something else. |
|
I splitted them, but I couldn't create stacked PRs, so each contains the prevouis ones |
I think that was a missing function name, I'll check and correct it! |
a0cb720 to
1a90b08
Compare
1a90b08 to
105e4f3
Compare
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
my32_pthread_mutex_init: fake->i386__kind: incomplete definition of type 'struct __pthread_mutex_s' Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
105e4f3 to
1b32884
Compare
These patches add inital musl support (#2012).
This is
x86-muslvcuberunning on anarm64-muslhost.x86-glibcvcubehas missing symbols and how to handle them is to be decide.I haven't spitted the patches into multiple PRs yet, because rebasing everything is a lot of work and I would like to do this in a coordinated way. I have re-ordered my commits into an order that is somewhat logical and made them small and pointed so they can be easily cherry-picked. Happy to shuffle things around, just let me know.
Patches
1. houskeeping
1.1 global GNU_SOURCE
pick 0501bb1 # global GNU_SOURCE
This removes
GNU_SOURCEfrom the files and moves it toCMakeLists.txt.GNU_SOURCEshould be consistently applied bevore includes, but is not and some files are included bevoreGNU_SOURCE.1.2. global large file support (lfs)
pick 948da8f # global lfs
pick 4e2c3c0 # lfs: use fseeko
pick 93334e9 # lfs: use ino_t, off_t
pick 14183a4 # lfs: mmap
pick a92baa7 # lfs: fsblkcnt_t, fsfilcnt_t
pick efbdf2e # lfs: stat
pick 71280a2 # lfs: dirent
pick ccb07ba # lfs: alphasort
pick 15a561e # lfs: f/open
pick 6bde1ec # lfs: l/f/stat, fstatat, statfs
pick d20deea # lfs: get/setrlimit, struct rlimit
pick ba082aa # lfs: n/ftw
pick 66b1a31 # lfs: scandir/at, readdir
pick 817c444 # lfs: glob, globfree, glob_t
This renames all compatibility
*64_ttypes to their unprefixed names and enables 64 bit file types globally.1.3. isnan/isinf
pick f88fca2 # replace legacy isnanf/isinff with isnan/isinf
This consisently moves to
isnanandisinfwhich are used in parallel to deprecated function names2. Bugs
2.1 my_pthread_getaffinity_np_old
pick 9f41c3c # fix my_pthread_getaffinity_np_old return a value
my_pthread_getaffinity_np_oldis not returning a value2.2 early init segfault
pick 03f659f # fix early init segfault
if
GetNativeSymbolUnversionedreturnsNULLinlibtools/libdl.cthere is no message and the app segfaults. Adding a message, doesn't work, becasecore.cinitializesftrace = stderronly after the failure already happend.This patch:
GetNativeSymbolUnversionedand prints a message and aborts on errorftrace=stderrinPrintfFtracewhen it is to be used, but not yet set3. GNU-ism
3.1 rename symbols to not use glibc internals
pick 1ae022f # musl fix glibc names: __sigset_t, __pid_t, __uid_t
pick 10de8e3 # musl fix glibc names: qsort __compar_d_fn_t
3.2 macro redefinition
pick dd7be61 # fix musl build: os.h: macro redefined
3.3 fix type mismatch
pick 46edc2a # fix musl build: threads
4. conditional dependencies
These symbols do not exist on
musl. Currently a lot of things are handled viaANDROIDand__GLIBC__. I didn't want to switch based onlibcbut usedcmaketests to determine if headers, symbols and functions are available and then act accordingly.pick 1b76649 # conditional: execinfo.h
pick ad717c3 # conditional: mallopt
pick a721751 # conditional: malloc_trim
pick 36ff077 # conditional: mallinfo, mallinfo2
pick 88d7403 # conditional: _pthread_cleanup_push/pop
pick fa7ec47 # conditional: pthread_attr_get/setaffinity_np
pick f22c702 # conditional: __pthread_mutex_s->__kind
pick 8cd2665 # conditional: dlvsym
pick 6a99b16 # conditional: obstack_vprintf
pick 420ff22 # conditional: struct obstack
pick 3e609d6 # conditional: siginfo_t
pick 7bf2e51 # conditional: getprotobyname/number_r
pick 94ea179 # conditional: struct __res_state
pick c6b558f # conditional: RTLD_DL_SYMENT/LINKMAP
pick 38637ef # conditional: scandirat
pick 379621c # conditional: __ctype_b/tolower/toupper_loc
pick 649c198 # conditional: glob_t
pick d74203c # conditional: posix_spawn_file_actions_t
pick 87f6053 # conditional: __NFDBITS
pick 8a0d530 # conditional: __chk_fail
I'm not sure how to handle
glibcsymbols in general. For those that are needed by the build I added workarounds, added libraries and implemented missing functions. Symbols that are justpassed throughwill fail. I think it is nice to have fall-backs, but I'm not sure to which extendbox64wants to become agcompatlike thing5. libs for missing features
for
obstack_vprintfandgetprotobyname_r/getprotobynumber_rI implemented fallback. For other functions I addedargp,obstack,fts,ucontextanderrorwhen targeting musl. All of them are packaged foralpineandgentoopick 8bda8b3 # musl: link additional libs
6. musl specifics
These last packages implement new behavior specifically for musl
pick de0abd2 # musl: update malloc hook
musldoesn't have__libc_*symbols, find them throughdlsyminsteadpick 1a90b08 # musl: elfloader find symbol
elfloaderis looking for versioned libs which work differntly on muslTesting
Test 11 crashes and is disabled on Android
Test 44 and 45 are missing symbols
AI Disclosure
I built the project and manually fixed compiler and linker issues until I got the
muslbuild working. So I'm pretty confident of the patch set 1-5. Then I got a segfaulting app for which i used AI to pinpoint the issues addressed in patch set 6. The code quality of set 6 is rather low for that reason and probably needs rework.