mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] `musl-gcc -static` and lld/mold
@ 2022-11-13  0:11 Rui Ueyama
  2022-11-13  0:38 ` Rich Felker
  0 siblings, 1 reply; 8+ messages in thread
From: Rui Ueyama @ 2022-11-13  0:11 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 822 bytes --]

Hi,

I think I found a musl-gcc issue. It looks like musl-gcc always appends
`-dynamic-linker /lib/ld-musl-x86_64.so.1` even if `-static` is given. That
causes a created program to immediately crash on startup as you can see
below:

$ cat hello.c
#include <stdio.h>
int main() { printf("Hello\n"); }

$ musl-gcc -static -fuse-ld=lld hello.c -o hello

$ ./hello
Segmentation fault (core dumped)

$ musl-gcc -static -fuse-ld=lld hello.c -o hello -Wl,-no-dynamic-linker
$ ./hello
Hello

This also happens to my new linker, mold, as well. `-dynamic-linker` option
is passed to the linker, and lld and mold do what it is told to do, so I
don't think it is a linker's bug. Rather, it's a compiler front end's bug
that passes the unnecessary command line option. Can you not to append
`-dynamic-linker` if `-static`?

Rui Ueyama

[-- Attachment #2: Type: text/html, Size: 1108 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-13 18:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-13  0:11 [musl] `musl-gcc -static` and lld/mold Rui Ueyama
2022-11-13  0:38 ` Rich Felker
2022-11-13  0:46   ` Rui Ueyama
2022-11-13  0:55     ` Rui Ueyama
2022-11-13  3:26       ` Fangrui Song
2022-11-13 15:51         ` Szabolcs Nagy
2022-11-13 17:09           ` Rich Felker
2022-11-13 18:30             ` Fangrui Song

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).