From nobody Mon Feb 9 03:29:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1596742788; cv=none; d=zohomail.com; s=zohoarc; b=AsVQIMdlvoobhV4SLIJOiW01YD819fWARzUTR1cKOeoVOYpoEU4tBG2sk4wxqo/R0yz8RruKshDAYIIcm8NS/FyDy6Rfjihtuwj4WtF5S5B5BPazToWTfb/x6uSd8Kxg3+Rwi/onapxHzgzHvEjjJjhL6ZjohzbIzVjINpdAx9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596742788; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4Dd1GRjsxw96gmGekjPDyR/p+N4UDxMzTG5T1V+3e+I=; b=EHlLVbtEg8RQCl+XneFa9N6isldk+wwKGKqlFaKqSPpHdzy1jI5fG6ddkY5SI4Ajm3e6EOxlJEARqFaKHEveFevHYxCHvJLBExC8vqQBE/oYPCOrm49lPBwDh4ckq9R6OCKn3dsbrUA8jLYrk4+u92MNOlXWrgkZRlKZr2owyoU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596742788023984.9385394557906; Thu, 6 Aug 2020 12:39:48 -0700 (PDT) Received: from localhost ([::1]:59126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3lju-0000yb-KG for importer@patchew.org; Thu, 06 Aug 2020 15:39:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3lOy-00061Y-Sj for qemu-devel@nongnu.org; Thu, 06 Aug 2020 15:18:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k3lOw-0006YI-9u for qemu-devel@nongnu.org; Thu, 06 Aug 2020 15:18:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-504-uN00fbhiO2WrIBFeCe0Xbw-1; Thu, 06 Aug 2020 15:18:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD96E1DE2 for ; Thu, 6 Aug 2020 19:18:02 +0000 (UTC) Received: from 640k.localdomain.com (unknown [10.36.110.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id DECE75FC30; Thu, 6 Aug 2020 19:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596741485; h=from:from:reply-to:subject:subject: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=4Dd1GRjsxw96gmGekjPDyR/p+N4UDxMzTG5T1V+3e+I=; b=ELVknfMaWR/+b0BbKxlmxYvvjtpRrV3JkisTrky6JaWTxuVad69OhoGXkHrKracJSr4Mpj kTNx/KTMfkoDPcElKcJys6jfNp/QZtitDJX46TJB+UuLvPBdcAIuJM+yCnpOQ4deYhydnB M0vG8VSs3XAc5iR9q7TvYCObv0Yt8o4= X-MC-Unique: uN00fbhiO2WrIBFeCe0Xbw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 056/143] meson: add modules infrastructure Date: Thu, 6 Aug 2020 21:14:52 +0200 Message-Id: <1596741379-12902-57-git-send-email-pbonzini@redhat.com> In-Reply-To: <1596741379-12902-1-git-send-email-pbonzini@redhat.com> References: <1596741379-12902-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/06 13:48:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham 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=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- Makefile | 10 +--------- Makefile.target | 6 ++++++ meson.build | 52 +++++++++++++++++++++++++++++++++++++++++++++++++= +++ rules.mak | 10 +++++----- scripts/undefsym.sh | 20 ++++++++++++++++++++ 5 files changed, 84 insertions(+), 14 deletions(-) create mode 100755 scripts/undefsym.sh diff --git a/Makefile b/Makefile index e5f68e0..82527d0 100644 --- a/Makefile +++ b/Makefile @@ -251,7 +251,7 @@ slirp/all: .git-submodule-status CFLAGS=3D"$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS=3D"$(QEMU_LDFLAGS)") =20 $(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \ - $(qom-obj-y) + $(qom-obj-y) block.syms qemu.syms =20 $(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \ $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY)) @@ -461,14 +461,6 @@ install: all $(if $(BUILD_DOCS),install-doc) \ ifneq ($(TOOLS),) $(call install-prog,$(TOOLS),$(DESTDIR)$(bindir)) endif -ifneq ($(CONFIG_MODULES),) - $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)" - for s in $(modules-m:.mo=3D$(DSOSUF)); do \ - t=3D"$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \ - $(INSTALL_LIB) $$s "$$t"; \ - test -z "$(STRIP)" || $(STRIP) "$$t"; \ - done -endif ifneq ($(HELPERS-y),) $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir)) endif diff --git a/Makefile.target b/Makefile.target index 43d2f97..d1d8906 100644 --- a/Makefile.target +++ b/Makefile.target @@ -162,6 +162,12 @@ obj-y +=3D qapi/ obj-y +=3D migration/ram.o LIBS :=3D $(libs_softmmu) $(LIBS) =20 +# Temporary until emulators are linked by Meson +LIBS :=3D $(LIBS) @../block.syms @../qemu.syms +ifneq ($(CONFIG_MODULES),y) +LIBS :=3D $(LIBS) +endif + # Hardware support ifeq ($(TARGET_NAME), sparc64) obj-y +=3D hw/sparc64/ diff --git a/meson.build b/meson.build index fd2086e..9d745f8 100644 --- a/meson.build +++ b/meson.build @@ -10,6 +10,7 @@ sh =3D find_program('sh') cc =3D meson.get_compiler('c') config_host =3D keyval.load(meson.current_build_dir() / 'config-host.mak') config_all_disas =3D keyval.load(meson.current_build_dir() / 'config-all-d= isas.mak') +enable_modules =3D 'CONFIG_MODULES' in config_host =20 add_project_arguments(config_host['QEMU_CFLAGS'].split(), language: ['c', 'objc']) @@ -297,6 +298,7 @@ endforeach util_ss =3D ss.source_set() stub_ss =3D ss.source_set() trace_ss =3D ss.source_set() +block_ss =3D ss.source_set() common_ss =3D ss.source_set() softmmu_ss =3D ss.source_set() user_ss =3D ss.source_set() @@ -304,6 +306,7 @@ bsd_user_ss =3D ss.source_set() linux_user_ss =3D ss.source_set() specific_ss =3D ss.source_set() =20 +modules =3D {} hw_arch =3D {} target_arch =3D {} target_softmmu_arch =3D {} @@ -413,6 +416,12 @@ subdir('crypto') subdir('storage-daemon') subdir('ui') =20 + +if enable_modules + libmodulecommon =3D static_library('module-common', files('module-common= .c') + genh, pic: true, c_args: '-DBUILD_DSO') + modulecommon =3D declare_dependency(link_whole: libmodulecommon, compile= _args: '-DBUILD_DSO') +endif + # Build targets from sourcesets =20 stub_ss =3D stub_ss.apply(config_all, strict: false) @@ -429,6 +438,49 @@ subdir('io') subdir('fsdev') subdir('target') =20 +mods =3D [] +block_mods =3D [] +softmmu_mods =3D [] +foreach d, list : modules + foreach m : list + if enable_modules and host_machine.system() !=3D 'windows' + sl =3D static_library(d + '-' + m[0], m[1], dependencies: m[2], pic:= true) + if d =3D=3D 'block' + block_mods +=3D sl + else + softmmu_mods +=3D sl + endif + mods +=3D {'dir': d, 'name': m[0], 'lib': sl, 'deps': m[2]} + else + if d =3D=3D 'block' + block_ss.add(when: [m.get(3, []), m[2]], if_true: m[1]) + else + softmmu_ss.add(when: [m.get(3, []), m[2]], if_true: m[1]) + endif + endif + endforeach +endforeach + +nm =3D find_program('nm') +undefsym =3D find_program('scripts/undefsym.sh') +block_syms =3D custom_target('block.syms', output: 'block.syms', + input: [libqemuutil, block_mods], + capture: true, + command: [undefsym, nm, '@INPUT@']) +qemu_syms =3D custom_target('qemu.syms', output: 'qemu.syms', + input: [libqemuutil, softmmu_mods], + capture: true, + command: [undefsym, nm, '@INPUT@']) + + +foreach m : mods + shared_module(m['dir'] + '-' + m['name'], + name_prefix: '', + link_whole: m['lib'], + install: true, + install_dir: config_host['qemu_moddir']) +endforeach + common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: softmmu_ss) common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss) =20 diff --git a/rules.mak b/rules.mak index d8d35f7..9da9dcd 100644 --- a/rules.mak +++ b/rules.mak @@ -61,17 +61,17 @@ endif # 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 =3D $(filter-out %.a %.fa %.mo,$1) \ +process-archive-undefs =3D $(filter-out %.a %.fa %.mo %$(DSOSUF),$1) \ $(addprefix $(WL_U), \ $(filter $(call defined-symbols,$(filter %.a %.fa, $1= )), \ - $(call undefined-symbols,$(filter %.mo,$1)))= ) \ + $(call undefined-symbols,$(filter %.mo %$(DSOSUF),$1)))) \ $(foreach l,$(filter %.fa,$1),$(call whole-archive,$l)) \ $(filter %.a,$1) =20 -extract-libs =3D $(strip $(foreach o,$(filter-out %.mo,$1),$($o-libs))) +extract-libs =3D $(strip $(foreach o,$(filter-out %.mo %$(DSOSUF),$1),$($o= -libs))) expand-objs =3D $(strip $(sort $(filter %.o,$1)) \ - $(foreach o,$(filter %.mo,$1),$($o-objs)) \ - $(filter-out %.o %.mo,$1)) + $(foreach o,$(filter %.mo %$(DSOSUF),$1),$($o-objs)) \ + $(filter-out %.o %.mo %$(DSOSUF),$1)) =20 %.o: %.c @mkdir -p $(dir $@) diff --git a/scripts/undefsym.sh b/scripts/undefsym.sh new file mode 100755 index 0000000..d4871f0 --- /dev/null +++ b/scripts/undefsym.sh @@ -0,0 +1,20 @@ +#! /bin/bash + +# Before a shared module's DSO is produced, a static library is built for = it +# and passed to this script. The script generates -Wl,-u options to force +# the inclusion of symbol from libqemuutil.a if the shared modules need th= em, +# This is necessary because the modules may use functions not needed by the +# executable itself, which would cause the function to not be linked in. +# Then the DSO loading would fail because of the missing symbol. + +if test $# -le 2; then + exit 0 +fi + +NM=3D$1 +staticlib=3D$2 +shift 2 +# Find symbols defined in static libraries and undefined in shared modules +comm -12 \ + <( $NM -P -g $staticlib | awk '$2!=3D"U"{print "-Wl,-u," $1}' | sort -u)= \ + <( $NM -P -g "$@" | awk '$2=3D=3D"U"{print "-Wl,-u," $1}' | sort -u) --=20 1.8.3.1