From patchwork Mon Nov 6 18:32:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 834869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-86825-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="jDBjDa0F"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yW1QL5XNdz9s1h for ; Tue, 7 Nov 2017 05:32:58 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; q=dns; s=default; b=ombDcVXgBXh9vUvY dYDLnXvj1jGqzkpXNzrkIybgDvKMWyPaLzYFyF//07pYP+68GE067MYmk5Z20vKL zAo/MLuv0xEhNYKGoAud9/9ZEpaPUM/UwB+euI++oE0qbh8ZXVe/IAD1lNcMEcNj 3Mi05ZWxd3QPDIAH3kQBzP4Z+9A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; s=default; bh=BSYyMTiywTQZT7zTKBS14N 8JM2E=; b=jDBjDa0FcNeK02jCxz+b+H93g+F4pdqgogSn2fwHdvXjFgtV7Pz8Ok 8bT+EDyAICpJPDdydOP/6yKgUnpIxmAtezP2e3mlRfg2/DTtUWfAdoDEm//zvqSM 9vVwEX2L+rsGlZn0uQO1eh5Wyhp8O16vOaNoo6REhJy5zZdr/P3G8= Received: (qmail 105539 invoked by alias); 6 Nov 2017 18:32:52 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 105524 invoked by uid 89); 6 Nov 2017 18:32:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=UD:mk, t X-HELO: mga11.intel.com X-ExtLoop1: 1 Date: Mon, 6 Nov 2017 10:32:49 -0800 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] nptl: Simplify libpthread.so rules Message-ID: <20171106183249.GA27753@gmail.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) libpthread.so must be created against a special crti.o and when multi-lib GCC is used to build glibc, the special crti.o must be placed under the `gcc -print-multi-directory` subdirectory so that -B$(common-objpfx)nptl/ will pick it up. This patch compiles the special crti.o directly with "-include pt-crti.h" and uses the new make-link-multidir from the fix for [BZ #22362] to create the symlink for the multi-lib subdirectory. It simplifies libpthread.so rules to support -B$(common-objpfx)nptl/ and -B$(common-objpfx)/ for correct crt*.o files. Tested on x86-64 for x86-64, i686 and x32. Any comments? H.J. --- * nptl/Makefile (multidir.mk): Don't generate. ($(objpfx)multidir.mk): Removed. (crtn-objs): Likewise. (generated-dirs): Don't add $(multidir). (multilib-crti-objs): New. (extra-objs): Use $(multilib-crti-objs). Don't add pt-crti.o. ($(objpfx)libpthread.so): Removed. (CPPFLAGS-crti.o): New. ($(objpfx)crti.o): Removed. ($(objpfx)$(multidir)/crti.o): Likewise. ($(objpfx)$(multidir)/crtn.o): Likewise. ($(addprefix $(objpfx)$(multidir)/, $(crti-objs))): New target. (generated): Remove multidir.mk. * nptl/pt-crti.S: Renamed to ... * nptl/pt-crti.h: This. Don't include . --- nptl/Makefile | 40 +++++++++------------------------------- nptl/{pt-crti.S => pt-crti.h} | 2 -- 2 files changed, 9 insertions(+), 33 deletions(-) rename nptl/{pt-crti.S => pt-crti.h} (99%) diff --git a/nptl/Makefile b/nptl/Makefile index d819349f43..f2550cf33c 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -401,27 +401,13 @@ tests: $(test-modules) endif ifeq ($(build-shared),yes) - -# Set the `multidir' variable by grabbing the variable from the compiler. -# We do it once and save the result in a generated makefile. --include $(objpfx)multidir.mk -$(objpfx)multidir.mk: $(common-objpfx)config.make - $(make-target-directory) - dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \ - echo "multidir := $$dir" > $@T - mv -f $@T $@ - crti-objs := crti.o -crtn-objs := crtn.o -ifneq (,$(patsubst .,,$(multidir))) -generated-dirs += $(firstword $(subst /, , $(multidir))) -crti-objs += $(multidir)/crti.o -crtn-objs += $(multidir)/crtn.o -$(objpfx)$(multidir): - mkdir -p $@ +extra-objs += $(crti-objs) + +ifneq ($(multidir),.) +multilib-crti-objs := $(addprefix $(multidir)/, $(crti-objs)) +extra-objs += $(multilib-crti-objs) endif -extra-objs += $(crti-objs) $(crtn-objs) -extra-objs += pt-crti.o endif CFLAGS-flockfile.c = $(libio-mtsafe) @@ -623,9 +609,7 @@ LDLIBS-tst-cancel24 = $(no-as-needed) -lstdc++ LDLIBS-tst-cancel24-static = $(LDLIBS-tst-cancel24) extra-B-pthread.so = -B$(common-objpfx)nptl/ -$(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)) +CPPFLAGS-crti.o = -include pt-crti.h # Make sure we link with the thread library. ifeq ($(build-shared),yes) @@ -659,19 +643,13 @@ $(objpfx)tst-cleanup0-cmp.out: tst-cleanup0.expect $(objpfx)tst-cleanup0.out cmp $^ > $@; \ $(evaluate-test) -$(objpfx)crti.o: $(objpfx)pt-crti.o - ln -f $< $@ - ifneq ($(multidir),.) -$(objpfx)$(multidir)/crti.o: $(objpfx)crti.o $(objpfx)$(multidir)/ - ln -f $< $@ - -$(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir)/ - ln -f $< $@ +$(addprefix $(objpfx)$(multidir)/, $(crti-objs)): $(addprefix $(objpfx), $(crti-objs)) + $(make-link-multidir) endif generated += libpthread_nonshared.a \ - multidir.mk tst-atfork2.mtrace tst-cancel-wrappers.out \ + tst-atfork2.mtrace tst-cancel-wrappers.out \ tst-tls6.out generated += $(objpfx)tst-atfork2.mtrace \ diff --git a/nptl/pt-crti.S b/nptl/pt-crti.h similarity index 99% rename from nptl/pt-crti.S rename to nptl/pt-crti.h index d2371bc6ff..f7b2c610b2 100644 --- a/nptl/pt-crti.S +++ b/nptl/pt-crti.h @@ -39,5 +39,3 @@ #define PREINIT_FUNCTION __pthread_initialize_minimal_internal #define PREINIT_FUNCTION_WEAK 0 - -#include