From nobody Tue Feb 10 13:16:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1606144901; cv=none; d=zohomail.com; s=zohoarc; b=UFUKXRSS8yfXU8Ue+W/SYOdsyRwIZL+eGMX5BV3bn9HBGuz8su11X4Ec7XqFSkaiHCXhtsLGxHtRxpPJVO4vfMRRGX3ZfXqRWqI53kBmv7JuQlB9qiSnKYi9wsqJaMcILAo5gx6zvy6/MdQD+y5k71txY9eson85KMIvr9rm+bU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606144901; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cuO4qVJ1llY0PSDhrVuUhRfZB05Gf7cWsKZi8aM03oE=; b=GblaKQP4uXut8lWSKW3I1amp4NED3du/60xNG0/vHlZheh40UjxqzNh51HSaLPwQOyfSeRqWAkRwIUfnnAawB83UfPB0f02Do5XrCPWqayILUyghtUcjZ1/haRt+c/vF4aMgNhLxFxq4lakoEp83kYfxJW2ceO9jnzX44S3dy4o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1606144901808864.0130008824144; Mon, 23 Nov 2020 07:21:41 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.34637.65796 (Exim 4.92) (envelope-from ) id 1khDed-0006eC-VE; Mon, 23 Nov 2020 15:21:23 +0000 Received: by outflank-mailman (output) from mailman id 34637.65796; Mon, 23 Nov 2020 15:21:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khDed-0006e5-Ru; Mon, 23 Nov 2020 15:21:23 +0000 Received: by outflank-mailman (input) for mailman id 34637; Mon, 23 Nov 2020 15:21:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khDec-0006du-J9 for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 15:21:22 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1625aba3-5ee8-4a01-9fc2-df14e972cbcb; Mon, 23 Nov 2020 15:21:21 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 91B61AF9E; Mon, 23 Nov 2020 15:21:20 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khDec-0006du-J9 for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 15:21:22 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1625aba3-5ee8-4a01-9fc2-df14e972cbcb; Mon, 23 Nov 2020 15:21:21 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 91B61AF9E; Mon, 23 Nov 2020 15:21:20 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1625aba3-5ee8-4a01-9fc2-df14e972cbcb X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606144880; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cuO4qVJ1llY0PSDhrVuUhRfZB05Gf7cWsKZi8aM03oE=; b=lVpak4STOi/mO4KPxsT9oV8uBjAXmOU+ouQke8fqwI3v8KtrGsZapuH4IfJ5hsAU4Vfjfo DEUo7okw7j6LVAog0Yj37lAwfnK8iqAkFv2dfOhMxt3R8pcwQCYOAWnA0NL8qz/kz+CRXB RCMrQGqh//x4DRVBkB7na8+qka856E8= Subject: [PATCH v3 2/8] lib: collect library files in an archive From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Wei Liu , Stefano Stabellini , Anthony Perard References: <1a6bac6a-7d83-f5b6-c5b9-8b3b39824d40@suse.com> Message-ID: <21714b83-8619-5aa9-be5b-3015d05a26a4@suse.com> Date: Mon, 23 Nov 2020 16:21:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <1a6bac6a-7d83-f5b6-c5b9-8b3b39824d40@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" In order to (subsequently) drop odd things like CONFIG_NEEDS_LIST_SORT just to avoid bloating binaries when only some arch-es and/or configurations need generic library routines, combine objects under lib/ into an archive, which the linker then can pick the necessary objects out of. Note that we can't use thin archives just yet, until we've raised the minimum required binutils version suitably. Signed-off-by: Jan Beulich Acked-by: Julien Grall Reviewed-by: Anthony PERARD Reviewed-by: Bertrand Marquis --- xen/Rules.mk | 29 +++++++++++++++++++++++++---- xen/arch/arm/Makefile | 6 +++--- xen/arch/x86/Makefile | 8 ++++---- xen/lib/Makefile | 3 ++- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/xen/Rules.mk b/xen/Rules.mk index d5e5eb33de39..aba6ca2a90f5 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -41,12 +41,16 @@ ALL_OBJS-y +=3D $(BASEDIR)/xsm/built_in.o ALL_OBJS-y +=3D $(BASEDIR)/arch/$(TARGET_ARCH)/built_in.o ALL_OBJS-$(CONFIG_CRYPTO) +=3D $(BASEDIR)/crypto/built_in.o =20 +ALL_LIBS-y :=3D $(BASEDIR)/lib/lib.a + # Initialise some variables +lib-y :=3D targets :=3D CFLAGS-y :=3D AFLAGS-y :=3D =20 ALL_OBJS :=3D $(ALL_OBJS-y) +ALL_LIBS :=3D $(ALL_LIBS-y) =20 SPECIAL_DATA_SECTIONS :=3D rodata $(foreach a,1 2 4 8 16, \ $(foreach w,1 2 4, \ @@ -60,7 +64,14 @@ include Makefile # ------------------------------------------------------------------------= --- =20 quiet_cmd_ld =3D LD $@ -cmd_ld =3D $(LD) $(XEN_LDFLAGS) -r -o $@ $(real-prereqs) +cmd_ld =3D $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out %.a,$(real-prereqs))= \ + --start-group $(filter %.a,$(real-prereqs)) --end-group + +# Archive +# ------------------------------------------------------------------------= --- + +quiet_cmd_ar =3D AR $@ +cmd_ar =3D rm -f $@; $(AR) cPrs $@ $(real-prereqs) =20 # Objcopy # ------------------------------------------------------------------------= --- @@ -86,6 +97,10 @@ obj-y :=3D $(patsubst %/, %/built_in.o, $(obj-y)) # tell kbuild to descend subdir-obj-y :=3D $(filter %/built_in.o, $(obj-y)) =20 +# Libraries are always collected in one lib file. +# Filter out objects already built-in +lib-y :=3D $(filter-out $(obj-y), $(sort $(lib-y))) + $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS-y +=3D -DINIT_= SECTIONS_ONLY =20 ifeq ($(CONFIG_COVERAGE),y) @@ -129,7 +144,7 @@ include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk c_flags +=3D $(CFLAGS-y) a_flags +=3D $(CFLAGS-y) $(AFLAGS-y) =20 -built_in.o: $(obj-y) $(extra-y) +built_in.o: $(obj-y) $(if $(strip $(lib-y)),lib.a) $(extra-y) ifeq ($(strip $(obj-y)),) $(CC) $(c_flags) -c -x c /dev/null -o $@ else @@ -140,8 +155,14 @@ else endif endif =20 +lib.a: $(lib-y) FORCE + $(call if_changed,ar) + targets +=3D built_in.o -targets +=3D $(filter-out $(subdir-obj-y), $(obj-y)) $(extra-y) +ifneq ($(strip $(lib-y)),) +targets +=3D lib.a +endif +targets +=3D $(filter-out $(subdir-obj-y), $(obj-y) $(lib-y)) $(extra-y) targets +=3D $(MAKECMDGOALS) =20 built_in_bin.o: $(obj-bin-y) $(extra-y) @@ -155,7 +176,7 @@ endif PHONY +=3D FORCE FORCE: =20 -%/built_in.o: FORCE +%/built_in.o %/lib.a: FORCE $(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in.o =20 %/built_in_bin.o: FORCE diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 296c5e68bbc3..612a83b315c8 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -90,14 +90,14 @@ endif =20 ifeq ($(CONFIG_LTO),y) # Gather all LTO objects together -prelink_lto.o: $(ALL_OBJS) - $(LD_LTO) -r -o $@ $^ +prelink_lto.o: $(ALL_OBJS) $(ALL_LIBS) + $(LD_LTO) -r -o $@ $(filter-out %.a,$^) --start-group $(filter %.a,$^) --= end-group =20 # Link it with all the binary objects prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_l= to.o $(call if_changed,ld) else -prelink.o: $(ALL_OBJS) FORCE +prelink.o: $(ALL_OBJS) $(ALL_LIBS) FORCE $(call if_changed,ld) endif =20 diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 9b368632fb43..8f2180485b2b 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -132,8 +132,8 @@ EFI_OBJS-$(XEN_BUILD_EFI) :=3D efi/relocs-dummy.o =20 ifeq ($(CONFIG_LTO),y) # Gather all LTO objects together -prelink_lto.o: $(ALL_OBJS) - $(LD_LTO) -r -o $@ $^ +prelink_lto.o: $(ALL_OBJS) $(ALL_LIBS) + $(LD_LTO) -r -o $@ $(filter-out %.a,$^) --start-group $(filter %.a,$^) --= end-group =20 # Link it with all the binary objects prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_l= to.o $(EFI_OBJS-y) FORCE @@ -142,10 +142,10 @@ prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$= (ALL_OBJS)) prelink_lto.o $ prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) preli= nk_lto.o FORCE $(call if_changed,ld) else -prelink.o: $(ALL_OBJS) $(EFI_OBJS-y) FORCE +prelink.o: $(ALL_OBJS) $(ALL_LIBS) $(EFI_OBJS-y) FORCE $(call if_changed,ld) =20 -prelink-efi.o: $(ALL_OBJS) FORCE +prelink-efi.o: $(ALL_OBJS) $(ALL_LIBS) FORCE $(call if_changed,ld) endif =20 diff --git a/xen/lib/Makefile b/xen/lib/Makefile index 53b1da025e0d..b8814361d63e 100644 --- a/xen/lib/Makefile +++ b/xen/lib/Makefile @@ -1,2 +1,3 @@ -obj-y +=3D ctype.o obj-$(CONFIG_X86) +=3D x86/ + +lib-y +=3D ctype.o