Skip to contentSkip to conversation

Merge dtc

DISCUSSION Milton Miller 5 participants 12 messages Oct 18, 2007 – Nov 8, 2007 PowerPC

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines · David Gibson

This very large patch incorporates a copy of dtc into the kernel source, in arch/powerpc/boot/dtc-src. This means that dtc is no longer an external dependency to build kernels with configurations which need a dtb file.

Signed-off-by David Gibson <david at gibson.dropbear.id.au>

Too big for the list, full patch at
http://ozlabs.org/~dgibson/home/merge-dtc.patch+

So split it up. The obvious one is "here is the unique content, then copy these files from dtc git" would have been better.

I finally went and looked at the url. The Kbuild integration is wrong.
It should build dtc in dtc-src and run the binary from there, and the
rules should be in a Kconfig as a normal host-target in that directory.
(I don't have a problem with that Kbuild including Makefie.dtc).

things like the dependancy on scripts_basic in the top level Makefile.

milton

#1 lore raw
Quoted 7 lines · Milton Miller
Quoted 5 lines · David Gibson

This very large patch incorporates a copy of dtc into the kernel source, in arch/powerpc/boot/dtc-src. This means that dtc is no longer an external dependency to build kernels with configurations which need a dtb file.

Quoted 7 lines
Quoted 4 lines
Signed-off-by David Gibson <david at gibson.dropbear.id.au>

Too big for the list, full patch at
http://ozlabs.org/~dgibson/home/merge-dtc.patch+

So split it up. The obvious one is "here is the unique content, then
copy these files from dtc git" would have been better.

One obvious split is a patch solely containing the _shipped files. And next patch the rest.

As Milton already pointed out you should build dtc in the dtc directory (why the -src prefix??).
And the dtc specific Makefile looks like something from the late 80'. Please drop all these ALLUPPERCASE variables and accept a little bit of redundancy.
Then mere humans may be able to read the Makefile.

When you have done the above I would be happy to review the kbuild bits.

Sam

#10 lore raw
In reply to Milton Miller
Quoted 7 lines · Milton Miller
Quoted 5 lines · David Gibson

This very large patch incorporates a copy of dtc into the kernel source, in arch/powerpc/boot/dtc-src. This means that dtc is no longer an external dependency to build kernels with configurations which need a dtb file.

Quoted 7 lines
Quoted 4 lines
Signed-off-by David Gibson <david at gibson.dropbear.id.au>

Too big for the list, full patch at
http://ozlabs.org/~dgibson/home/merge-dtc.patch+

So split it up. The obvious one is "here is the unique content, then
copy these files from dtc git" would have been better.

*facepalm*

The point of the small patches thing is not to glom together logically separate patches. It's *not* to split patches up simply for the sake of making them smaller.

You've suggested the closest thing to a logical split here, but even then - the dtc files are dead without the Makefile changes, and the Makefile changes won't build without the dtc files (so the patches would have to go in reversed order to what you suggest).

Not to mention that the Makefile patch will be tiny and the raw import will still be way too big for the list.

Quoted 1 line

I finally went and looked at the url. The Kbuild integration is wrong.

Wrong? Not how you'd prefer them perhaps...

Quoted 2 lines

It should build dtc in dtc-src and run the binary from there, and the
rules should be in a Kconfig as a normal host-target in that directory.

Why? This approach has the advantage that the subdirectory contains *only* verbatim imported files, which could well make updates simpler.

Quoted 4 lines

(I don't have a problem with that Kbuild including Makefie.dtc).

things like the dependancy on scripts_basic in the top level Makefile.

I'm not even sure what you mean by this.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#2 lore raw
In reply to Sam Ravnborg
Quoted 10 lines · Sam Ravnborg
Quoted 9 lines · Milton Miller
Quoted 7 lines · David Gibson

This very large patch incorporates a copy of dtc into the kernel source, in arch/powerpc/boot/dtc-src. This means that dtc is no longer an external dependency to build kernels with configurations which need a dtb file.

Signed-off-by David Gibson <david at gibson.dropbear.id.au>
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Too big for the list, full patch at
http://ozlabs.org/~dgibson/home/merge-dtc.patch+

So split it up. The obvious one is "here is the unique content, then
copy these files from dtc git" would have been better.

One obvious split is a patch solely containing the _shipped files. And next patch the rest.

Um.. why? No way is that a logical split.

Quoted 2 lines

As Milton already pointed out you should build dtc in the dtc directory (why the -src prefix??).

The -src suffix is only there because I'm not building in the directory - we can't have both a dtc binary and a dtc directory in arch/powerpc/boot.

Ok, so how do I build in the subdirectory? I was going to do that, but couldn't for the life of me figure out how.

Quoted 3 lines

And the dtc specific Makefile looks like something from the late 80'. Please drop all these ALLUPPERCASE variables and accept a little bit of redundancy.

Hrm... I'm pretty dubious about this. Practically every Makefile in the universe, *except* Kbuild uses uppercase for most variables. Makefile.dtc is imported verbatim from the standalone dtc package, and is supposed to have the minimal information about what needs to be built to import into Makefiles that actually know how to build things.

Quoted 1 line

Then mere humans may be able to read the Makefile.

Says a maintainer of Kbuild, about my tiny and not-very-complex Makefile fragment... um, ok...

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#11 lore raw
In reply to David Gibson
Quoted 5 lines · David Gibson
Quoted 4 lines · Milton Miller
Quoted 2 lines · David Gibson

Too big for the list, full patch at
http://ozlabs.org/~dgibson/home/merge-dtc.patch+

Quoted 8 lines
Quoted 2 lines

So split it up. The obvious one is "here is the unique content, then
copy these files from dtc git" would have been better.

*facepalm*

The point of the small patches thing is not to glom together logically separate patches. It's *not* to split patches up simply for the sake of making them smaller.

The point of posting on the list is to encourage review before merging.
Hiding them behind a download means a lot fewer people are looking at
the code.

Quoted 7 lines

You've suggested the closest thing to a logical split here, but even then - the dtc files are dead without the Makefile changes, and the Makefile changes won't build without the dtc files (so the patches would have to go in reversed order to what you suggest).

Not to mention that the Makefile patch will be tiny and the raw import will still be way too big for the list.

I'm talking about split for review, not necessarily merge.

We split by function for review so that different people pay closer attention to their areas of intrest and speciality. This helps prevent people being distracted by the bulk.

The files that are verbatim from the other project have been reviewed in that project (at least in theory), and therefore are not likely to draw comments. Especially since they are (1) shadows from another project and (2) host files, there is more flexibility and less review required, eg relaxed coding standards, correctness already tested, and in this case multiple platform testing.

Sam's suggestion to split the generated files was because they require no review other than for damage.

In contrast, the files such as the make rules are original and unique to this import, and therefore draw comments during review. If you weren't asking for a review, why did you post to the mailing list?

Oh, and the files being in the tree but dead is fine from a bisect standpoint. The patch can be reverted if the makefile doesn't go in (not that a maintainer would commit them separately).

Quoted 3 lines
Quoted 1 line

I finally went and looked at the url. The Kbuild integration is wrong.

Wrong? Not how you'd prefer them perhaps...

Wrong in that its unlike every other program that Kbuild makes.

Quoted 6 lines
Quoted 3 lines

It should build dtc in dtc-src and run the binary from there, and
the
rules should be in a Kconfig as a normal host-target in that directory.

Why? This approach has the advantage that the subdirectory contains *only* verbatim imported files, which could well make updates simpler.

The file name Kbuild is unlikely to conflict with a file from that other repository. It doesn't contain all the files in that repository (or even all in a subdirectory) so there is some filtering going on anyways.

Quoted 6 lines

(I don't have a problem with that Kbuild including Makefie.dtc).

Quoted 3 lines

things like the dependancy on scripts_basic in the top level Makefile.

I'm not even sure what you mean by this.

I was trying to give a hint where you could find "compile programs in that directory so I can run them here" for you to draw upon.

#3 lore raw
In reply to David Gibson
Quoted 9 lines · David Gibson
Quoted 7 lines · Sam Ravnborg
Quoted 6 lines · Milton Miller
Quoted 4 lines · David Gibson

This very large patch incorporates a copy of dtc into the kernel source, in arch/powerpc/boot/dtc-src. This means that dtc is no longer an external dependency to build kernels with configurations which need a dtb file.

Quoted 6 lines
Quoted 2 lines

As Milton already pointed out you should build dtc in the dtc directory (why the -src prefix??).

The -src suffix is only there because I'm not building in the directory - we can't have both a dtc binary and a dtc directory in arch/powerpc/boot.

So run the dtc binary stored in the sub directory. Thats what we do elsewhere.

Quoted 2 lines

Ok, so how do I build in the subdirectory? I was going to do that, but couldn't for the life of me figure out how.

Documentation/kbuild/makefiles.txt 6.4 boot images:

"$(Q)$(MAKE) $(build)=<dir>" is the recommended way to invoke make in a subdirectory.

Section 4 Host Program Support is also relavent, and mentions $(always).

Quoted 10 lines
Quoted 3 lines

And the dtc specific Makefile looks like something from the late 80'. Please drop all these ALLUPPERCASE variables and accept a little bit of redundancy.

Hrm... I'm pretty dubious about this. Practically every Makefile in the universe, *except* Kbuild uses uppercase for most variables. Makefile.dtc is imported verbatim from the standalone dtc package, and is supposed to have the minimal information about what needs to be built to import into Makefiles that actually know how to build things.

Quoted 4 lines
Quoted 1 line

Then mere humans may be able to read the Makefile.

Says a maintainer of Kbuild, about my tiny and not-very-complex Makefile fragment... um, ok...

overley complex calls to override source, conditional rules based on shipped files? Its not a trivial fragment.

milton

#4 lore raw
Quoted 13 lines · Milton Miller
Quoted 12 lines · David Gibson
Quoted 10 lines · Sam Ravnborg
Quoted 6 lines · Milton Miller
Quoted 4 lines · David Gibson

This very large patch incorporates a copy of dtc into the kernel source, in arch/powerpc/boot/dtc-src. This means that dtc is no longer an external dependency to build kernels with configurations which need a dtb file.

As Milton already pointed out you should build dtc in the dtc directory (why the -src prefix??).

Quoted 6 lines
Quoted 3 lines

The -src suffix is only there because I'm not building in the directory - we can't have both a dtc binary and a dtc directory in arch/powerpc/boot.

So run the dtc binary stored in the sub directory. Thats what we do elsewhere.

Yes, yes, which boils down to your other point of building in the subdirectory. It's not a separate issue.

Quoted 7 lines
Quoted 2 lines

Ok, so how do I build in the subdirectory? I was going to do that, but couldn't for the life of me figure out how.

Documentation/kbuild/makefiles.txt 6.4 boot images:

"$(Q)$(MAKE) $(build)=<dir>" is the recommended way to invoke make in a subdirectory.

But where does it go? To have somewhere to put that rule, we'd still need a target in arch/powerpc/boot itself.

Quoted 1 line

Section 4 Host Program Support is also relavent, and mentions $(always).

I know I tried using $(always), but I couldn't figure out how to make it do something useful.

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines

And the dtc specific Makefile looks like something from the late 80'. Please drop all these ALLUPPERCASE variables and accept a little bit of redundancy.

Hrm... I'm pretty dubious about this. Practically every Makefile in the universe, *except* Kbuild uses uppercase for most variables. Makefile.dtc is imported verbatim from the standalone dtc package, and is supposed to have the minimal information about what needs to be built to import into Makefiles that actually know how to build things.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Then mere humans may be able to read the Makefile.

Says a maintainer of Kbuild, about my tiny and not-very-complex Makefile fragment... um, ok...

overley complex calls to override source,

I'm not sure what you're referring to... even if you mean in Makefile.dtc or in the diff to arch/powerpc/boot/Makefile.

Quoted 2 lines

conditional rules based on
shipped files?

Or here, for sure. The shipped/lex/yacc rules are just based on those from Kconfig and genksyms.

Quoted 1 line

Its not a trivial fragment.

Compared to the behemoth that is Kbuild...

I'm happy to improve the Makefile integration, but you seem to be rather vague on how, and the Kbuild documentation makes my brain hurt.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#5 lore raw
Quoted 4 lines

Compared to the behemoth that is Kbuild...

I'm happy to improve the Makefile integration, but you seem to be rather vague on how, and the Kbuild documentation makes my brain hurt.

I can make an ALL UPPERCASE VERSION if that makes it easier for you to read ;-) Give me a day or two then I shall give it a try and see what I can do about it. I will use the previsous posted URL as basis if you do not tell me otherwise.

Sam

#6 lore raw
Quoted 7 lines · Sam Ravnborg
Quoted 4 lines

Compared to the behemoth that is Kbuild...

I'm happy to improve the Makefile integration, but you seem to be rather vague on how, and the Kbuild documentation makes my brain hurt.

I can make an ALL UPPERCASE VERSION if that makes it easier for you to read ;-)

Hardy har har. Since this is supposed to build both within the kernel and standalone there will necessarily be a few style conflicts at the boundary. Kbuild is not in the majority here; in fact it's close to unique.

Quoted 3 lines

Give me a day or two then I shall give it a try and see what I can do about it. I will use the previsous posted URL as basis if you do not tell me otherwise.

Thank you. The previous URL should be fine, I've made no changes since then.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Reviewed-by
#7 lore raw

Hi David.

Quoted 6 lines
Quoted 3 lines

Give me a day or two then I shall give it a try and see what I can do about it. I will use the previsous posted URL as basis if you do not tell me otherwise.

Thank you. The previous URL should be fine, I've made no changes since then.

I decided to go for a kbuild specific version integrated in boot/Makefile.
This is much more readable because this syntax is explicit. We do not favour 3 levels of variabls to avoid rewriting the same filename two times.
I have tested the change only with a O=.. crosscompile build.

I have tested the patch with and without DTC_GENPARSER=1. It does not rebuild if not needed and is OK with -j10 builds.

Please consider this version in favour of your old version.

Take this as review feedback.

You can add:

Thanks,
Sam

 arch/powerpc/boot/Makefile |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)
arch/powerpc/boot/Makefile +38 -2
index 18e3271..064dc07 100644
@@ -108,17 +108,53 @@ $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
 $(obj)/wrapper.a: $(obj-wlib) FORCE
 	$(call if_changed,bootar)
 
-hostprogs-y	:= addnote addRamDisk hack-coff mktree
+hostprogs-y	:= addnote addRamDisk hack-coff mktree dtc
 
 targets		+= $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a)
 extra-y		:= $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
 		   $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds
 
 wrapper		:=$(srctree)/$(src)/wrapper
-wrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
+wrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree dtc) \
 			$(wrapper) FORCE
 
 #############
+# Bits for building dtc
+# DTC_GENPARSER	:= 1	# Uncomment to rebuild flex/bison output
+
+dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o srcpos.o
+dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
+dtc-objs := $(addprefix dtc-src/, $(dtc-objs))
+
+# prerequisites on generated files needs to be explicit
+$(obj)/dtc-src/dtc-parser.tab.o: $(obj)/dtc-src/dtc-parser.tab.c $(obj)/dtc-src/dtc-parser.tab.h
+$(obj)/dtc-src/dtc-lexer.lex.o:  $(obj)/dtc-src/dtc-lexer.lex.c
+$(obj)/dtc-src/data.o:           $(obj)/dtc-src/dtc-parser.tab.h
+
+HOSTCFLAGS += -I$(src)/dtc-src/
+
+targets += dtc-src/dtc-parser.tab.c
+targets += dtc-src/dtc-lexer.lex.c
+
+ifdef DTC_GENPARSER
+BISON = bison
+FLEX = flex
+
+quiet_cmd_bison = BISON   $@
+      cmd_bison = $(BISON) -o$@ -d $<; cp $@ $@_shipped
+quiet_cmd_flex = FLEX    $@
+      cmd_flex = $(FLEX) -o$@ $<; cp $@ $@_shipped
+
+$(obj)/dtc-src/dtc-parser.tab.c: $(src)/dtc-src/dtc-parser.y FORCE
+	$(call if_changed,bison)
+
+$(obj)/dtc-src/dtc-parser.tab.h: $(obj)/dtc-src/dtc-parser.tab.c
+
+$(obj)/dtc-src/dtc-lexer.lex.c: $(src)/dtc-src/dtc-lexer.l FORCE
+	$(call if_changed,flex)
+endif
+
+#############
 # Bits for building various flavours of zImage
 
 ifneq ($(CROSS32_COMPILE),)
#8 lore raw
Quoted 6 lines · Sam Ravnborg

Hi David.

Quoted 4 lines
Quoted 3 lines

Give me a day or two then I shall give it a try and see what I can do about it. I will use the previsous posted URL as basis if you do not tell me otherwise.

Quoted 8 lines
Quoted 2 lines

Thank you. The previous URL should be fine, I've made no changes since then.

I decided to go for a kbuild specific version integrated in boot/Makefile.
This is much more readable because this syntax is explicit. We do not favour 3 levels of variabls to avoid rewriting the same filename two times.

Well, yes, on consideration the substitutions in Makefile.dtc are a bit over-involved. Although I still find describing its dozen or so lines as unreadable when set next to the intricate wonders of Kbuild a little... bemusing.

Quoted 6 lines

I have tested the change only with a O=.. crosscompile build.

I have tested the patch with and without DTC_GENPARSER=1. It does not rebuild if not needed and is OK with -j10 builds.

Please consider this version in favour of your old version.

Ok. I'll use this version in my next spin; except for adding one dependency you missed, and removing one which should never have been there (unneccessary #include, which I've already fixed in dtc upstream).

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#9 lore raw
Quoted 6 lines · David Gibson

Ok. I'll use this version in my next spin; except for adding one dependency you missed, and removing one which should never have been there (unneccessary #include, which I've already fixed in dtc upstream).

I think if we embed the DTC in the kernel tree, we should wait until it supports /dts-v1/ files first.

jdl