unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: "David Arroyo" <david@aqwari.net>
To: help-guix@gnu.org
Cc: zimoun <zimon.toutoune@gmail.com>
Subject: Re: Defining a toolchain with musl libc
Date: Mon, 09 May 2022 19:54:13 -0400	[thread overview]
Message-ID: <253ea756-2eb5-44fc-9f83-d27b3d0db005@www.fastmail.com> (raw)
In-Reply-To: <87h75y4oq9.fsf@gmail.com>

Hi Simon, thanks for your reply!

I must confess that I started this thread with an XY problem; my problem was with execline binaries segfaulting after I performed a pivot_root operation. I don't fully recall why, but I suspected the segfault occurred  when execv() tried to load and/or use a dynamic library. I was trying to verify this theory by statically linking execline and trying to reproduce the crash.

But since then there some updates to the glibc package and I cannot reproduce the issue anymore. I could try to go back with the time-machine and reproduce again but it's not urgent for me anymore.

On Mon, May 9, 2022, at 13:09, zimoun wrote:
> On Mon, 11 Apr 2022 at 22:34, "David Arroyo" <david@aqwari.net> wrote:
> Maybe “guix graph --path” could help.  Well, maybe skalibs and/or
> execline retain a reference to bash or bash-minimal which probably drags
> glibc and gcc.

That is a nifty tool, I didn't know about the `--path` option. Unfortunately it didn't seem to work here, I tried the following from the root of my channel repo:

	$ guix graph --path --type=bag-emerged -L $(pwd) -e '(@ (aqwari packages skaware) execline-musl-static)' glibc
	guix graph: error: no path from 'execline-musl-static@2.8.1.0' to 'glibc@2.33'

However, if I render the full `--type=bag-emerged` graph, massive as it is, glibc is clearly present and referenced by dozens of other nodes. There are too many edges for me to trace each one, but it looks like the path you predicted from execline -> bash-minimal -> glibc is there.

> Note that usually musl comes from a wrapper around gcc, named
> ’musl-gcc’.  It is specifically disabled by the musl package:
>
>        #:configure-flags
>        (list "--disable-gcc-wrapper")))
>
> I do not know why.  Maybe because at the time of commit
> ce728f70e5ef8783a28652e382c2c9f61c7b4c06, it was not necessary or maybe
> because the license of musl is incompatible with the one of GCC.

Newer versions of GCC actually have an `-mmusl` flag and allow for target
triplets include `-musl-`, which appear to accomplish something similar. In fact, in a separate project this G-expression worked well for compiling a single C file with musl, statically:

https://git.sr.ht/~droyo/guix-channel/tree/640fe1b4eabe9a3aaa4b532c0ed71e7abb74dae8/item/aqwari/namespace.scm#L288-299

> Well, I would take this path: rebuild a variant of musl with the wrapper
> and try to make a C toolchain using this wrapper.

This sounds like a reasonable approach. The only potential issue I see is this option in mus-gcc's spec file:

	*link:
	-dynamic-linker /lib/ld-musl-x86_64.so.1 -nostdlib %{shared:-shared} %{static:-static} %{rdynamic:-export-dynamic}

but I'm not producing dynamically linked binaries anyway. While this is not urgent for me anymore, I'm still interested and I will probably try this in the next few weeks.

> Maybe the package musl-cross could be interesting.

I will take a look. Initially I was put off because that package hard-codes its own gcc, linux headers, and binutils versions rather than tracking the common packages. But it could be good inspiration.

Thanks again!
David


  reply	other threads:[~2022-05-09 23:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12  2:34 Defining a toolchain with musl libc David Arroyo
2022-04-12 18:22 ` David Arroyo
2022-05-09 17:09 ` zimoun
2022-05-09 23:54   ` David Arroyo [this message]
2022-05-10  8:00     ` zimoun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=253ea756-2eb5-44fc-9f83-d27b3d0db005@www.fastmail.com \
    --to=david@aqwari.net \
    --cc=help-guix@gnu.org \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).