Closed ghost closed 7 months ago
@zamfofex Sounds great!
I think alias
looks difficult to support,
but others are nice to have.
Would you please tell me how to compile musl using xcc? Thanks!
Would you please tell me how to compile musl using xcc? Thanks!
First, apply this patch to musl 1.2.4: https://gist.github.com/zamfofex/5caf961fe7012929de0aadf71b7c4898
Then, make sure to replace the file name for CC
in config.mak
with the file name of xcc on your actual computer. Finally, just run make
from the patched musl’s directory.
Note that there is still work to be done to get it to “work” correctly, but it should compile, at least! (I tried on Linux only.) Also, it skips compiling some parts of the library like src/thread
and src/math
which currently seem problematic.
@zamfofex Thanks! Using the diff, I succeed to compile musl using xcc!
My memo: patch -p1 -d . < ../musl-xcc.diff
I have updated the compiler to allow __asm
declaration in base text (top level),
now you can put the code in crt_arch.h
:
__asm(
".text \n"
".globl " START " \n"
START ": \n"
" xor %rbp,%rbp \n"
" mov %rsp,%rdi \n"
// ".weak _DYNAMIC \n"
// ".hidden _DYNAMIC \n"
// " lea _DYNAMIC(%rip),%rsi \n"
" and $-16,%rsp \n"
" call " START "_c \n"
);
@zamfofex I'm going to close this issue. Please open new issue if you still have a problem.
Hello, thank you for your work! :tada: I wonder whether it’d be desirable to replace xcc’s own C library (in libsrc
) with musl. Is that something you are interested in? If you feel like that’s the direction you want to go, I could see if I can progress further in getting musl to compile and work fully, and eventually submit a pull request to replace it in.
I don't currently have a strong motivation to replace library code, but I think it's worth having the flexibility to choose other libraries.
I’m not sure whether you are interested in using a different libc for your project, but I feel like it would be a very neat approach to get more programs to compile under it more easily.
I’ve been experimenting with porting musl to xcc, and I found only a few things that seemed to prevent me from compiling most of the library!
Porobably the biggest issue is xcc’s lack of support for the
alias("")
attribute. Other than that, I also ran into some syntactical issues:int foo(), bar();
(used sparringly)0xF.8p12
(used extensively)Other than that, I haven’t tried compiling some parts of the library like pthread and I have just added stubs for syscalls, but given that (with few changes) most of musl could be compiled with xcc already, it seems very promising!
Ultimately, maybe it would be more sensible to remove the need to implement syscalls in the musl port by instead taking the low level function implementations (like
read
, etc.) from xcc’s libsrc, so that it can work more easily across xcc’s platforms like Mac and Wasm. (Something similar to whatwasi-libc
does.)