mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] Allow different paths for static and shared libraries
@ 2015-05-31  7:24 Ismael Luceno
  2015-05-31  7:31 ` Rich Felker
  0 siblings, 1 reply; 10+ messages in thread
From: Ismael Luceno @ 2015-05-31  7:24 UTC (permalink / raw)
  To: musl; +Cc: Ismael Luceno

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
---
 Makefile  | 5 ++++-
 configure | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 3bd7b4d..cffe068 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,7 @@ bindir = $(exec_prefix)/bin
 prefix = /usr/local/musl
 includedir = $(prefix)/include
 libdir = $(prefix)/lib
+shlibdir = $(libdir)
 syslibdir = /lib
 
 SRCS = $(sort $(wildcard src/*/*.c arch/$(ARCH)/src/*.c))
@@ -174,7 +175,9 @@ $(DESTDIR)$(includedir)/%: include/%
 $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so
 	$(INSTALL) -D -l $(libdir)/libc.so $@ || true
 
-install-libs: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),)
+install-libs: $(filter-out $(SHARED_LIBS),$(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%))
+install-libs: $(SHARED_LIBS:lib/%=$(DESTDIR)$(shlibdir)/%)
+install-libs: $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),)
 
 install-headers: $(ALL_INCLUDES:include/%=$(DESTDIR)$(includedir)/%)
 
diff --git a/configure b/configure
index 7b29ae4..7450e29 100755
--- a/configure
+++ b/configure
@@ -16,6 +16,7 @@ Installation directories:
 Fine tuning of the installation directories:
   --bindir=DIR            user executables [EPREFIX/bin]
   --libdir=DIR            library files for the linker [PREFIX/lib]
+  --shlibdir=DIR          shared library files path [=libdir]
   --includedir=DIR        include files for the C compiler [PREFIX/include]
   --syslibdir=DIR         location for the dynamic linker [/lib]
 
@@ -121,6 +122,7 @@ prefix=/usr/local/musl
 exec_prefix='$(prefix)'
 bindir='$(exec_prefix)/bin'
 libdir='$(prefix)/lib'
+shlibdir='$(libdir)'
 includedir='$(prefix)/include'
 syslibdir='/lib'
 target=
@@ -139,6 +141,7 @@ case "$arg" in
 --exec-prefix=*) exec_prefix=${arg#*=} ;;
 --bindir=*) bindir=${arg#*=} ;;
 --libdir=*) libdir=${arg#*=} ;;
+--shlibdir=*) shlibdir=${arg#*=} ;;
 --includedir=*) includedir=${arg#*=} ;;
 --syslibdir=*) syslibdir=${arg#*=} ;;
 --enable-shared|--enable-shared=yes) shared=yes ;;
-- 
2.4.1



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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-05-31  7:24 [PATCH] Allow different paths for static and shared libraries Ismael Luceno
@ 2015-05-31  7:31 ` Rich Felker
  2015-05-31  9:10   ` Ismael Luceno
  0 siblings, 1 reply; 10+ messages in thread
From: Rich Felker @ 2015-05-31  7:31 UTC (permalink / raw)
  To: musl

On Sun, May 31, 2015 at 04:24:25AM -0300, Ismael Luceno wrote:
> Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> ---
>  Makefile  | 5 ++++-
>  configure | 3 +++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> [...]

Is there a motivation/intended-usage-case for this patch?

Rich


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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-05-31  7:31 ` Rich Felker
@ 2015-05-31  9:10   ` Ismael Luceno
  2015-05-31 16:30     ` Rich Felker
  0 siblings, 1 reply; 10+ messages in thread
From: Ismael Luceno @ 2015-05-31  9:10 UTC (permalink / raw)
  To: musl

On Sun, 31 May 2015 03:31:57 -0400
Rich Felker <dalias@libc.org> wrote:
> On Sun, May 31, 2015 at 04:24:25AM -0300, Ismael Luceno wrote:
> > Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> > ---
> >  Makefile  | 5 ++++-
> >  configure | 3 +++
> >  2 files changed, 7 insertions(+), 1 deletion(-)
> > [...]
> 
> Is there a motivation/intended-usage-case for this patch?
> 
> Rich

libc.so must be available at boot, while the static libraries don't
need to, so installing to different paths comes useful.


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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-05-31  9:10   ` Ismael Luceno
@ 2015-05-31 16:30     ` Rich Felker
  2015-05-31 21:51       ` Ismael Luceno
  0 siblings, 1 reply; 10+ messages in thread
From: Rich Felker @ 2015-05-31 16:30 UTC (permalink / raw)
  To: musl

On Sun, May 31, 2015 at 06:10:54AM -0300, Ismael Luceno wrote:
> On Sun, 31 May 2015 03:31:57 -0400
> Rich Felker <dalias@libc.org> wrote:
> > On Sun, May 31, 2015 at 04:24:25AM -0300, Ismael Luceno wrote:
> > > Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> > > ---
> > >  Makefile  | 5 ++++-
> > >  configure | 3 +++
> > >  2 files changed, 7 insertions(+), 1 deletion(-)
> > > [...]
> > 
> > Is there a motivation/intended-usage-case for this patch?
> 
> libc.so must be available at boot, while the static libraries don't
> need to, so installing to different paths comes useful.

In that case I think you're not looking for the semantics of slibdir
but rather using it as a mechanism to make ldso available before
libdir is mounted.

Note that having libc.so and libc.a in different dirs is very
problematic/dangerous at linking time. If the dir containing libc.a is
searched first, then it will get linked into dynamic-linked binaries
and very bad things will happen.

I think this is probably yet another case of wanting ldso to be the
canonical file and libc.so to be a symlink to it (reversing symlink
direction). This issue has come up many times before but I always
forget how it was resolved (or not) and why nothing changed...

Rich


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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-05-31 16:30     ` Rich Felker
@ 2015-05-31 21:51       ` Ismael Luceno
  2015-06-01  1:27         ` Rich Felker
  0 siblings, 1 reply; 10+ messages in thread
From: Ismael Luceno @ 2015-05-31 21:51 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

On Sun, 31 May 2015 12:30:34 -0400
Rich Felker <dalias@libc.org> wrote:
> On Sun, May 31, 2015 at 06:10:54AM -0300, Ismael Luceno wrote:
> > On Sun, 31 May 2015 03:31:57 -0400
> > Rich Felker <dalias@libc.org> wrote:
> > > On Sun, May 31, 2015 at 04:24:25AM -0300, Ismael Luceno wrote:
> > > > Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> > > > ---
> > > >  Makefile  | 5 ++++-
> > > >  configure | 3 +++
> > > >  2 files changed, 7 insertions(+), 1 deletion(-)
> > > > [...]
> > > 
> > > Is there a motivation/intended-usage-case for this patch?
> > 
> > libc.so must be available at boot, while the static libraries don't
> > need to, so installing to different paths comes useful.
> 
> In that case I think you're not looking for the semantics of slibdir
> but rather using it as a mechanism to make ldso available before
> libdir is mounted.
> 
> Note that having libc.so and libc.a in different dirs is very
> problematic/dangerous at linking time. If the dir containing libc.a is
> searched first, then it will get linked into dynamic-linked binaries
> and very bad things will happen.
> 
> I think this is probably yet another case of wanting ldso to be the
> canonical file and libc.so to be a symlink to it (reversing symlink
> direction). This issue has come up many times before but I always
> forget how it was resolved (or not) and why nothing changed...
> 
> Rich

A ld script in place of libc.so, containing "GROUP ( /lib/libc.so )",
would workaround that.


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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-05-31 21:51       ` Ismael Luceno
@ 2015-06-01  1:27         ` Rich Felker
  2015-06-01 18:41           ` Ismael Luceno
  2015-06-01 18:54           ` Daniel Cegiełka
  0 siblings, 2 replies; 10+ messages in thread
From: Rich Felker @ 2015-06-01  1:27 UTC (permalink / raw)
  To: musl

On Sun, May 31, 2015 at 06:51:42PM -0300, Ismael Luceno wrote:
> On Sun, 31 May 2015 12:30:34 -0400
> Rich Felker <dalias@libc.org> wrote:
> > On Sun, May 31, 2015 at 06:10:54AM -0300, Ismael Luceno wrote:
> > > On Sun, 31 May 2015 03:31:57 -0400
> > > Rich Felker <dalias@libc.org> wrote:
> > > > On Sun, May 31, 2015 at 04:24:25AM -0300, Ismael Luceno wrote:
> > > > > Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> > > > > ---
> > > > >  Makefile  | 5 ++++-
> > > > >  configure | 3 +++
> > > > >  2 files changed, 7 insertions(+), 1 deletion(-)
> > > > > [...]
> > > > 
> > > > Is there a motivation/intended-usage-case for this patch?
> > > 
> > > libc.so must be available at boot, while the static libraries don't
> > > need to, so installing to different paths comes useful.
> > 
> > In that case I think you're not looking for the semantics of slibdir
> > but rather using it as a mechanism to make ldso available before
> > libdir is mounted.
> > 
> > Note that having libc.so and libc.a in different dirs is very
> > problematic/dangerous at linking time. If the dir containing libc.a is
> > searched first, then it will get linked into dynamic-linked binaries
> > and very bad things will happen.
> > 
> > I think this is probably yet another case of wanting ldso to be the
> > canonical file and libc.so to be a symlink to it (reversing symlink
> > direction). This issue has come up many times before but I always
> > forget how it was resolved (or not) and why nothing changed...
> 
> A ld script in place of libc.so, containing "GROUP ( /lib/libc.so )",
> would workaround that.

Are you sure? I think that would result in a dependency for
"/lib/libc.so" getting put in the binary rather than one for
"libc.so", and that's also a serious bug.

Rich


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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-06-01  1:27         ` Rich Felker
@ 2015-06-01 18:41           ` Ismael Luceno
  2015-06-01 18:58             ` Rich Felker
  2015-06-01 18:54           ` Daniel Cegiełka
  1 sibling, 1 reply; 10+ messages in thread
From: Ismael Luceno @ 2015-06-01 18:41 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

On Sun, 31 May 2015 21:27:25 -0400
Rich Felker <dalias@libc.org> wrote:
> On Sun, May 31, 2015 at 06:51:42PM -0300, Ismael Luceno wrote:
> > On Sun, 31 May 2015 12:30:34 -0400
> > Rich Felker <dalias@libc.org> wrote:
> > > On Sun, May 31, 2015 at 06:10:54AM -0300, Ismael Luceno wrote:
> > > > On Sun, 31 May 2015 03:31:57 -0400
> > > > Rich Felker <dalias@libc.org> wrote:
> > > > > On Sun, May 31, 2015 at 04:24:25AM -0300, Ismael Luceno wrote:
> > > > > > Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> > > > > > ---
> > > > > >  Makefile  | 5 ++++-
> > > > > >  configure | 3 +++
> > > > > >  2 files changed, 7 insertions(+), 1 deletion(-)
> > > > > > [...]
> > > > > 
> > > > > Is there a motivation/intended-usage-case for this patch?
> > > > 
> > > > libc.so must be available at boot, while the static libraries
> > > > don't need to, so installing to different paths comes useful.
> > > 
> > > In that case I think you're not looking for the semantics of
> > > slibdir but rather using it as a mechanism to make ldso available
> > > before libdir is mounted.
> > > 
> > > Note that having libc.so and libc.a in different dirs is very
> > > problematic/dangerous at linking time. If the dir containing
> > > libc.a is searched first, then it will get linked into
> > > dynamic-linked binaries and very bad things will happen.
> > > 
> > > I think this is probably yet another case of wanting ldso to be
> > > the canonical file and libc.so to be a symlink to it (reversing
> > > symlink direction). This issue has come up many times before but
> > > I always forget how it was resolved (or not) and why nothing
> > > changed...
> > 
> > A ld script in place of libc.so, containing "GROUP ( /lib/libc.so
> > )", would workaround that.
> 
> Are you sure? I think that would result in a dependency for
> "/lib/libc.so" getting put in the binary rather than one for
> "libc.so", and that's also a serious bug.

That's what glibc does. Hmm...


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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-06-01  1:27         ` Rich Felker
  2015-06-01 18:41           ` Ismael Luceno
@ 2015-06-01 18:54           ` Daniel Cegiełka
  2015-06-06 18:21             ` Anthony G. Basile
  1 sibling, 1 reply; 10+ messages in thread
From: Daniel Cegiełka @ 2015-06-01 18:54 UTC (permalink / raw)
  To: musl

2015-06-01 3:27 GMT+02:00 Rich Felker <dalias@libc.org>:
> On Sun, May 31, 2015 at 06:51:42PM -0300, Ismael Luceno wrote:
>> On Sun, 31 May 2015 12:30:34 -0400
>> Rich Felker <dalias@libc.org> wrote:

>> A ld script in place of libc.so, containing "GROUP ( /lib/libc.so )",
>> would workaround that.
>
> Are you sure? I think that would result in a dependency for
> "/lib/libc.so" getting put in the binary rather than one for
> "libc.so", and that's also a serious bug.

from gentoo:

# cat /usr/lib/libc.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a  AS_NEEDED (
/lib64/ld-linux-x86-64.so.2 ) )

btw. I am not a fan of this solution.

Daniel


> Rich


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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-06-01 18:41           ` Ismael Luceno
@ 2015-06-01 18:58             ` Rich Felker
  0 siblings, 0 replies; 10+ messages in thread
From: Rich Felker @ 2015-06-01 18:58 UTC (permalink / raw)
  To: musl

On Mon, Jun 01, 2015 at 03:41:28PM -0300, Ismael Luceno wrote:
> On Sun, 31 May 2015 21:27:25 -0400
> Rich Felker <dalias@libc.org> wrote:
> > On Sun, May 31, 2015 at 06:51:42PM -0300, Ismael Luceno wrote:
> > > On Sun, 31 May 2015 12:30:34 -0400
> > > Rich Felker <dalias@libc.org> wrote:
> > > > On Sun, May 31, 2015 at 06:10:54AM -0300, Ismael Luceno wrote:
> > > > > On Sun, 31 May 2015 03:31:57 -0400
> > > > > Rich Felker <dalias@libc.org> wrote:
> > > > > > On Sun, May 31, 2015 at 04:24:25AM -0300, Ismael Luceno wrote:
> > > > > > > Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> > > > > > > ---
> > > > > > >  Makefile  | 5 ++++-
> > > > > > >  configure | 3 +++
> > > > > > >  2 files changed, 7 insertions(+), 1 deletion(-)
> > > > > > > [...]
> > > > > > 
> > > > > > Is there a motivation/intended-usage-case for this patch?
> > > > > 
> > > > > libc.so must be available at boot, while the static libraries
> > > > > don't need to, so installing to different paths comes useful.
> > > > 
> > > > In that case I think you're not looking for the semantics of
> > > > slibdir but rather using it as a mechanism to make ldso available
> > > > before libdir is mounted.
> > > > 
> > > > Note that having libc.so and libc.a in different dirs is very
> > > > problematic/dangerous at linking time. If the dir containing
> > > > libc.a is searched first, then it will get linked into
> > > > dynamic-linked binaries and very bad things will happen.
> > > > 
> > > > I think this is probably yet another case of wanting ldso to be
> > > > the canonical file and libc.so to be a symlink to it (reversing
> > > > symlink direction). This issue has come up many times before but
> > > > I always forget how it was resolved (or not) and why nothing
> > > > changed...
> > > 
> > > A ld script in place of libc.so, containing "GROUP ( /lib/libc.so
> > > )", would workaround that.
> > 
> > Are you sure? I think that would result in a dependency for
> > "/lib/libc.so" getting put in the binary rather than one for
> > "libc.so", and that's also a serious bug.
> 
> That's what glibc does. Hmm...

Indeed. I suppose the path part of the pathname there is ignored when
producing DT_NEEDED records, then, or else something else weird is
going on with glibc -- perhaps the SONAME in glibc forces the path to
be removed and the whole pathname replaced with the SONAME?

In any case I don't think this is the right solution for the problem
at hand.

Rich


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

* Re: [PATCH] Allow different paths for static and shared libraries
  2015-06-01 18:54           ` Daniel Cegiełka
@ 2015-06-06 18:21             ` Anthony G. Basile
  0 siblings, 0 replies; 10+ messages in thread
From: Anthony G. Basile @ 2015-06-06 18:21 UTC (permalink / raw)
  To: musl

On 6/1/15 2:54 PM, Daniel Cegiełka wrote:
> 2015-06-01 3:27 GMT+02:00 Rich Felker <dalias@libc.org>:
>> On Sun, May 31, 2015 at 06:51:42PM -0300, Ismael Luceno wrote:
>>> On Sun, 31 May 2015 12:30:34 -0400
>>> Rich Felker <dalias@libc.org> wrote:
>
>>> A ld script in place of libc.so, containing "GROUP ( /lib/libc.so )",
>>> would workaround that.
>>
>> Are you sure? I think that would result in a dependency for
>> "/lib/libc.so" getting put in the binary rather than one for
>> "libc.so", and that's also a serious bug.
>
> from gentoo:
>
> # cat /usr/lib/libc.so
> /* GNU ld script
>     Use the shared library, but some functions are only in
>     the static library, so try that secondarily.  */
> OUTPUT_FORMAT(elf64-x86-64)
> GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a  AS_NEEDED (
> /lib64/ld-linux-x86-64.so.2 ) )
>
> btw. I am not a fan of this solution.
>
> Daniel
>
>
>> Rich

Just reading some of my backmail here and I want to clarify a point. 
That file was taken from a gentoo *glibc* system not musl.  On the 
stage3 tarballs I push out we have:

# file /usr/lib/libc.so
/usr/lib/libc.so: ELF 64-bit LSB shared object, x86-64, version 1 
(SYSV), dynamically linked, stripped

Admittedly other .so's in /usr/lib use similar ld scripts, this is not 
the case for libc.so on gentoo musl stages.

I know this is a bit of an aside, but I didn't want readers of this list 
to be mislead.

-- 
Anthony G. Basile, Ph. D.
Chair of Information Technology
D'Youville College
Buffalo, NY 14201
(716) 829-8197


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

end of thread, other threads:[~2015-06-06 18:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-31  7:24 [PATCH] Allow different paths for static and shared libraries Ismael Luceno
2015-05-31  7:31 ` Rich Felker
2015-05-31  9:10   ` Ismael Luceno
2015-05-31 16:30     ` Rich Felker
2015-05-31 21:51       ` Ismael Luceno
2015-06-01  1:27         ` Rich Felker
2015-06-01 18:41           ` Ismael Luceno
2015-06-01 18:58             ` Rich Felker
2015-06-01 18:54           ` Daniel Cegiełka
2015-06-06 18:21             ` Anthony G. Basile

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).