Commit 53ae381b10 for qemu.org

commit 53ae381b10478269372ce8d83f785db7c87bb18a
Author: Tan Chi <tanchi25@mails.ucas.ac.cn>
Date:   Sun Nov 1 11:15:44 2026 +0800

    hw/riscv: Build device-common only for its users

    hw/riscv/device-common.c is built unconditionally, although its
    helpers are only used by the virt and server reference machines.

    In minimal builds without these machines, device-common.c can
    reference device implementations that are not built, resulting
    in an undefined reference to gpex_set_irq_num().

    Introduce CONFIG_RISCV_DEVICE_COMMON and select it from the two
    machines that use these helpers. Build device-common.c only
    when this option is enabled.

    Signed-off-by: Tan Chi <tanchi25@mails.ucas.ac.cn>
    Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
    Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
    Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
    Message-ID: <20261101031547.125591-3-tanchi25@mails.ucas.ac.cn>
    Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
index d89fdfcc86..f3bf8d159c 100644
--- a/hw/riscv/Kconfig
+++ b/hw/riscv/Kconfig
@@ -7,6 +7,9 @@ config RISCV_NUMA
 config IBEX
     bool

+config RISCV_DEVICE_COMMON
+    bool
+
 # RISC-V machines in alphabetical order

 config MICROCHIP_PFSOC
@@ -68,6 +71,7 @@ config RISCV_VIRT
     select PLATFORM_BUS
     select ACPI
     select ACPI_PCI
+    select RISCV_DEVICE_COMMON

 config RISCV_SERVER_PLATFORM_REF
     bool
@@ -85,6 +89,7 @@ config RISCV_SERVER_PLATFORM_REF
     select RISCV_IOMMU
     select RISCV_NUMA
     select SERIAL_MM
+    select RISCV_DEVICE_COMMON

 config SHAKTI_C
     bool
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
index 957031c07d..b60108787d 100644
--- a/hw/riscv/meson.build
+++ b/hw/riscv/meson.build
@@ -2,7 +2,7 @@ riscv_ss = ss.source_set()
 riscv_ss.add(when: ['CONFIG_RISCV_APLIC', 'CONFIG_RISCV_IMSIC'],
              if_true: files('aia.c'))
 riscv_ss.add(files('boot.c'))
-riscv_ss.add(files('device-common.c'))
+riscv_ss.add(when: 'CONFIG_RISCV_DEVICE_COMMON', if_true: files('device-common.c'))
 riscv_ss.add(files('fdt-common.c'))
 riscv_ss.add(when: 'CONFIG_RISCV_NUMA', if_true: files('numa.c'))
 riscv_ss.add(files('riscv_hart.c'))