Linux MUSL

Anything that prevents you from playing the game properly. Do you have issues playing for the game, downloading it or successfully running it on your computer? Let us know here.
Post Reply
swoboderz
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Sep 03, 2022 1:06 am
Contact:

Linux MUSL

Post by swoboderz »

So i have been experimenting with a MUSL libc and heres some problems i have run into.

Code: Select all

dots@gentpad ~ $ factorio
Error relocating /home/dots/Games/factorio/bin/x64/factorio: setcontext: symbol not found
Error relocating /home/dots/Games/factorio/bin/x64/factorio: makecontext: symbol not found
Error relocating /home/dots/Games/factorio/bin/x64/factorio: __res_nquery: symbol not found
Error relocating /home/dots/Games/factorio/bin/x64/factorio: __dn_expand: symbol not found
After installing libucontext from official repository:

Code: Select all

dots@gentpad ~ $ factorio
Error relocating /home/dots/Games/factorio/bin/x64/factorio: __res_nquery: symbol not found
Error relocating /home/dots/Games/factorio/bin/x64/factorio: __dn_expand: symbol not found
I do know the functions just above come from a libresolv but it seems the MUSL libc does not contain it. i tried doing a quick hack of designing the function signatures by creating a gcompat patch (glibc compat layer) myself with various combos of returning -1, 0, or x > 0 but it segfaults.

I can confirm it wasnt the libucontext but instead the patch, which changes the ld-linux (ld-musl) binary from the following:

Code: Select all

(lldb) run
Process 5712 launched: '/home/dots/Games/factorio/bin/x64/factorio' (x86_64)
Process 5712 stopped
* thread #1, name = 'ld-musl-x86_64.', stop reason = exec
    frame #0: 0x00007ffff7fc3027 libc.so`_dlstart
libc.so`_dlstart:
->  0x7ffff7fc3027 <+0>:  xorq   %rbp, %rbp
    0x7ffff7fc302a <+3>:  movq   %rsp, %rdi
    0x7ffff7fc302d <+6>:  leaq   0x37df4(%rip), %rsi
    0x7ffff7fc3034 <+13>: andq   $-0x10, %rsp
(lldb) continue
Process 5712 resuming
Process 5712 stopped
* thread #1, name = 'ld-musl-x86_64.', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x000000000172b8e5
->  0x172b8e5: andw   (%rax,%r12,2), %dx
    0x172b8ea: jne    0x172b848
    0x172b8f0: andl   $0x1, %r15d
    0x172b8f4: je     0x172b910
(lldb)
I am wondering what it would actually take to get MUSL support. or any ideas on how to get around the unfound symbols (i had previously assumed the Mod menu would be broken before i found it segfaulting with my cheap imitation)
Thanks! :D

Rseding91
Factorio Staff
Factorio Staff
Posts: 12349
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Linux MUSL

Post by Rseding91 »

But why?
If you want to get ahold of me I'm almost always on Discord.

swoboderz
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Sep 03, 2022 1:06 am
Contact:

Re: Linux MUSL

Post by swoboderz »

Rseding91 wrote:
Sat Sep 03, 2022 2:53 pm
But why?
What do you mean?

Rseding91
Factorio Staff
Factorio Staff
Posts: 12349
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Linux MUSL

Post by Rseding91 »

Why try to get a 3rd party library working with the game when you could just *play* the game as is?
If you want to get ahold of me I'm almost always on Discord.

swoboderz
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Sep 03, 2022 1:06 am
Contact:

Re: Linux MUSL

Post by swoboderz »

Rseding91 wrote:
Sat Sep 03, 2022 5:04 pm
Why try to get a 3rd party library working with the game when you could just *play* the game as is?
there are differences between the MUSL libc ABI and the GLIBC ABI. MUSL is trying to become a full replacement, however there remains a package "gcompat" for more non-posix standards that glibc happenned to create to add support outside the MUSL libc. if you are unaware, a LibC maps C standard functions to a program. On my current operating system, factorio simply will not run because its not using the GNU Libc. Everything if installed up until the point of factorio was source compiled. so there was no issue.

mrvn
Smart Inserter
Smart Inserter
Posts: 5361
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Linux MUSL

Post by mrvn »

You should check your code. You obviously implemented the missing functions wrong.

res_nquery() is used to find the factorio server to check for updates, to download mods and for multiplayer. While you can probably play offline (which would allow a return -1 for the function) that would limit the game. Returning 0 seems kind of odd and returning x > 0 will definetly not work if you don't actually fill in the answer buffer.

You should write a dummy libresolv linked against musl.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1431
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Linux MUSL

Post by ptx0 »

Rseding91 wrote:
Sat Sep 03, 2022 5:04 pm
Why try to get a 3rd party library working with the game when you could just *play* the game as is?
well, Alpine Linux is based on musl instead of libc.

swoboderz
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Sep 03, 2022 1:06 am
Contact:

Re: Linux MUSL

Post by swoboderz »

mrvn wrote:
Sun Sep 04, 2022 12:12 am
You should check your code. You obviously implemented the missing functions wrong.

res_nquery() is used to find the factorio server to check for updates, to download mods and for multiplayer. While you can probably play offline (which would allow a return -1 for the function) that would limit the game. Returning 0 seems kind of odd and returning x > 0 will definetly not work if you don't actually fill in the answer buffer.

You should write a dummy libresolv linked against musl.
I actually tried returning -1 and it proceeded to segfault anyway

mrvn
Smart Inserter
Smart Inserter
Posts: 5361
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Linux MUSL

Post by mrvn »

swoboderz wrote:
Mon Sep 05, 2022 12:21 am
mrvn wrote:
Sun Sep 04, 2022 12:12 am
You should check your code. You obviously implemented the missing functions wrong.

res_nquery() is used to find the factorio server to check for updates, to download mods and for multiplayer. While you can probably play offline (which would allow a return -1 for the function) that would limit the game. Returning 0 seems kind of odd and returning x > 0 will definetly not work if you don't actually fill in the answer buffer.

You should write a dummy libresolv linked against musl.
I actually tried returning -1 and it proceeded to segfault anyway
Did you set h_errno? Returning an error of SUCCESS (or whatever value is in h_errno currently) might be confusing the code.

User avatar
vinzenz
Factorio Staff
Factorio Staff
Posts: 97
Joined: Mon Aug 02, 2021 6:45 pm
Contact:

Re: Linux MUSL

Post by vinzenz »

swoboderz wrote:
Mon Sep 05, 2022 12:21 am
I actually tried returning -1 and it proceeded to segfault anyway

you can try stubbing res_ninit to return -1, so Factorio doesn't even try to engage with libresolv
bringing the oops to devops

Post Reply

Return to “Technical Help”