linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] kbuild: remove all "obj- := dummy.o" tricks
@ 2017-11-07 16:31 Masahiro Yamada
  2017-11-07 16:31 ` [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it Masahiro Yamada
  2017-11-07 16:31 ` [PATCH 2/2] kbuild: remove all dummy assignments to obj- Masahiro Yamada
  0 siblings, 2 replies; 8+ messages in thread
From: Masahiro Yamada @ 2017-11-07 16:31 UTC (permalink / raw)
  To: linux-kbuild, Sam Ravnborg
  Cc: Rob Herring, Mark Rutland, Pantelis Antoniou, devicetree,
	Arnd Bergmann, linux-mips, linux-kernel, Michal Marek,
	Masahiro Yamada, Ralf Baechle, Michal Marek, netdev,
	Russell King, Alexei Starovoitov, Daniel Borkmann,
	linux-arm-kernel


This clean-up was prompted by Sam
when I refactored DT building:
https://patchwork.kernel.org/patch/10041881/

If you want to test this series,
apply the following 3 patches:
https://patchwork.kernel.org/patch/10037891/
https://patchwork.kernel.org/patch/10041877/
https://patchwork.kernel.org/patch/10041881/

I CCed DT forks to informs them of conflicts
with those patches Rob Herring offered to apply.
I doubt if he wants to review this series...



Masahiro Yamada (2):
  kbuild: create built-in.o automatically if parent directory wants it
  kbuild: remove all dummy assignments to obj-

 Makefile                                  | 2 +-
 arch/arm/mach-uniphier/Makefile           | 1 -
 arch/mips/boot/dts/brcm/Makefile          | 3 ---
 arch/mips/boot/dts/cavium-octeon/Makefile | 3 ---
 arch/mips/boot/dts/img/Makefile           | 3 ---
 arch/mips/boot/dts/ingenic/Makefile       | 3 ---
 arch/mips/boot/dts/lantiq/Makefile        | 3 ---
 arch/mips/boot/dts/mti/Makefile           | 3 ---
 arch/mips/boot/dts/netlogic/Makefile      | 3 ---
 arch/mips/boot/dts/ni/Makefile            | 3 ---
 arch/mips/boot/dts/pic32/Makefile         | 3 ---
 arch/mips/boot/dts/qca/Makefile           | 3 ---
 arch/mips/boot/dts/ralink/Makefile        | 3 ---
 arch/mips/boot/dts/xilfpga/Makefile       | 3 ---
 firmware/Makefile                         | 3 ---
 samples/bpf/Makefile                      | 3 ---
 samples/hidraw/Makefile                   | 3 ---
 samples/seccomp/Makefile                  | 3 ---
 samples/sockmap/Makefile                  | 3 ---
 samples/statx/Makefile                    | 3 ---
 samples/uhid/Makefile                     | 3 ---
 scripts/Makefile.build                    | 4 ++--
 22 files changed, 3 insertions(+), 61 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it
  2017-11-07 16:31 [PATCH 0/2] kbuild: remove all "obj- := dummy.o" tricks Masahiro Yamada
@ 2017-11-07 16:31 ` Masahiro Yamada
  2017-11-09  5:35   ` Sam Ravnborg
  2017-11-18  4:06   ` Masahiro Yamada
  2017-11-07 16:31 ` [PATCH 2/2] kbuild: remove all dummy assignments to obj- Masahiro Yamada
  1 sibling, 2 replies; 8+ messages in thread
From: Masahiro Yamada @ 2017-11-07 16:31 UTC (permalink / raw)
  To: linux-kbuild, Sam Ravnborg
  Cc: Rob Herring, Mark Rutland, Pantelis Antoniou, devicetree,
	Arnd Bergmann, linux-mips, linux-kernel, Michal Marek,
	Masahiro Yamada, Michal Marek

"obj-y += foo/" syntax requires Kbuild to visit the "foo" subdirectory
and link built-in.o from that directory.  This means foo/Makefile is
responsible for creating built-in.o even if there is no object to
link (in this case, built-in.o is an empty archive).

We have had several fixups like commit 4b024242e8a4 ("kbuild: Fix
linking error built-in.o no such file or directory"), then ended up
with a complex condition as follows:

  ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
  builtin-target := $(obj)/built-in.o
  endif

We still have more cases not covered by the above, so we need to add
  obj- := dummy.o
in several places just for creating empty built-in.o.

A key point is, the parent Makefile knows whether built-in.o is needed
or not.  If a subdirectory needs to create built-in.o, its parent can
tell the fact when Kbuild descends into it.

If non-empty $(need-builtin) flag is passed from the parent, built-in.o
should be created.  $(obj-y) should be still checked to support the
single target "%/".  All of ugly tricks will go away.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile               | 2 +-
 scripts/Makefile.build | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 008a4e5..cc0b618 100644
--- a/Makefile
+++ b/Makefile
@@ -1003,7 +1003,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
 
 PHONY += $(vmlinux-dirs)
 $(vmlinux-dirs): prepare scripts
-	$(Q)$(MAKE) $(build)=$@
+	$(Q)$(MAKE) $(build)=$@ need-builtin=1
 
 define filechk_kernel.release
 	echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 061d0c3..e1c6efd 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -84,7 +84,7 @@ lib-target := $(obj)/lib.a
 obj-y += $(obj)/lib-ksyms.o
 endif
 
-ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
+ifneq ($(strip $(obj-y) $(need-builtin)),)
 builtin-target := $(obj)/built-in.o
 endif
 
@@ -569,7 +569,7 @@ targets += $(multi-used-y) $(multi-used-m)
 
 PHONY += $(subdir-ym)
 $(subdir-ym):
-	$(Q)$(MAKE) $(build)=$@
+	$(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1)
 
 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
 # ---------------------------------------------------------------------------
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] kbuild: remove all dummy assignments to obj-
  2017-11-07 16:31 [PATCH 0/2] kbuild: remove all "obj- := dummy.o" tricks Masahiro Yamada
  2017-11-07 16:31 ` [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it Masahiro Yamada
@ 2017-11-07 16:31 ` Masahiro Yamada
  2017-11-18  4:08   ` Masahiro Yamada
  1 sibling, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2017-11-07 16:31 UTC (permalink / raw)
  To: linux-kbuild, Sam Ravnborg
  Cc: Rob Herring, Mark Rutland, Pantelis Antoniou, devicetree,
	Arnd Bergmann, linux-mips, linux-kernel, Michal Marek,
	Masahiro Yamada, Ralf Baechle, Alexei Starovoitov, netdev,
	Russell King, Daniel Borkmann, linux-arm-kernel

Now kbuild core scripts create empty built-in.o where necessary.
Remove "obj- := dummy.o" tricks.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 arch/arm/mach-uniphier/Makefile           | 1 -
 arch/mips/boot/dts/brcm/Makefile          | 3 ---
 arch/mips/boot/dts/cavium-octeon/Makefile | 3 ---
 arch/mips/boot/dts/img/Makefile           | 3 ---
 arch/mips/boot/dts/ingenic/Makefile       | 3 ---
 arch/mips/boot/dts/lantiq/Makefile        | 3 ---
 arch/mips/boot/dts/mti/Makefile           | 3 ---
 arch/mips/boot/dts/netlogic/Makefile      | 3 ---
 arch/mips/boot/dts/ni/Makefile            | 3 ---
 arch/mips/boot/dts/pic32/Makefile         | 3 ---
 arch/mips/boot/dts/qca/Makefile           | 3 ---
 arch/mips/boot/dts/ralink/Makefile        | 3 ---
 arch/mips/boot/dts/xilfpga/Makefile       | 3 ---
 firmware/Makefile                         | 3 ---
 samples/bpf/Makefile                      | 3 ---
 samples/hidraw/Makefile                   | 3 ---
 samples/seccomp/Makefile                  | 3 ---
 samples/sockmap/Makefile                  | 3 ---
 samples/statx/Makefile                    | 3 ---
 samples/uhid/Makefile                     | 3 ---
 20 files changed, 58 deletions(-)

diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile
index 6bea3d3..e69de29 100644
--- a/arch/arm/mach-uniphier/Makefile
+++ b/arch/arm/mach-uniphier/Makefile
@@ -1 +0,0 @@
-obj- += dummy.o
diff --git a/arch/mips/boot/dts/brcm/Makefile b/arch/mips/boot/dts/brcm/Makefile
index bacb131..fcf68a2 100644
--- a/arch/mips/boot/dts/brcm/Makefile
+++ b/arch/mips/boot/dts/brcm/Makefile
@@ -34,6 +34,3 @@ dtb-$(CONFIG_DT_NONE) += \
 	bcm97435svmb.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/cavium-octeon/Makefile b/arch/mips/boot/dts/cavium-octeon/Makefile
index e9592a9..a857b4c 100644
--- a/arch/mips/boot/dts/cavium-octeon/Makefile
+++ b/arch/mips/boot/dts/cavium-octeon/Makefile
@@ -1,6 +1,3 @@
 dtb-$(CONFIG_CAVIUM_OCTEON_SOC)	+= octeon_3xxx.dtb octeon_68xx.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/img/Makefile b/arch/mips/boot/dts/img/Makefile
index a46d773..17dedb7 100644
--- a/arch/mips/boot/dts/img/Makefile
+++ b/arch/mips/boot/dts/img/Makefile
@@ -2,6 +2,3 @@ dtb-$(CONFIG_FIT_IMAGE_FDT_BOSTON)	+= boston.dtb
 
 dtb-$(CONFIG_MACH_PISTACHIO)	+= pistachio_marduk.dtb
 obj-$(CONFIG_MACH_PISTACHIO)	+= pistachio_marduk.dtb.o
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/ingenic/Makefile b/arch/mips/boot/dts/ingenic/Makefile
index ddd0faf..f2e516c 100644
--- a/arch/mips/boot/dts/ingenic/Makefile
+++ b/arch/mips/boot/dts/ingenic/Makefile
@@ -2,6 +2,3 @@ dtb-$(CONFIG_JZ4740_QI_LB60)	+= qi_lb60.dtb
 dtb-$(CONFIG_JZ4780_CI20)	+= ci20.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/lantiq/Makefile b/arch/mips/boot/dts/lantiq/Makefile
index 586b1c9..fed59e0 100644
--- a/arch/mips/boot/dts/lantiq/Makefile
+++ b/arch/mips/boot/dts/lantiq/Makefile
@@ -1,6 +1,3 @@
 dtb-$(CONFIG_DT_EASY50712)	+= easy50712.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/mti/Makefile b/arch/mips/boot/dts/mti/Makefile
index faf7ac4..35cf12b 100644
--- a/arch/mips/boot/dts/mti/Makefile
+++ b/arch/mips/boot/dts/mti/Makefile
@@ -2,6 +2,3 @@ dtb-$(CONFIG_MIPS_MALTA)	+= malta.dtb
 dtb-$(CONFIG_LEGACY_BOARD_SEAD3)	+= sead3.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/netlogic/Makefile b/arch/mips/boot/dts/netlogic/Makefile
index 77ffb30..84a38eb 100644
--- a/arch/mips/boot/dts/netlogic/Makefile
+++ b/arch/mips/boot/dts/netlogic/Makefile
@@ -5,6 +5,3 @@ dtb-$(CONFIG_DT_XLP_GVP)	+= xlp_gvp.dtb
 dtb-$(CONFIG_DT_XLP_RVP)	+= xlp_rvp.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/ni/Makefile b/arch/mips/boot/dts/ni/Makefile
index 6cd9c60..9e2c9fa 100644
--- a/arch/mips/boot/dts/ni/Makefile
+++ b/arch/mips/boot/dts/ni/Makefile
@@ -1,4 +1 @@
 dtb-$(CONFIG_FIT_IMAGE_FDT_NI169445)	+= 169445.dtb
-
-# Force kbuild to make empty built-in.o if necessary
-obj-					+= dummy.o
diff --git a/arch/mips/boot/dts/pic32/Makefile b/arch/mips/boot/dts/pic32/Makefile
index 5a08e48..6ecc249 100644
--- a/arch/mips/boot/dts/pic32/Makefile
+++ b/arch/mips/boot/dts/pic32/Makefile
@@ -4,6 +4,3 @@ dtb-$(CONFIG_DTB_PIC32_NONE)		+= \
 					pic32mzda_sk.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/qca/Makefile b/arch/mips/boot/dts/qca/Makefile
index 181db5d..ad6429b 100644
--- a/arch/mips/boot/dts/qca/Makefile
+++ b/arch/mips/boot/dts/qca/Makefile
@@ -4,6 +4,3 @@ dtb-$(CONFIG_ATH79)			+= ar9331_dpt_module.dtb
 dtb-$(CONFIG_ATH79)			+= ar9331_dragino_ms14.dtb
 dtb-$(CONFIG_ATH79)			+= ar9331_omega.dtb
 dtb-$(CONFIG_ATH79)			+= ar9331_tl_mr3020.dtb
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/ralink/Makefile b/arch/mips/boot/dts/ralink/Makefile
index 7b64654..baaea4a 100644
--- a/arch/mips/boot/dts/ralink/Makefile
+++ b/arch/mips/boot/dts/ralink/Makefile
@@ -6,6 +6,3 @@ dtb-$(CONFIG_DTB_OMEGA2P)	+= omega2p.dtb
 dtb-$(CONFIG_DTB_VOCORE2)	+= vocore2.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/arch/mips/boot/dts/xilfpga/Makefile b/arch/mips/boot/dts/xilfpga/Makefile
index 77c8096..53f755f 100644
--- a/arch/mips/boot/dts/xilfpga/Makefile
+++ b/arch/mips/boot/dts/xilfpga/Makefile
@@ -1,6 +1,3 @@
 dtb-$(CONFIG_XILFPGA_NEXYS4DDR)	+= nexys4ddr.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
-
-# Force kbuild to make empty built-in.o if necessary
-obj-				+= dummy.o
diff --git a/firmware/Makefile b/firmware/Makefile
index fa08088..6524be1 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -58,6 +58,3 @@ endif
 
 targets := $(patsubst $(obj)/%,%, \
                                 $(shell find $(obj) -name \*.gen.S 2>/dev/null))
-# Without this, built-in.o won't be created when it's empty, and the
-# final vmlinux link will fail.
-obj- := dummy
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index cf17c79..4ea6f75 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -1,6 +1,3 @@
-# kbuild trick to avoid linker error. Can be omitted if a module is built.
-obj- := dummy.o
-
 # List of programs to build
 hostprogs-y := test_lru_dist
 hostprogs-y += sock_example
diff --git a/samples/hidraw/Makefile b/samples/hidraw/Makefile
index a9ab961..329da9c 100644
--- a/samples/hidraw/Makefile
+++ b/samples/hidraw/Makefile
@@ -1,6 +1,3 @@
-# kbuild trick to avoid linker error. Can be omitted if a module is built.
-obj- := dummy.o
-
 # List of programs to build
 hostprogs-y := hid-example
 
diff --git a/samples/seccomp/Makefile b/samples/seccomp/Makefile
index bf7cc6b..5c6baac 100644
--- a/samples/seccomp/Makefile
+++ b/samples/seccomp/Makefile
@@ -1,6 +1,3 @@
-# kbuild trick to avoid linker error. Can be omitted if a module is built.
-obj- := dummy.o
-
 hostprogs-$(CONFIG_SAMPLE_SECCOMP) := bpf-fancy dropper bpf-direct
 
 HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include
diff --git a/samples/sockmap/Makefile b/samples/sockmap/Makefile
index 9291ab8..73f1da4 100644
--- a/samples/sockmap/Makefile
+++ b/samples/sockmap/Makefile
@@ -1,6 +1,3 @@
-# kbuild trick to avoid linker error. Can be omitted if a module is built.
-obj- := dummy.o
-
 # List of programs to build
 hostprogs-y := sockmap
 
diff --git a/samples/statx/Makefile b/samples/statx/Makefile
index 1f80a3d..59df7c2 100644
--- a/samples/statx/Makefile
+++ b/samples/statx/Makefile
@@ -1,6 +1,3 @@
-# kbuild trick to avoid linker error. Can be omitted if a module is built.
-obj- := dummy.o
-
 # List of programs to build
 hostprogs-$(CONFIG_SAMPLE_STATX) := test-statx
 
diff --git a/samples/uhid/Makefile b/samples/uhid/Makefile
index c95a696..8d7fd61 100644
--- a/samples/uhid/Makefile
+++ b/samples/uhid/Makefile
@@ -1,6 +1,3 @@
-# kbuild trick to avoid linker error. Can be omitted if a module is built.
-obj- := dummy.o
-
 # List of programs to build
 hostprogs-y := uhid-example
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it
  2017-11-07 16:31 ` [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it Masahiro Yamada
@ 2017-11-09  5:35   ` Sam Ravnborg
  2017-11-09  5:53     ` Masahiro Yamada
  2017-11-18  4:06   ` Masahiro Yamada
  1 sibling, 1 reply; 8+ messages in thread
From: Sam Ravnborg @ 2017-11-09  5:35 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Rob Herring, Mark Rutland, Pantelis Antoniou,
	devicetree, Arnd Bergmann, linux-mips, linux-kernel,
	Michal Marek, Michal Marek

Hi Masahiro.

Thanks for picking this up.

> A key point is, the parent Makefile knows whether built-in.o is needed
> or not.  If a subdirectory needs to create built-in.o, its parent can
> tell the fact when Kbuild descends into it.
Good observation!
> 
> diff --git a/Makefile b/Makefile
> index 008a4e5..cc0b618 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1003,7 +1003,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
>  
>  PHONY += $(vmlinux-dirs)
>  $(vmlinux-dirs): prepare scripts
> -	$(Q)$(MAKE) $(build)=$@
> +	$(Q)$(MAKE) $(build)=$@ need-builtin=1

The need-bultin may also be required for the shortcuts
that allows one to use:

	make <dir>/

    example:

	make net/

And maybe selftest, documentation shortcuts too?
Other than that - looks good.

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

	Sam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it
  2017-11-09  5:35   ` Sam Ravnborg
@ 2017-11-09  5:53     ` Masahiro Yamada
  2017-11-09 16:08       ` Sam Ravnborg
  0 siblings, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2017-11-09  5:53 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Linux Kbuild mailing list, Rob Herring, Mark Rutland,
	Pantelis Antoniou, devicetree, Arnd Bergmann, Linux-MIPS,
	Linux Kernel Mailing List, Michal Marek, Michal Marek

Hi Sam,

Thanks for your review.

2017-11-09 14:35 GMT+09:00 Sam Ravnborg <sam@ravnborg.org>:
> Hi Masahiro.
>
> Thanks for picking this up.
>
>> A key point is, the parent Makefile knows whether built-in.o is needed
>> or not.  If a subdirectory needs to create built-in.o, its parent can
>> tell the fact when Kbuild descends into it.
> Good observation!
>>
>> diff --git a/Makefile b/Makefile
>> index 008a4e5..cc0b618 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -1003,7 +1003,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
>>
>>  PHONY += $(vmlinux-dirs)
>>  $(vmlinux-dirs): prepare scripts
>> -     $(Q)$(MAKE) $(build)=$@
>> +     $(Q)$(MAKE) $(build)=$@ need-builtin=1
>
> The need-bultin may also be required for the shortcuts
> that allows one to use:
>
>         make <dir>/
>
>     example:
>
>         make net/


I do not want to add need-builtin=1 for single targets.


make scripts/
would create false scripts/built-in.o
This is odd.

I wrote the solution in the commit log:
  $(obj-y) should be still checked to support the single target "%/".


If net/Makefile contains at least one obj-y,
"make net/" will create built-in.o





> And maybe selftest, documentation shortcuts too?
> Other than that - looks good.
>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
>
>         Sam
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it
  2017-11-09  5:53     ` Masahiro Yamada
@ 2017-11-09 16:08       ` Sam Ravnborg
  0 siblings, 0 replies; 8+ messages in thread
From: Sam Ravnborg @ 2017-11-09 16:08 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Rob Herring, Mark Rutland,
	Pantelis Antoniou, devicetree, Arnd Bergmann, Linux-MIPS,
	Linux Kernel Mailing List, Michal Marek, Michal Marek

Hi Masahiro.

On Thu, Nov 09, 2017 at 02:53:04PM +0900, Masahiro Yamada wrote:
> Hi Sam,
> 
> Thanks for your review.
> 
> 2017-11-09 14:35 GMT+09:00 Sam Ravnborg <sam@ravnborg.org>:
> > Hi Masahiro.
> >
> > Thanks for picking this up.
> >
> >> A key point is, the parent Makefile knows whether built-in.o is needed
> >> or not.  If a subdirectory needs to create built-in.o, its parent can
> >> tell the fact when Kbuild descends into it.
> > Good observation!
> >>
> >> diff --git a/Makefile b/Makefile
> >> index 008a4e5..cc0b618 100644
> >> --- a/Makefile
> >> +++ b/Makefile
> >> @@ -1003,7 +1003,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
> >>
> >>  PHONY += $(vmlinux-dirs)
> >>  $(vmlinux-dirs): prepare scripts
> >> -     $(Q)$(MAKE) $(build)=$@
> >> +     $(Q)$(MAKE) $(build)=$@ need-builtin=1
> >
> > The need-bultin may also be required for the shortcuts
> > that allows one to use:
> >
> >         make <dir>/
> >
> >     example:
> >
> >         make net/
> 
> 
> I do not want to add need-builtin=1 for single targets.
> 
> 
> make scripts/
> would create false scripts/built-in.o
> This is odd.
> 
> I wrote the solution in the commit log:
>   $(obj-y) should be still checked to support the single target "%/".

I missed this bit in the commit log,
but I almost commented on this in the patch itself.
Good way to do it.

	Sam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it
  2017-11-07 16:31 ` [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it Masahiro Yamada
  2017-11-09  5:35   ` Sam Ravnborg
@ 2017-11-18  4:06   ` Masahiro Yamada
  1 sibling, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2017-11-18  4:06 UTC (permalink / raw)
  To: Linux Kbuild mailing list, Sam Ravnborg
  Cc: Rob Herring, Mark Rutland, Pantelis Antoniou, devicetree,
	Arnd Bergmann, Linux-MIPS, Linux Kernel Mailing List,
	Michal Marek, Masahiro Yamada, Michal Marek

2017-11-08 1:31 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> "obj-y += foo/" syntax requires Kbuild to visit the "foo" subdirectory
> and link built-in.o from that directory.  This means foo/Makefile is
> responsible for creating built-in.o even if there is no object to
> link (in this case, built-in.o is an empty archive).
>
> We have had several fixups like commit 4b024242e8a4 ("kbuild: Fix
> linking error built-in.o no such file or directory"), then ended up
> with a complex condition as follows:
>
>   ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
>   builtin-target := $(obj)/built-in.o
>   endif
>
> We still have more cases not covered by the above, so we need to add
>   obj- := dummy.o
> in several places just for creating empty built-in.o.
>
> A key point is, the parent Makefile knows whether built-in.o is needed
> or not.  If a subdirectory needs to create built-in.o, its parent can
> tell the fact when Kbuild descends into it.
>
> If non-empty $(need-builtin) flag is passed from the parent, built-in.o
> should be created.  $(obj-y) should be still checked to support the
> single target "%/".  All of ugly tricks will go away.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>

Applied to linux-kbuild/kbuild.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] kbuild: remove all dummy assignments to obj-
  2017-11-07 16:31 ` [PATCH 2/2] kbuild: remove all dummy assignments to obj- Masahiro Yamada
@ 2017-11-18  4:08   ` Masahiro Yamada
  0 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2017-11-18  4:08 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Rob Herring, Mark Rutland, Pantelis Antoniou, devicetree,
	Arnd Bergmann, Linux-MIPS, Linux Kernel Mailing List,
	Michal Marek, Masahiro Yamada, Ralf Baechle, Alexei Starovoitov,
	netdev, Russell King, Daniel Borkmann, Sam Ravnborg,
	linux-arm-kernel

2017-11-08 1:31 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> Now kbuild core scripts create empty built-in.o where necessary.
> Remove "obj- := dummy.o" tricks.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>

Applied to linux-kbuild/kbuild.

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-11-18  4:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07 16:31 [PATCH 0/2] kbuild: remove all "obj- := dummy.o" tricks Masahiro Yamada
2017-11-07 16:31 ` [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it Masahiro Yamada
2017-11-09  5:35   ` Sam Ravnborg
2017-11-09  5:53     ` Masahiro Yamada
2017-11-09 16:08       ` Sam Ravnborg
2017-11-18  4:06   ` Masahiro Yamada
2017-11-07 16:31 ` [PATCH 2/2] kbuild: remove all dummy assignments to obj- Masahiro Yamada
2017-11-18  4:08   ` Masahiro Yamada

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).