Compiling with musl (an alternate libc)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#61 Post by Ibidem »

goingnuts wrote:I am having problems getting util-linux to build (tried 2.13-pre7 & util-linux-2.22) both with their own problems. I have also tried to search for util-linux-musl-patches but not found something usable...Any hints?
I only need 4 of the aps from it (rev/mount/umount/losetup) but they are quite important as they go in initrd...
Is there a reason you can't use busybox for these?

All the projects I know of so far have used busybox, but...perhaps starch would have that...Ah yes:
https://github.com/StarchLinux/starch-p ... x/PKGBUILD
Not quite enough info to build here; you need to build PAM or disable su, login, and sulogin. Also it seems you might have better luck with 2.21.5.

OK...just going at it my own way (2.22.2)...
./configure --without-udev --without-slang --without-selinux --without-audit --disable-login --disable-su --disable-sulogin --disable-schedutils --disable-nls
CFLAGS="-D_GNU_SOURCE -Os"
I inserted this in include/cpuset.h below the first include:

Code: Select all

#include <sys/types.h>
#ifndef __cpu_mask
#define __NCPUBITS (8 * sizeof(__cpu_mask))
typedef unsigned long int __cpu_mask;
typedef struct
{
  __cpu_mask __bits[ 1024 / __NCPUBITS ];
} cpu_set_t;
#endif
Now it fails in a few places due to a missing <sys/ttydefaults.h> (CEOL et al.); cfdisk is using __sighandler_t instead of sighandler_t; those are most of the problems...

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#62 Post by goingnuts »

Busybox bins will do in initrd but u/mount-FULL is needed in some scripts later (functions4puppy4, rc.shutdown a.o.) so I include them in initrd and copy before switchroot.

Your hints made me able to compile util-linux-2.22...but the mount-bin segfaults.
Below end of running strace on the mount:
stat64("/run", 0xbff4ede8) = -1 ENOENT (No such file or directory)
lstat64("/dev/.mount/utab", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
open("/dev/.mount/utab", O_RDWR|O_CREAT|O_LARGEFILE, 0644) = 3
close(3) = 0
lstat64("/etc/mtab", {st_mode=S_IFLNK|0777, st_size=12, ...}) = 0
open("/proc/self/mountinfo", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/proc/mounts", O_RDONLY|O_LARGEFILE) = 3
readv(3, [{"", 0}, {"rootfs / rootfs rw 0 0\n/dev/sdc5"..., 1024}], 2) = 876
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Well - I will see if I can get the old util-linux-2.13-pre7 working...

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#63 Post by Ibidem »

goingnuts wrote:Busybox bins will do in initrd but u/mount-FULL is needed in some scripts later (functions4puppy4, rc.shutdown a.o.) so I include them in initrd and copy before switchroot.

Your hints made me able to compile util-linux-2.22...but the mount-bin segfaults.
Below end of running strace on the mount:
stat64("/run", 0xbff4ede8) = -1 ENOENT (No such file or directory)
lstat64("/dev/.mount/utab", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
open("/dev/.mount/utab", O_RDWR|O_CREAT|O_LARGEFILE, 0644) = 3
close(3) = 0
lstat64("/etc/mtab", {st_mode=S_IFLNK|0777, st_size=12, ...}) = 0
open("/proc/self/mountinfo", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/proc/mounts", O_RDONLY|O_LARGEFILE) = 3
readv(3, [{"", 0}, {"rootfs / rootfs rw 0 0\n/dev/sdc5"..., 1024}], 2) = 876
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Well - I will see if I can get the old util-linux-2.13-pre7 working...
If you see this issue again, would you mind posting what the output from gdb "where" or "bt full" is?

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#64 Post by goingnuts »

Attached output of both...thx.
I compiled util-linux-2.22 with
CFLAGS="-g -D_BSD_SOURCE -D_GNU_SOURCE -D__KERNEL_STRICT_NAMES" LDFLAGS="-static -Xcompiler -static" \
./configure --prefix=/usr --without-udev --without-slang --without-selinux --without-audit --disable-login --disable-su --disable-sulogin --disable-schedutils --disable-nls --disable-shared --disable-fsck --without-ncurses --disable-utmpdump
and had to remove fsck.minix$(EXEEXT) and hexdump$(EXEEXT) from Makefile after configure to get on building - but I do not think that has anything to do with it. Attached applied patch as well...
Attachments
util-linux-2.22.diff.gz
fake .gz
(1.4 KiB) Downloaded 397 times
mount_dbg.txt.gz
fake .gz - output of gdb mount
(7.26 KiB) Downloaded 382 times

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#65 Post by jamesbond »

Ibidem,

I used to be able to cross-compile 32-bit static binaries with my 64-bit compiler - ie, under Fatdog64's 64-bit gcc, I built 32-bit musl static libs and use that to compile a program (documented in the first page of this thread).

I just tried recent version of musl (9 mar 2013) and I can't do that anymore, using exactly the same config.mak. Is this capability removed?

The error was this: it keeps trying to load crtbegin.o. I fixed this by editing musl-gcc specs file, but then it failed to find "__dividi3" symbol. In case you're wondering, the program I tried to build is guess_fstype.

cheers!
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#66 Post by Ibidem »

jamesbond wrote:Ibidem,

I used to be able to cross-compile 32-bit static binaries with my 64-bit compiler - ie, under Fatdog64's 64-bit gcc, I built 32-bit musl static libs and use that to compile a program (documented in the first page of this thread).

I just tried recent version of musl (9 mar 2013) and I can't do that anymore, using exactly the same config.mak. Is this capability removed?

The error was this: it keeps trying to load crtbegin.o. I fixed this by editing musl-gcc specs file, but then it failed to find "__dividi3" symbol. In case you're wondering, the program I tried to build is guess_fstype.

cheers!
Hmm...
that should come from your host compiler (a subdirectory of /usr/lib/gcc/i486-linux-gnu/ most likely)
And of course you need your compiler to include that in 32-bit form...which I expected that GCC would do by default.
I wonder if the issue is musl-gcc switching to a _replacement_ spec file...but that might not be the real issue, otoh.
However, I can't test anything to do with this, since I have an i386-only system.

Are you using the same compiler? Does just reverting the musl update leave you with something that works?

If the compiler isn't the issue, could you try a git bisect?
http://effectif.com/git/simple-approach ... git-bisect

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#67 Post by jamesbond »

EDIT: Original post deleted.
I did change the compiler, it's just that I didn't remember :oops:
So it's not musl problem at all - it's PEBKAC problem :oops:
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#68 Post by Ibidem »

jamesbond wrote:EDIT: Original post deleted.
I did change the compiler, it's just that I didn't remember :oops:
So it's not musl problem at all - it's PEBKAC problem :oops:
That sort of thing has happened to me also...
I presume that the new compiler can't use -m32 with the old musl, either?
(Did you disable multilib or something like that?)

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#69 Post by jamesbond »

Ibidem wrote:I presume that the new compiler can't use -m32 with the old musl, either?
Yes :oops:
(Did you disable multilib or something like that?)
I don't think so. This is the compiler that got compiled by T2 SDE. The one that worked fast Fatdog 521, with gcc 4.4.3 (also compiled by T2 SDE, earlier version). I saw that is has a "32" directory under the libgcc, that contains all 32-bit startup files. Fatdog 620 which I'm using now uses gcc 4.6.2. I got confused because when I tested musl at that time (version 0.9.0), I was in the middle of intense development for Fatdog 600, but I was still using 521 for daily usage. I had the complete gcc 4.6.2 from T2 package, it has the "32" directory too, but when I extracted it, musl (even the 0.9.0) still doesn't work. I think I probably need to extract the whole package. Anyway, don't worry about this, it isn't musl problem and sorry for being off-topic here, I should probably start another topic to discuss it :oops:
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

musl 0.9.11 released...

#70 Post by Ibidem »

FYI,
musl 0.9.11 is released, and there's currently a discussion of the roadmap going on.
Rich Felker wrote: This release adds the support for the scanf %m allocation
modifier, week-number-related strftime formats, and various legacy
network-related functions. Major improvements have been made to
dynamic linker path handling and pseudo-random number generators.
Major visible bugs/regressions in scanf and mbsrtowcs have been
fixed, as well as several potentially-serious synchronization and
resource-leak bugs and x86_64-specific bugs that resulted in
crashes at startup in some C++ programs or unpredictable signal
behavior.

Download: http://www.etalabs.net/musl/releases/musl-0.9.11.tar.gz
or http://www.musl-libc.org/releases/musl-0.9.11.tar.gz
Includes ether.h (so the official version should be enough to build busybox ether-wake and such), inet_*, the scanf m modifier (malloc() enough memory for the input; needed for util-linux), supports larger dev numbers, and iconv now supports conversion to legacy formats.

The bugfixes may be nice for Fatdog64.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#71 Post by jamesbond »

Musl reaches its version 1.0 milestone last week.

That's not the end though, development is still active and on-going: the team already has a roadmap for post-1.0.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

Post Reply