From patchwork Mon Aug 17 14:35:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 276329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E2E1C433E1 for ; Mon, 17 Aug 2020 14:46:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E81820789 for ; Mon, 17 Aug 2020 14:46:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bVS4MP7O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E81820789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k7gPV-0002LR-Ak for qemu-devel@archiver.kernel.org; Mon, 17 Aug 2020 10:46:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k7gGh-0003Zq-PV for qemu-devel@nongnu.org; Mon, 17 Aug 2020 10:37:47 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:45580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k7gGf-00063U-PU for qemu-devel@nongnu.org; Mon, 17 Aug 2020 10:37:47 -0400 Received: by mail-wr1-x42a.google.com with SMTP id z18so15240511wrm.12 for ; Mon, 17 Aug 2020 07:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dspYanX3zf7a9yxolnnruaw1M3atSamdkc1hvEVqzGE=; b=bVS4MP7OD0Kk3M6bl9iuuY6LTLaC1GxovV8fQcQrNNUOcjQrWdf/TW9FLIG8uMCRIz vwBHSGcdXRuvK0VKMKf7+C6iryNR5ysVY9Vx3X3hKfyBr3VZDovLq8oL/YVRM4V+BhOd nQNYTVYnq67KAedV3eH1+mGvtZ1TxOY8aG/bRob2OblUmonunBeJK2azHkhbL/PSuFBt qpqkajgNXzRF2oDVjbOcqY7LeCwec9a7qobxQPhRKF9uXdqD4nwXl8MzEyO1NmDR5N1k CVkQmGEQ9pBYyejfoFKGLNqeIsfHCC3SXq+pLLfgcHfaojLN6tUB59WEoVcNae0kXGkk 7YNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=dspYanX3zf7a9yxolnnruaw1M3atSamdkc1hvEVqzGE=; b=oJtzsiK2IyW2Gt09LO8l9hGimvZk+cr6NB2VXCso0zHQCT5+tXNJNWpofT8+dMks0G FtNkTyAjBIRVdBmRAMfgy4T+FoM+u/812WNxJMFoe2Y3KZIPNMw/7Q6ZLqh2fOtBQJo2 XYp9x2AtCVpFfYyiGMlYT8208eZ6sYyhqBgZRr23lIbkqtRzVU+IMB0SOvQ7aY0z6Ax0 9wIngiNuQrLBKD4pxDZ8O5HEjG2FuT0vodLhg6nD18yFYFGU+jVvuV+TRrPrImZMqiPl 6jTwgz67ripdQ/VIeT2ZBiTTVh3CGyfC1pZIDs6yPk9y5OMWnqych08Q/3b5MEZM1P1S EluQ== X-Gm-Message-State: AOAM531d78I+rzIuxW6nuxwqgBzSCexspN+GsnTn+9pt0CQzvN8quJq5 9vBm6PWSVpV8ZvhKairx+9PUzk5wlzc= X-Google-Smtp-Source: ABdhPJxm18IhDgtyUK3NJHGPa/63dgzgkJSxxgTCMOQB849PF+zBOfwO3bGZmrUBuHOLo4l7hHh3CA== X-Received: by 2002:adf:fb87:: with SMTP id a7mr16896296wrr.390.1597675064179; Mon, 17 Aug 2020 07:37:44 -0700 (PDT) Received: from donizetti.redhat.com ([2001:b07:6468:f312:a0d1:fc42:c610:f977]) by smtp.gmail.com with ESMTPSA id i22sm34966603wrb.45.2020.08.17.07.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 07:37:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 017/150] build-sys hack: link with whole .fa archives Date: Mon, 17 Aug 2020 16:35:10 +0200 Message-Id: <20200817143723.343284-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200817143723.343284-1-pbonzini@redhat.com> References: <20200817143723.343284-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=paolo.bonzini@gmail.com; helo=mail-wr1-x42a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau In order to link the *-obj-y files into tests, we will make static libraries of them in Meson, and then link them as whole archives into the tests. To separate regular static libraries from link-whole libraries, give them a different file extension. Signed-off-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- rules.mak | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/rules.mak b/rules.mak index e79a4005a7..5ab42def82 100644 --- a/rules.mak +++ b/rules.mak @@ -39,6 +39,13 @@ find-symbols = $(if $1, $(sort $(shell $(NM) -P -g $1 | $2))) defined-symbols = $(call find-symbols,$1,awk '$$2!="U"{print $$1}') undefined-symbols = $(call find-symbols,$1,awk '$$2=="U"{print $$1}') +WL := -Wl, +ifdef CONFIG_DARWIN +whole-archive = $(WL)-force_load,$1 +else +whole-archive = $(WL)--whole-archive $1 $(WL)--no-whole-archive +endif + # All the .mo objects in -m variables are also added into corresponding -y # variable in unnest-vars, but filtered out here, when LINK is called. # @@ -54,11 +61,12 @@ undefined-symbols = $(call find-symbols,$1,awk '$$2=="U"{print $$1}') # This is necessary because the exectuable itself may not use the function, in # which case the function would not be linked in. Then the DSO loading will # fail because of the missing symbol. -process-archive-undefs = $(filter-out %.a %.mo,$1) \ +process-archive-undefs = $(filter-out %.a %.fa %.mo,$1) \ $(addprefix $(WL_U), \ - $(filter $(call defined-symbols,$(filter %.a, $1)), \ + $(filter $(call defined-symbols,$(filter %.a %.fa, $1)), \ $(call undefined-symbols,$(filter %.mo,$1)))) \ - $(filter %.a,$1) + $(foreach l,$(filter %.fa,$1),$(call whole-archive,$l)) \ + $(filter %.a,$1) extract-libs = $(strip $(foreach o,$(filter-out %.mo,$1),$($o-libs))) expand-objs = $(strip $(sort $(filter %.o,$1)) \ @@ -122,7 +130,7 @@ LD_REL := $(CC) -nostdlib $(LD_REL_FLAGS) modules: %$(EXESUF): %.o - $(call LINK,$(filter %.o %.a %.mo, $^)) + $(call LINK,$(filter %.o %.a %.mo %.fa, $^)) %.a: $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"AR","$(TARGET_DIR)$@") @@ -378,7 +386,7 @@ define unnest-vars $(error $o added in $v but $o-objs is not set))) $(shell mkdir -p ./ $(sort $(dir $($v)))) # Include all the .d files - $(eval -include $(patsubst %.o,%.d,$(patsubst %.mo,%.d,$($v)))) + $(eval -include $(patsubst %.o,%.d,$(patsubst %.mo,%.d,$(filter %.o,$($v))))) $(eval $v := $(filter-out %/,$($v)))) endef