From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Bernhard Beschow" <shentey@gmail.com>,
qemu-arm@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
qemu-ppc@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v2 2/3] configure: Ensure existance of dtc when libfdt is used
Date: Tue, 8 Jul 2025 22:48:05 +0200 [thread overview]
Message-ID: <20250708204806.1898-3-shentey@gmail.com> (raw)
In-Reply-To: <20250708204806.1898-1-shentey@gmail.com>
The next patch relies on dtc for boards with a bundled DTB. These boards
depend on libfdt already. Make sure that there is a dtc iff libfdt is used
such that the DTBs can be generated.
Co-developed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
meson.build | 16 +++--
pc-bios/dtb/meson.build | 1 -
subprojects/dtc.wrap | 1 +
.../packagefiles/dtc-meson-override.patch | 62 +++++++++++++++++++
4 files changed, 75 insertions(+), 5 deletions(-)
create mode 100644 subprojects/packagefiles/dtc-meson-override.patch
diff --git a/meson.build b/meson.build
index b5f74aa37a..2963789033 100644
--- a/meson.build
+++ b/meson.build
@@ -2089,13 +2089,15 @@ if numa.found() and not cc.links('''
endif
fdt = not_found
+dtc = not_found
fdt_opt = get_option('fdt')
if fdt_opt == 'enabled' and get_option('wrap_mode') == 'nodownload'
fdt_opt = 'system'
endif
if fdt_opt in ['enabled', 'system'] or (fdt_opt == 'auto' and have_system)
fdt = cc.find_library('fdt', required: fdt_opt == 'system')
- if fdt.found() and cc.links('''
+ dtc = find_program('dtc', required: fdt_opt == 'system')
+ if dtc.found() and fdt.found() and cc.links('''
#include <libfdt.h>
#include <libfdt_env.h>
int main(void) { fdt_find_max_phandle(NULL, NULL); return 0; }''',
@@ -2104,16 +2106,22 @@ if fdt_opt in ['enabled', 'system'] or (fdt_opt == 'auto' and have_system)
elif fdt_opt != 'system'
fdt_opt = get_option('wrap_mode') == 'nodownload' ? 'disabled' : 'internal'
fdt = not_found
+ dtc = not_found
else
- error('system libfdt is too old (1.5.1 or newer required)')
+ if dtc.found()
+ error('system libfdt is too old (1.5.1 or newer required)')
+ else
+ error('device tree compiler not found')
+ endif
endif
endif
if fdt_opt == 'internal'
assert(not fdt.found())
libfdt_proj = subproject('dtc', required: true,
- default_options: ['tools=false', 'yaml=disabled',
+ default_options: ['tools=true', 'yaml=disabled',
'python=disabled', 'default_library=static'])
- fdt = libfdt_proj.get_variable('libfdt_dep')
+ fdt = dependency('libfdt', required: true)
+ dtc = find_program('dtc', required: true)
endif
rdma = not_found
diff --git a/pc-bios/dtb/meson.build b/pc-bios/dtb/meson.build
index 993032949f..9fcdbeff14 100644
--- a/pc-bios/dtb/meson.build
+++ b/pc-bios/dtb/meson.build
@@ -5,7 +5,6 @@ dtbs = [
'petalogix-s3adsp1800.dtb',
]
-dtc = find_program('dtc', required: false)
if dtc.found()
foreach out : dtbs
f = fs.replace_suffix(out, '.dts')
diff --git a/subprojects/dtc.wrap b/subprojects/dtc.wrap
index d1bc9174e9..347ca61ea6 100644
--- a/subprojects/dtc.wrap
+++ b/subprojects/dtc.wrap
@@ -2,3 +2,4 @@
url = https://gitlab.com/qemu-project/dtc.git
revision = b6910bec11614980a21e46fbccc35934b671bd81
depth = 1
+diff_files = dtc-meson-override.patch
diff --git a/subprojects/packagefiles/dtc-meson-override.patch b/subprojects/packagefiles/dtc-meson-override.patch
new file mode 100644
index 0000000000..9dd8cf85a7
--- /dev/null
+++ b/subprojects/packagefiles/dtc-meson-override.patch
@@ -0,0 +1,62 @@
+diff --git a/libfdt/meson.build b/libfdt/meson.build
+index 0307ffb..6581965 100644
+--- a/libfdt/meson.build
++++ b/libfdt/meson.build
+@@ -30,6 +30,7 @@ libfdt_dep = declare_dependency(
+ include_directories: libfdt_inc,
+ link_with: libfdt,
+ )
++meson.override_dependency('libfdt', libfdt_dep)
+
+ install_headers(
+ files(
+diff --git a/meson.build b/meson.build
+index b23ea1b..7def0a6 100644
+--- a/meson.build
++++ b/meson.build
+@@ -54,6 +54,7 @@ version_gen_h = vcs_tag(
+
+ subdir('libfdt')
+
++dtc_tools = []
+ if get_option('tools')
+ flex = find_program('flex', required: true)
+ bison = find_program('bison', required: true)
+@@ -77,7 +78,7 @@ if get_option('tools')
+ )
+
+ if cc.check_header('fnmatch.h')
+- executable(
++ dtc_tools += executable(
+ 'convert-dtsv0',
+ [
+ lgen.process('convert-dtsv0-lexer.l'),
+@@ -88,7 +89,7 @@ if get_option('tools')
+ )
+ endif
+
+- executable(
++ dtc_tools += executable(
+ 'dtc',
+ [
+ lgen.process('dtc-lexer.l'),
+@@ -108,7 +109,7 @@ if get_option('tools')
+ )
+
+ foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay']
+- executable(e, files(e + '.c'), dependencies: util_dep, install: true)
++ dtc_tools += executable(e, files(e + '.c'), dependencies: util_dep, install: true)
+ endforeach
+
+ install_data(
+@@ -118,6 +119,10 @@ if get_option('tools')
+ )
+ endif
+
++foreach e: dtc_tools
++ meson.override_find_program(e.name(), e)
++endforeach
++
+ if not meson.is_cross_build()
+ if py.found() and swig.found()
+ subdir('pylibfdt')
--
2.50.0
next prev parent reply other threads:[~2025-07-08 21:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 20:48 [PATCH v2 0/3] DTB build housekeeping Bernhard Beschow
2025-07-08 20:48 ` [PATCH v2 1/3] hw/microblaze: Add missing FDT dependency Bernhard Beschow
2025-07-14 21:34 ` Philippe Mathieu-Daudé
2025-07-08 20:48 ` Bernhard Beschow [this message]
2025-07-08 20:48 ` [PATCH v2 3/3] pc-bios/dtb: Remove device tree blobs Bernhard Beschow
2025-07-14 21:35 ` Philippe Mathieu-Daudé
2025-07-14 17:48 ` [PATCH v2 0/3] DTB build housekeeping Bernhard Beschow
2025-07-15 6:06 ` Philippe Mathieu-Daudé
2025-08-14 5:15 ` Paolo Bonzini
2025-08-28 11:13 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250708204806.1898-3-shentey@gmail.com \
--to=shentey@gmail.com \
--cc=berrange@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).