From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27593 invoked by alias); 10 Apr 2003 22:31:56 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 27541 invoked from network); 10 Apr 2003 22:31:55 -0000 Received: from unknown (HELO localhost.localdomain) (195.113.19.66) by sources.redhat.com with SMTP; 10 Apr 2003 22:31:55 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h3AMVqqO001076; Fri, 11 Apr 2003 00:31:52 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id h3AMVqRH001065; Fri, 11 Apr 2003 00:31:52 +0200 Date: Thu, 10 Apr 2003 22:31:00 -0000 From: Jakub Jelinek To: Roland McGrath , Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Replace the ugly multilib libpthread hacks with something nicer Message-ID: <20030410223152.GD16629@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2003-04/txt/msg00028.txt.bz2 Hi! glibc built on ppc64 using gcc -m64 where gcc defaults to -m32 if no -m64 is given results in all libpthread tests failed. Instead of hacking yet another ugly hack ala sparc or x86_64, the following patch hardlinks the crtfiles to where gcc will be actually looking for them. The search order of gcc when searching for these files is to go through gcc -print-search-dirs | sed -n 's/^libraries: =//p' in the first round appending the GCC resp. OS multidir names (depending on whether a particular directory is under toolchain or OS control) and if a file is not found there, it does another round without the multidirs appended. Say on the above mentioned ppc configuration, GCC multidir is 64 and OS multidir is ../lib64, one of the first directories it tries is $(objpfx)64, later on /usr/lib/../lib64 where it actually finds the crt file and stops, but if it would not find it there, a little bit later it would search $(objpfx) and if the file wouldn't be there it would continue to /usr/lib/. With this patch, the crt files are found immediately in a subdir of $(objpfx). NPTL would need similar change (although it only uses crti.o and not crtn.o). 2003-04-10 Jakub Jelinek * Makefile (multidir, crti-objs, crtn-objs): New variables. (generated-dirs): Add pathname component of multidir. (omit-deps, extra-objs): Include $(multidir)/crt? as well. ($(objpfx)libpthread.so): Depend on $(multidir)/crt?.o as well. ($(objpfx)$(multidir), $(objpfx)$(multidir)/crti.o, $(objpfx)$(multidir)/crtn.o): New. * sysdeps/unix/sysv/linux/sparc/Makefile: Removed. * sysdeps/unix/sysv/linux/x86_64/Makefile (LDFLAGS-pthread.so, before-compile, generated): Don't generate and use specs. ($(objpfx)specs): Remove. --- linuxthreads/sysdeps/unix/sysv/linux/sparc/Makefile.jj 2003-03-20 05:58:49.000000000 -0500 +++ linuxthreads/sysdeps/unix/sysv/linux/sparc/Makefile 2003-04-10 18:08:01.000000000 -0400 @@ -1,11 +0,0 @@ -ifeq ($(subdir),linuxthreads) -# gcc has /usr/lib{,64}/crti.o hardcoded in the specs file, because otherwise -# it would normally find {64,32}bit crt[in].o. -LDFLAGS-pthread.so += -specs=$(objpfx)specs -before-compile += $(objpfx)specs -generated += specs -$(objpfx)specs: - $(CC) $(CFLAGS) $(CPPFLAGS) -dumpspecs \ - | sed 's~\(/usr/lib\(\|64\)/\|^\|\([^/a-z]\)\)\(crt[in]\.o\)~\3'$(objpfx)'\4~g' > $@.new - mv -f $@.new $@ -endif --- linuxthreads/sysdeps/unix/sysv/linux/x86_64/Makefile.jj 2003-02-22 17:53:59.000000000 -0500 +++ linuxthreads/sysdeps/unix/sysv/linux/x86_64/Makefile 2003-04-10 18:08:33.000000000 -0400 @@ -1,12 +1,3 @@ ifeq ($(subdir),linuxthreads) CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions -fno-asynchronous-unwind-tables -# gcc -m64 has /usr/lib64/crti.o hardcoded in the specs file, because otherwise -# it would normally find 32bit crti.o. -LDFLAGS-pthread.so += -specs=$(objpfx)specs -before-compile += $(objpfx)specs -generated += specs -$(objpfx)specs: - $(CC) $(CFLAGS) $(CPPFLAGS) -dumpspecs \ - | sed 's,\(/usr/lib\(\|64\)/\|^\|\([^/a-z]\)\)\(crt[in]\.o\),\3./\4,g' > $@.new - mv -f $@.new $@ endif --- linuxthreads/Makefile.jj 2003-04-03 05:27:37.000000000 -0500 +++ linuxthreads/Makefile 2003-04-10 18:10:34.000000000 -0400 @@ -79,7 +79,16 @@ $(objpfx)libpthread_nonshared.a: $(addpr ifeq ($(build-shared),yes) -extra-objs += crti.o crtn.o +multidir := $(shell $(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory) +crti-objs := crti.o +crtn-objs := crtn.o +ifneq ($(multidir),.) +generated-dirs := $(firstword $(subst /, , $(multidir))) +crti-objs += $(multidir)/crti.o +crtn-objs += $(multidir)/crtn.o +omit-deps += $(multidir)/crti $(multidir)/crtn +endif +extra-objs += $(crti-objs) $(crtn-objs) omit-deps += crti crtn CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions @@ -132,9 +141,9 @@ $(inst_libdir)/libpthread_nonshared.a: $ extra-B-pthread.so = -B$(common-objpfx)linuxthreads/ -$(objpfx)libpthread.so: $(objpfx)crti.o $(objpfx)crtn.o -$(objpfx)libpthread.so: +preinit += $(objpfx)crti.o -$(objpfx)libpthread.so: +postinit += $(objpfx)crtn.o +$(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs)) +$(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs)) +$(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs)) znodelete-yes = -DHAVE_Z_NODELETE CFLAGS-mutex.c += -D__NO_WEAK_PTHREAD_ALIASES @@ -249,6 +258,17 @@ $(objpfx)crti.o: $(objpfx)crti.S $(objpf $(objpfx)crtn.o: $(objpfx)crtn.S $(objpfx)defs.h $(compile.S) -g0 $(ASFLAGS-.os) -o $@ +ifneq ($(multidir),.) +$(objpfx)$(multidir): + @mkdir -p $(objpfx)$(multidir) + +$(objpfx)$(multidir)/crti.o: $(objpfx)crti.o $(objpfx)$(multidir) + ln -f $< $@ + +$(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir) + ln -f $< $@ +endif + generated += crti.S crtn.S defs.h pt-initfini.s endif Jakub