|
Message-ID: <20221113170918.GD7728@brightrain.aerifal.cx> Date: Sun, 13 Nov 2022 12:09:18 -0500 From: Rich Felker <dalias@...c.org> To: Fangrui Song <i@...kray.me>, Rui Ueyama <rui314@...il.com>, musl@...ts.openwall.com Subject: Re: `musl-gcc -static` and lld/mold On Sun, Nov 13, 2022 at 04:51:26PM +0100, Szabolcs Nagy wrote: > * Fangrui Song <i@...kray.me> [2022-11-12 19:26:53 -0800]: > > On 2022-11-13, Rui Ueyama wrote: > > > diff --git a/tools/musl-gcc.specs.sh b/tools/musl-gcc.specs.sh > > > index 30492574..ffb46d70 100644 > > > --- a/tools/musl-gcc.specs.sh > > > +++ b/tools/musl-gcc.specs.sh > > > @@ -23,7 +23,7 @@ libgcc.a%s %:if-exists(libgcc_eh.a%s) > > > crtendS.o%s $libdir/crtn.o > > > > > > *link: > > > --dynamic-linker $ldso -nostdlib %{shared:-shared} %{static:-static} > > > %{rdynamic:-export-dynamic} > > > +%{!static:-dynamic-linker $ldso} -nostdlib %{shared:-shared} > > > %{static:-static} %{rdynamic:-export-dynamic} > > > > > > *esp_link: > > > > I use this patch which handles -static-pie as well: https://github.com/MaskRay/musl/tree/musl-gcc > > i guess you meant > https://github.com/MaskRay/musl/commit/e8a9c5489b9be78a4532712045df6f7cd45c4de6 > (would be nice if it was submitted to the list) > > > > > In addition, I use `*libdir: $libdir` to avoid absolute path references > > so that the spec file can be easily fixed after moving the build directory. > > i think that should only affect the paths used at compile/link time > but not paths at runtime: > > %{static|static-pie:; :-dynamic-linker %(libdir)/libc.so} > > different runtime path should be a separate option. > (just like --syslibdir is separate from --libdir, e.g. syslibdir > could be a variable too) Yes, this change is wrong. Use of $ldso here was very intentional. > there is also interference with the -static-pie handling of gcc's > driver which might cause trouble when -static and -static-pie is mixed: > > %{static-pie:-static -pie --no-dynamic-linker -z text} While musl-target-patched gcc supports -static -pie (or -static with default-pie) as static-pie, we can't assume a gcc we're repurposing does that, so I think we need to make -static just act as classic static (no pie). This can probably be in the "else case" for -static-pie though, so that, if both are included, -static-pie takes precedence. Note that we can't just implement the desired behavior for -static afaict because it requires existence of --no-dynamic-linker, which the host ld might not have. So, something like: *link: -nostdlib %{static-pie:-static -pie --no-dynamic-linker -z text;%{static:-static;-dynamic-linker $ldso %{shared:-shared}}} %{rdynamic:-export-dynamic}
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.