Skip to contentSkip to conversation

buildsys: Fix building without plugins on Darwin

PATCH-for-9.1 Applied Philippe Mathieu-Daudé 3 participants 4 messages Aug 13, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

Since commit 0082475e26 the plugin symbol list is unconditionally added to the linker flags, leading to a build failure:

Undefined symbols for architecture arm64:
"_qemu_plugin_entry_code", referenced from:
<initial-undefines>
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Fix by restricting the whole meson file to the --enable-plugins configure argument.

Fixes 0082475e26 ("meson: merge plugin_ldflags into emulator_link_args")
---
 plugins/meson.build | 50 +++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 24 deletions(-)
plugins/meson.build +26 -24
index 18a0303bff..1cc039d29b 100644
@@ -1,3 +1,7 @@
+if not get_option('plugins')
+  subdir_done()
+endif
+
 # Modules need more symbols than just those in plugins/qemu-plugins.symbols
 if not enable_modules
   if host_os == 'darwin'
@@ -12,29 +16,27 @@ if not enable_modules
   endif
 endif
 
-if get_option('plugins')
-  if host_os == 'windows'
-    dlltool = find_program('dlltool', required: true)
+if host_os == 'windows'
+  dlltool = find_program('dlltool', required: true)
 
-    # Generate a .lib file for plugins to link against.
-    # First, create a .def file listing all the symbols a plugin should expect to have
-    # available in qemu
-    win32_plugin_def = configure_file(
-      input: files('qemu-plugins.symbols'),
-      output: 'qemu_plugin_api.def',
-      capture: true,
-      command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@'])
-    # then use dlltool to assemble a delaylib.
-    win32_qemu_plugin_api_lib = configure_file(
-      input: win32_plugin_def,
-      output: 'libqemu_plugin_api.a',
-      command: [dlltool, '--input-def', '@INPUT@',
-                '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe']
-    )
-  endif
-  specific_ss.add(files(
-    'loader.c',
-    'core.c',
-    'api.c',
-  ))
+  # Generate a .lib file for plugins to link against.
+  # First, create a .def file listing all the symbols a plugin should expect to have
+  # available in qemu
+  win32_plugin_def = configure_file(
+    input: files('qemu-plugins.symbols'),
+    output: 'qemu_plugin_api.def',
+    capture: true,
+    command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@'])
+  # then use dlltool to assemble a delaylib.
+  win32_qemu_plugin_api_lib = configure_file(
+    input: win32_plugin_def,
+    output: 'libqemu_plugin_api.a',
+    command: [dlltool, '--input-def', '@INPUT@',
+              '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe']
+  )
 endif
+specific_ss.add(files(
+  'loader.c',
+  'core.c',
+  'api.c',
+))
Signature · 1 line
2.45.2
#1 lore raw
Quoted 11 lines · Philippe Mathieu-Daudé

Since commit 0082475e26 the plugin symbol list is unconditionally added to the linker flags, leading to a build failure:

Undefined symbols for architecture arm64:
"_qemu_plugin_entry_code", referenced from:
<initial-undefines>
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Quoted 8 lines

Fix by restricting the whole meson file to the --enable-plugins configure argument.

Fixes 0082475e26 ("meson: merge plugin_ldflags into emulator_link_args")
---
  plugins/meson.build | 50 +++++++++++++++++++++++----------------------
  1 file changed, 26 insertions(+), 24 deletions(-)
Applied
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Since commit 0082475e26 the plugin symbol list is unconditionally added to the linker flags, leading to a build failure:

Undefined symbols for architecture arm64:
"_qemu_plugin_entry_code", referenced from:
<initial-undefines>
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Quoted 5 lines

Fix by restricting the whole meson file to the --enable-plugins configure argument.

Fixes 0082475e26 ("meson: merge plugin_ldflags into emulator_link_args")

Queued to maintainer/for-9.1, thanks.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#3 lore raw
Quoted 13 lines · Alex Bennée
Quoted 11 lines · Philippe Mathieu-Daudé

Since commit 0082475e26 the plugin symbol list is unconditionally added to the linker flags, leading to a build failure:

Undefined symbols for architecture arm64:
"_qemu_plugin_entry_code", referenced from:
<initial-undefines>
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Quoted 7 lines
Quoted 5 lines

Fix by restricting the whole meson file to the --enable-plugins configure argument.

Fixes 0082475e26 ("meson: merge plugin_ldflags into emulator_link_args")

Queued to maintainer/for-9.1, thanks.

Thanks, possibly also:

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2476

(Cc'ing Helge to confirm)