This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[rfc] dont use absolute paths in ldscripts if they arent needed
- From: Mike Frysinger <vapier at gentoo dot org>
- To: libc-alpha at sourceware dot org
- Date: Sun, 2 Apr 2006 05:44:29 -0400
- Subject: [rfc] dont use absolute paths in ldscripts if they arent needed
- Geoman: IS A RETARD
i've been playing with cross-compilers in Gentoo when i noticed that the
ldscripts installed by glibc always use full paths. in a normal setup, these
are clearly required as libc.so.6 goes in /lib/ while libc.so goes
in /usr/lib/. in a cross-compiler setup though, you usually have libc.so.6
and libc.so in the same directory (like /usr/target/lib/). encoding this
full path can cause problems when using sysroot options with binutils and
gcc. crosstool gets around this by simply running a sed on the linker
scripts and deleting all leading path elements. that seems kind of hackish
so i whipped together a patch that i've been testing in Gentoo with mips64
multilib cross-compilers and some x86/amd64/ppc native installs that updates
the glibc build files to only generate absolute paths in the linker scripts
when $(slibdir) and $(libdir) are not the same.
-mike
2006-04-02 Mike Frysinger <vapier@gentoo.org>
* Makerules ($(inst_libdir)/libc.so): Only use absolute paths necessary.
* nptl/Makerules ($(inst_libdir)/libpthread.so): Likewise.
--- libc/Makerules
+++ libc/Makerules
@@ -972,6 +972,14 @@ ifndef subdir
# We need to use absolute paths since otherwise local copies (if they exist)
# of the files are taken by the linker.
install: $(inst_libdir)/libc.so
+
+ifeq ($(slibdir),$(libdir))
+ldscript_slibdir =
+ldscript_libdir =
+else
+ldscript_slibdir = $(slibdir)/
+ldscript_libdir = $(libdir)/
+endif
$(inst_libdir)/libc.so: $(common-objpfx)format.lds \
$(common-objpfx)libc.so$(libc.so-version) \
$(inst_libdir)/$(patsubst %,$(libtype.oS),\
@@ -981,9 +989,9 @@ $(inst_libdir)/libc.so: $(common-objpfx)
echo ' Use the shared library, but some functions are only in';\
echo ' the static library, so try that secondarily. */';\
cat $<; \
- echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
- '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
- ' AS_NEEDED (' $(slibdir)/$(rtld-installed-name) ') )' \
+ echo 'GROUP ( $(ldscript_slibdir)libc.so$(libc.so-version)' \
+ '$(ldscript_libdir)$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
+ ' AS_NEEDED (' $(ldscript_slibdir)$(rtld-installed-name) ') )' \
) > $@.new
mv -f $@.new $@
--- libc/nptl/Makefile
+++ libc/nptl/Makefile
@@ -368,6 +368,13 @@ lib-noranlib: $(addprefix $(objpfx),$(ex
# of the files are taken by the linker.
install: $(inst_libdir)/libpthread.so
+ifeq ($(slibdir),$(libdir))
+ldscript_slibdir =
+ldscript_libdir =
+else
+ldscript_slibdir = $(slibdir)/
+ldscript_libdir = $(libdir)/
+endif
$(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \
$(objpfx)libpthread.so$(libpthread.so-version) \
$(inst_libdir)/$(patsubst %,$(libtype.oS),\
@@ -377,8 +384,8 @@ $(inst_libdir)/libpthread.so: $(common-o
echo ' Use the shared library, but some functions are only in';\
echo ' the static library, so try that secondarily. */';\
cat $<; \
- echo 'GROUP ( $(slibdir)/libpthread.so$(libpthread.so-version)' \
- '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\
+ echo 'GROUP ( $(ldscript_slibdir)libpthread.so$(libpthread.so-version)' \
+ '$(ldscript_libdir)$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\
')' \
) > $@.new
mv -f $@.new $@