Skip to contentSkip to conversation

Only build dtc when DTC= is not set on the command line

RFC PATCH In review Jes Sorensen 3 participants 7 messages Oct 11, 2024 – Oct 14, 2024 Device tree

lore
Share & tools
lore
#0 lore raw

cover Only build dtc when DTC= is not set on the command line

From: Jes Sorensen <[email protected]>

RFC on Android it is quite common to have a prebuilt version of dtc. In this case one doesn't really want to build dtc in the kernel tree, as it is unused and to avoid the risk of mixing and matching dtc versions.

This is the simplest fix I see for this. An alternative would be to define a new DTC_USE_PREBUILT flag.

Thoughts?

Jes

Jes Sorensen (1):
Skip building dtc if a prebuilt binary is specified via DTC=

 scripts/dtc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
2.46.1
#1 lore raw

PATCH 1/1 Skip building dtc if a prebuilt binary is specified via DTC=

From: Jes Sorensen <[email protected]>

For Android it is common to use a prebuilt dtc, speficied via DTC=. In this case building dtc as part of the kernel is not necessary, and even unwanted to avoid mix and match between two different versions of dtc.

---
 scripts/dtc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
scripts/dtc/Makefile +3 -0
index b47f4daa4515..3b683dc7e582 100644
@@ -2,8 +2,11 @@
 # scripts/dtc makefile
 
 # *** Also keep .gitignore in sync when changing ***
+# If a prebuilt dtc binary is specificed, don't build dtc
+ifeq ($(DTC),)
 hostprogs-always-$(CONFIG_DTC)		+= dtc fdtoverlay
 hostprogs-always-$(CHECK_DTBS)		+= dtc
+endif
 
 dtc-objs	:= dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
 		   srcpos.o checks.o util.o
Signature · 1 line
2.46.1
maintainer
#2 lore raw

Re: [PATCH 1/1] Skip building dtc if a prebuilt binary is specified via DTC=

Quoted 11 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

For Android it is common to use a prebuilt dtc, speficied via DTC=. In this case building dtc as part of the kernel is not necessary, and even unwanted to avoid mix and match between two different versions of dtc.

---
 scripts/dtc/Makefile | 3 +++
 1 file changed, 3 insertions(+)

Well, this one is much simpler than a prior attempt[1] and may be acceptable. But I wonder if something is not handled here.

I think lack of external fdtoverlay support makes this incomplete.

Rob

[1] https://lore.kernel.org/all/[email protected]/

#3 lore raw

Re: [PATCH 1/1] Skip building dtc if a prebuilt binary is specified via DTC=

Quoted 13 lines · Rob Herring
Quoted 11 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

For Android it is common to use a prebuilt dtc, speficied via DTC=. In this case building dtc as part of the kernel is not necessary, and even unwanted to avoid mix and match between two different versions of dtc.

---
 scripts/dtc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
Quoted 4 lines

Well, this one is much simpler than a prior attempt[1] and may be acceptable. But I wonder if something is not handled here.

I think lack of external fdtoverlay support makes this incomplete.

So I was thinking about that. The only places I see in the tree that reference fdtoverlay are scripts/make_fit.py, scripts/Makefile.dtbs, and scripts/dtc/Makefile. I don't see anything calling make_fit.py.

We can either exclude fdtoverlay from this, or assume that if one explicitly sets prebuilts, fdtoverlay is there too.

Thoughts?

Thanks,
Jes

maintainer
#4 lore raw

Re: [PATCH 1/1] Skip building dtc if a prebuilt binary is specified via DTC=

Quoted 15 lines · Jes Sorensen
Quoted 13 lines · Rob Herring
Quoted 11 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

For Android it is common to use a prebuilt dtc, speficied via DTC=. In this case building dtc as part of the kernel is not necessary, and even unwanted to avoid mix and match between two different versions of dtc.

---
 scripts/dtc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
Quoted 8 lines
Quoted 4 lines

Well, this one is much simpler than a prior attempt[1] and may be acceptable. But I wonder if something is not handled here.

I think lack of external fdtoverlay support makes this incomplete.

So I was thinking about that. The only places I see in the tree that reference fdtoverlay are scripts/make_fit.py, scripts/Makefile.dtbs, and scripts/dtc/Makefile. I don't see anything calling make_fit.py.

"make dtbs" will use fdtoverlay if there are any base+overlay targets which there are an increasing number of.

Quoted 2 lines

We can either exclude fdtoverlay from this, or assume that if one explicitly sets prebuilts, fdtoverlay is there too.

Currently, if you set DTC you'll get external dtc plus in-tree fdtoverlay. With your patch, you'll get external dtc plus a build error because $(objtree)/scripts/dtc/fdtoverlay does not exist. Neither case is ideal.

Rob

#5 lore raw

Re: [PATCH 1/1] Skip building dtc if a prebuilt binary is specified via DTC=

Quoted 28 lines · Rob Herring
Quoted 15 lines · Jes Sorensen
Quoted 13 lines · Rob Herring
Quoted 11 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

For Android it is common to use a prebuilt dtc, speficied via DTC=. In this case building dtc as part of the kernel is not necessary, and even unwanted to avoid mix and match between two different versions of dtc.

---
 scripts/dtc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
Quoted 8 lines
Quoted 4 lines

Well, this one is much simpler than a prior attempt[1] and may be acceptable. But I wonder if something is not handled here.

I think lack of external fdtoverlay support makes this incomplete.

So I was thinking about that. The only places I see in the tree that reference fdtoverlay are scripts/make_fit.py, scripts/Makefile.dtbs, and scripts/dtc/Makefile. I don't see anything calling make_fit.py.

"make dtbs" will use fdtoverlay if there are any base+overlay targets which there are an increasing number of.

Quoted 7 lines
Quoted 2 lines

We can either exclude fdtoverlay from this, or assume that if one explicitly sets prebuilts, fdtoverlay is there too.

Currently, if you set DTC you'll get external dtc plus in-tree fdtoverlay. With your patch, you'll get external dtc plus a build error because $(objtree)/scripts/dtc/fdtoverlay does not exist. Neither case is ideal.

Agree, what path calls fdtoverlay ? I didn't see anything calling that script.

Thanks,
Jes

maintainer
#6 lore raw

Re: [PATCH 1/1] Skip building dtc if a prebuilt binary is specified via DTC=

Quoted 33 lines · Jes Sorensen
Quoted 31 lines · Rob Herring
Quoted 15 lines · Jes Sorensen
Quoted 13 lines · Rob Herring
Quoted 11 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

For Android it is common to use a prebuilt dtc, speficied via DTC=. In this case building dtc as part of the kernel is not necessary, and even unwanted to avoid mix and match between two different versions of dtc.

---
 scripts/dtc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
Quoted 8 lines
Quoted 4 lines

Well, this one is much simpler than a prior attempt[1] and may be acceptable. But I wonder if something is not handled here.

I think lack of external fdtoverlay support makes this incomplete.

So I was thinking about that. The only places I see in the tree that reference fdtoverlay are scripts/make_fit.py, scripts/Makefile.dtbs, and scripts/dtc/Makefile. I don't see anything calling make_fit.py.

"make dtbs" will use fdtoverlay if there are any base+overlay targets which there are an increasing number of.

Quoted 2 lines

We can either exclude fdtoverlay from this, or assume that if one explicitly sets prebuilts, fdtoverlay is there too.

Quoted 7 lines
Quoted 4 lines

Currently, if you set DTC you'll get external dtc plus in-tree fdtoverlay. With your patch, you'll get external dtc plus a build error because $(objtree)/scripts/dtc/fdtoverlay does not exist. Neither case is ideal.

Agree, what path calls fdtoverlay ? I didn't see anything calling that script.

It is the same magic used used to combine object files for a module. Anywhere you have "foo-dtbs = base.dtb overlay.dtbo \n dtbs-y += foo.dtb", foo.dtb will be built by applying the overlay with fdtoverlay.

Rob