mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-07-23 19:34:41 +00:00
meson: add modules infrastructure
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
2becc36a3e
commit
3154fee4db
10
Makefile
10
Makefile
|
@ -266,7 +266,7 @@ slirp/all: .git-submodule-status
|
||||||
CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
|
CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
|
||||||
|
|
||||||
$(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
|
$(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
|
||||||
$(qom-obj-y)
|
$(qom-obj-y) block.syms qemu.syms
|
||||||
|
|
||||||
$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
|
$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
|
||||||
$(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
|
$(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
|
||||||
|
@ -474,14 +474,6 @@ install: all $(if $(BUILD_DOCS),install-doc) \
|
||||||
ifneq ($(TOOLS),)
|
ifneq ($(TOOLS),)
|
||||||
$(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
|
$(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
|
||||||
endif
|
endif
|
||||||
ifneq ($(CONFIG_MODULES),)
|
|
||||||
$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
|
|
||||||
for s in $(modules-m:.mo=$(DSOSUF)); do \
|
|
||||||
t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
|
|
||||||
$(INSTALL_LIB) $$s "$$t"; \
|
|
||||||
test -z "$(STRIP)" || $(STRIP) "$$t"; \
|
|
||||||
done
|
|
||||||
endif
|
|
||||||
ifneq ($(HELPERS-y),)
|
ifneq ($(HELPERS-y),)
|
||||||
$(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
|
$(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -162,6 +162,12 @@ obj-y += qapi/
|
||||||
obj-y += migration/ram.o
|
obj-y += migration/ram.o
|
||||||
LIBS := $(libs_softmmu) $(LIBS)
|
LIBS := $(libs_softmmu) $(LIBS)
|
||||||
|
|
||||||
|
# Temporary until emulators are linked by Meson
|
||||||
|
LIBS := $(LIBS) @../block.syms @../qemu.syms
|
||||||
|
ifneq ($(CONFIG_MODULES),y)
|
||||||
|
LIBS := $(LIBS)
|
||||||
|
endif
|
||||||
|
|
||||||
# Hardware support
|
# Hardware support
|
||||||
ifeq ($(TARGET_NAME), sparc64)
|
ifeq ($(TARGET_NAME), sparc64)
|
||||||
obj-y += hw/sparc64/
|
obj-y += hw/sparc64/
|
||||||
|
|
51
meson.build
51
meson.build
|
@ -10,6 +10,7 @@ sh = find_program('sh')
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
|
config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
|
||||||
config_all_disas = keyval.load(meson.current_build_dir() / 'config-all-disas.mak')
|
config_all_disas = keyval.load(meson.current_build_dir() / 'config-all-disas.mak')
|
||||||
|
enable_modules = 'CONFIG_MODULES' in config_host
|
||||||
|
|
||||||
add_project_arguments(config_host['QEMU_CFLAGS'].split(),
|
add_project_arguments(config_host['QEMU_CFLAGS'].split(),
|
||||||
native: false, language: ['c', 'objc'])
|
native: false, language: ['c', 'objc'])
|
||||||
|
@ -316,6 +317,7 @@ genh += hxdep
|
||||||
util_ss = ss.source_set()
|
util_ss = ss.source_set()
|
||||||
stub_ss = ss.source_set()
|
stub_ss = ss.source_set()
|
||||||
trace_ss = ss.source_set()
|
trace_ss = ss.source_set()
|
||||||
|
block_ss = ss.source_set()
|
||||||
common_ss = ss.source_set()
|
common_ss = ss.source_set()
|
||||||
softmmu_ss = ss.source_set()
|
softmmu_ss = ss.source_set()
|
||||||
user_ss = ss.source_set()
|
user_ss = ss.source_set()
|
||||||
|
@ -323,6 +325,7 @@ bsd_user_ss = ss.source_set()
|
||||||
linux_user_ss = ss.source_set()
|
linux_user_ss = ss.source_set()
|
||||||
specific_ss = ss.source_set()
|
specific_ss = ss.source_set()
|
||||||
|
|
||||||
|
modules = {}
|
||||||
hw_arch = {}
|
hw_arch = {}
|
||||||
target_arch = {}
|
target_arch = {}
|
||||||
target_softmmu_arch = {}
|
target_softmmu_arch = {}
|
||||||
|
@ -432,6 +435,12 @@ subdir('crypto')
|
||||||
subdir('storage-daemon')
|
subdir('storage-daemon')
|
||||||
subdir('ui')
|
subdir('ui')
|
||||||
|
|
||||||
|
|
||||||
|
if enable_modules
|
||||||
|
libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
|
||||||
|
modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
|
||||||
|
endif
|
||||||
|
|
||||||
# Build targets from sourcesets
|
# Build targets from sourcesets
|
||||||
|
|
||||||
stub_ss = stub_ss.apply(config_all, strict: false)
|
stub_ss = stub_ss.apply(config_all, strict: false)
|
||||||
|
@ -448,6 +457,48 @@ subdir('io')
|
||||||
subdir('fsdev')
|
subdir('fsdev')
|
||||||
subdir('target')
|
subdir('target')
|
||||||
|
|
||||||
|
block_mods = []
|
||||||
|
softmmu_mods = []
|
||||||
|
foreach d, list : modules
|
||||||
|
foreach m, module_ss : list
|
||||||
|
if enable_modules and targetos != 'windows'
|
||||||
|
module_ss = module_ss.apply(config_host, strict: false)
|
||||||
|
sl = static_library(d + '-' + m, [genh, module_ss.sources()],
|
||||||
|
dependencies: [modulecommon, module_ss.dependencies()], pic: true)
|
||||||
|
if d == 'block'
|
||||||
|
block_mods += sl
|
||||||
|
else
|
||||||
|
softmmu_mods += sl
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if d == 'block'
|
||||||
|
block_ss.add_all(module_ss)
|
||||||
|
else
|
||||||
|
softmmu_ss.add_all(module_ss)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
nm = find_program('nm')
|
||||||
|
undefsym = find_program('scripts/undefsym.sh')
|
||||||
|
block_syms = custom_target('block.syms', output: 'block.syms',
|
||||||
|
input: [libqemuutil, block_mods],
|
||||||
|
capture: true,
|
||||||
|
command: [undefsym, nm, '@INPUT@'])
|
||||||
|
qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
|
||||||
|
input: [libqemuutil, softmmu_mods],
|
||||||
|
capture: true,
|
||||||
|
command: [undefsym, nm, '@INPUT@'])
|
||||||
|
|
||||||
|
foreach m : block_mods + softmmu_mods
|
||||||
|
shared_module(m.name(),
|
||||||
|
name_prefix: '',
|
||||||
|
link_whole: m,
|
||||||
|
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_SOFTMMU', if_true: softmmu_ss)
|
||||||
common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
|
common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
|
||||||
|
|
||||||
|
|
10
rules.mak
10
rules.mak
|
@ -61,17 +61,17 @@ endif
|
||||||
# This is necessary because the exectuable itself may not use the function, in
|
# 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
|
# which case the function would not be linked in. Then the DSO loading will
|
||||||
# fail because of the missing symbol.
|
# fail because of the missing symbol.
|
||||||
process-archive-undefs = $(filter-out %.a %.fa %.mo,$1) \
|
process-archive-undefs = $(filter-out %.a %.fa %.mo %$(DSOSUF),$1) \
|
||||||
$(addprefix $(WL_U), \
|
$(addprefix $(WL_U), \
|
||||||
$(filter $(call defined-symbols,$(filter %.a %.fa, $1)), \
|
$(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)) \
|
$(foreach l,$(filter %.fa,$1),$(call whole-archive,$l)) \
|
||||||
$(filter %.a,$1)
|
$(filter %.a,$1)
|
||||||
|
|
||||||
extract-libs = $(strip $(foreach o,$(filter-out %.mo,$1),$($o-libs)))
|
extract-libs = $(strip $(foreach o,$(filter-out %.mo %$(DSOSUF),$1),$($o-libs)))
|
||||||
expand-objs = $(strip $(sort $(filter %.o,$1)) \
|
expand-objs = $(strip $(sort $(filter %.o,$1)) \
|
||||||
$(foreach o,$(filter %.mo,$1),$($o-objs)) \
|
$(foreach o,$(filter %.mo %$(DSOSUF),$1),$($o-objs)) \
|
||||||
$(filter-out %.o %.mo,$1))
|
$(filter-out %.o %.mo %$(DSOSUF),$1))
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
|
|
20
scripts/undefsym.sh
Executable file
20
scripts/undefsym.sh
Executable file
|
@ -0,0 +1,20 @@
|
||||||
|
#! /usr/bin/env 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 them,
|
||||||
|
# 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=$1
|
||||||
|
staticlib=$2
|
||||||
|
shift 2
|
||||||
|
# Find symbols defined in static libraries and undefined in shared modules
|
||||||
|
comm -12 \
|
||||||
|
<( $NM -P -g $staticlib | awk '$2!="U"{print "-Wl,-u," $1}' | sort -u) \
|
||||||
|
<( $NM -P -g "$@" | awk '$2=="U"{print "-Wl,-u," $1}' | sort -u)
|
Loading…
Reference in a new issue