diff mbox series

[05/10] build: Avoid build failure when building drivers as modules

Message ID 20200626164307.3327380-6-dinechin@redhat.com (mailing list archive)
State New, archived
Headers show
Series RFC: Move SPICE to a load module | expand

Commit Message

Christophe de Dinechin June 26, 2020, 4:43 p.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
---
 Makefile.objs    | 1 +
 Makefile.target  | 7 +++++++
 hw/Makefile.objs | 1 +
 3 files changed, 9 insertions(+)

Comments

Daniel P. Berrangé June 26, 2020, 5:23 p.m. UTC | #1
On Fri, Jun 26, 2020 at 06:43:02PM +0200, Christophe de Dinechin wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
> ---
>  Makefile.objs    | 1 +
>  Makefile.target  | 7 +++++++
>  hw/Makefile.objs | 1 +
>  3 files changed, 9 insertions(+)
> 
> diff --git a/Makefile.objs b/Makefile.objs
> index e38768c8d5..6703353493 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -86,6 +86,7 @@ endif # CONFIG_SOFTMMU
>  # Target-independent parts used in system and user emulation
>  common-obj-y += cpus-common.o
>  common-obj-y += hw/
> +common-obj-m += hw/
>  common-obj-y += qom/
>  common-obj-y += disas/
>  
> diff --git a/Makefile.target b/Makefile.target
> index 8ed1eba95b..3f3b5ee058 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -179,6 +179,13 @@ endif # CONFIG_SOFTMMU
>  dummy := $(call unnest-vars,,obj-y)
>  all-obj-y := $(obj-y)
>  
> +#
> +# common-obj-m has some crap here, probably as side effect from
> +# filling obj-y.  Clear it.  Fixes suspicious dependency errors when
> +# building devices as modules.
> +#
> +common-obj-m :=

This comment doesn't fill me with confidence - makes it feel like there's
some more important root cause that needs addressing instead.

>  include $(SRC_PATH)/Makefile.objs
>  dummy := $(call unnest-vars,.., \
>                 authz-obj-y \
> diff --git a/hw/Makefile.objs b/hw/Makefile.objs
> index 4cbe5e4e57..d6d387b74b 100644
> --- a/hw/Makefile.objs
> +++ b/hw/Makefile.objs
> @@ -43,4 +43,5 @@ devices-dirs-y += smbios/
>  endif
>  
>  common-obj-y += $(devices-dirs-y)
> +common-obj-m := display/
>  obj-y += $(devices-dirs-y)
> -- 
> 2.26.2
> 
> 

Regards,
Daniel
Gerd Hoffmann June 29, 2020, 11:26 p.m. UTC | #2
Hi,

> > +#
> > +# common-obj-m has some crap here, probably as side effect from
> > +# filling obj-y.  Clear it.  Fixes suspicious dependency errors when
> > +# building devices as modules.
> > +#
> > +common-obj-m :=
> 
> This comment doesn't fill me with confidence - makes it feel like there's
> some more important root cause that needs addressing instead.

It's my fault, see also
  https://patchwork.ozlabs.org/project/qemu-devel/patch/20200624131045.14512-5-kraxel@redhat.com/

I think the underlying problem is that the functions building *-m
variables do not properly handle per-target objects.  Which has no bad
side effects as long as we never recurse into hw/, but if we want build
devices as modules we have to ...

Unless we want build per-target code as module the above should do the
trick I think.

Better suggestions are welcome of course.

take care,
  Gerd
diff mbox series

Patch

diff --git a/Makefile.objs b/Makefile.objs
index e38768c8d5..6703353493 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -86,6 +86,7 @@  endif # CONFIG_SOFTMMU
 # Target-independent parts used in system and user emulation
 common-obj-y += cpus-common.o
 common-obj-y += hw/
+common-obj-m += hw/
 common-obj-y += qom/
 common-obj-y += disas/
 
diff --git a/Makefile.target b/Makefile.target
index 8ed1eba95b..3f3b5ee058 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -179,6 +179,13 @@  endif # CONFIG_SOFTMMU
 dummy := $(call unnest-vars,,obj-y)
 all-obj-y := $(obj-y)
 
+#
+# common-obj-m has some crap here, probably as side effect from
+# filling obj-y.  Clear it.  Fixes suspicious dependency errors when
+# building devices as modules.
+#
+common-obj-m :=
+
 include $(SRC_PATH)/Makefile.objs
 dummy := $(call unnest-vars,.., \
                authz-obj-y \
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 4cbe5e4e57..d6d387b74b 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -43,4 +43,5 @@  devices-dirs-y += smbios/
 endif
 
 common-obj-y += $(devices-dirs-y)
+common-obj-m := display/
 obj-y += $(devices-dirs-y)