Skip to contentSkip to conversation

libfdt/fdt_ro.c build issues...

U-Boot New Wolfgang Denk 3 participants 8 messages Aug 27, 2008 – Sep 8, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

Dear Kumar,

there are build problems with libfdt/fdt_ro.c :

...
tools/fdt_ro.c: In function 'fdt_path_offset':
tools/fdt_ro.c:158: warning: implicit declaration of function 'fdt_getprop_namelen' tools/fdt_ro.c:158: warning: assignment makes pointer from integer without a cast tools/fdt_ro.c: At top level:
tools/fdt_ro.c:281: error: conflicting types for 'fdt_getprop_namelen' tools/fdt_ro.c:158: error: previous implicit declaration of 'fdt_getprop_namelen' was here
...

...dor all boards.

If you have time, could you please have a look?

Best regards,

Wolfgang Denk

Signature · 9 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
[War] is instinctive. But the instinct can  be  fought.  We're  human
beings  with the blood of a million savage years on our hands! But we
can stop it. We can admit that we're killers ... but we're not  going
to  kill  today. That's all it takes! Knowing that we're not going to
kill today!
	-- Kirk, "A Taste of Armageddon", stardate 3193.0
#1 lore raw
Quoted 13 lines · Wolfgang Denk

Dear Kumar,

there are build problems with libfdt/fdt_ro.c :

...
tools/fdt_ro.c: In function 'fdt_path_offset':
tools/fdt_ro.c:158: warning: implicit declaration of function 'fdt_getprop_namelen' tools/fdt_ro.c:158: warning: assignment makes pointer from integer without a cast tools/fdt_ro.c: At top level:
tools/fdt_ro.c:281: error: conflicting types for 'fdt_getprop_namelen' tools/fdt_ro.c:158: error: previous implicit declaration of 'fdt_getprop_namelen' was here
...

Quoted 7 lines

...dor all boards.

If you have time, could you please have a look?

Best regards,

Wolfgang Denk

??? I'm not seeing this, even with a fresh pull from the u-boot repository.

The function is declared in include/libfdt.h, properly in my copy.

libfdt/fdt_ro.c includes...

#ifndef USE_HOSTCC
#include <fdt.h>
#include <libfdt.h>
#else
#include "fdt_host.h"
#endif

and then fdt_host.h includes libfdt.h...

/* Make sure to include u-boot version of libfdt include files */ #include "../include/fdt.h"
#include "../include/libfdt.h"
#include "../include/fdt_support.h"

Best regards,
gvb

#2 lore raw

Dear Jerry Van Baren,

Quoted 11 lines · In message <[email protected]> you wrote:
Quoted 11 lines

there are build problems with libfdt/fdt_ro.c :

...
tools/fdt_ro.c: In function 'fdt_path_offset':
tools/fdt_ro.c:158: warning: implicit declaration of function 'fdt_getprop_namelen' tools/fdt_ro.c:158: warning: assignment makes pointer from integer without a cast tools/fdt_ro.c: At top level:
tools/fdt_ro.c:281: error: conflicting types for 'fdt_getprop_namelen' tools/fdt_ro.c:158: error: previous implicit declaration of 'fdt_getprop_namelen' was here
...

...

Quoted 1 line

??? I'm not seeing this, even with a fresh pull from the u-boot repository.

It seems it happens only for out-of-tree builds (which is my standard mode of operation).

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
How many Unix hacks does it take to change a light bulb?  Let's  see,
   can you use a shell script for that or does it need a C program?
#3 lore raw
In reply to Jerry Van Baren

Dear Jerry Van Baren,

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 9 lines

...
tools/fdt_ro.c: In function 'fdt_path_offset':
tools/fdt_ro.c:158: warning: implicit declaration of function 'fdt_getprop_namelen' tools/fdt_ro.c:158: warning: assignment makes pointer from integer without a cast tools/fdt_ro.c: At top level:
tools/fdt_ro.c:281: error: conflicting types for 'fdt_getprop_namelen' tools/fdt_ro.c:158: error: previous implicit declaration of 'fdt_getprop_namelen' was here
...

...

Quoted 3 lines

??? I'm not seeing this, even with a fresh pull from the u-boot repository.

The function is declared in include/libfdt.h, properly in my copy.

The problem comes from tools/fdt_host.h which includes:

	/* Make sure to include u-boot version of libfdt include files */
	#include "../include/fdt.h"
	#include "../include/libfdt.h"
	#include "../include/fdt_support.h"

However, the actual compiler run looks like this:

make[1]: Entering directory `/home/wd/git/u-boot/work/tools'
ln -s /home/wd/git/u-boot/work/tools/../libfdt/fdt.c /work/wd/tmp-ppc/tools/fdt.c
ln -s /home/wd/git/u-boot/work/tools/../libfdt/fdt_ro.c /work/wd/tmp-ppc/tools/fdt_ro.c
gcc -g -Wall -idirafter /home/wd/git/u-boot/work/include -idirafter /work/wd/tmp-ppc/include2 -idirafter /work/wd/tmp-ppc/include -DTEXT_BASE=0xFFFA0000 -DUSE_HOSTCC -O -c -o /work/wd/tmp-ppc/tools/fdt_ro.o /work/wd/tmp-ppc/tools/fdt_ro.c

and causes this:

...
# 1 "/work/wd/tmp-ppc/tools/fdt_host.h" 1
# 24 "/work/wd/tmp-ppc/tools/fdt_host.h"
# 1 "/usr/local/include/../include/fdt.h" 1 3
...
# 25 "/work/wd/tmp-ppc/tools/fdt_host.h" 2
# 1 "/usr/local/include/../include/libfdt.h" 1 3
# 54 "/usr/local/include/../include/libfdt.h" 3
...

i. e. it includes the WRONG versions of the header files - not these from the U-Boot code, but from the host system.

The problem is the "-idirafter":

`-idirafter DIR'
Search DIR for header files, but do it _after_ all directories specified with `-I' and the standard system directories have been exhausted. DIR is treated as a system include directory.

Hm... not sure how to fix this.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Probably the best operating system in the world  is  the  [operating
system] made for the PDP-11 by Bell Laboratories."
                                           - Ted Nelson, October 1977
#4 lore raw
Quoted 11 lines · Wolfgang Denk

Dear Jerry Van Baren,

Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 8 lines

...
tools/fdt_ro.c: In function 'fdt_path_offset':
tools/fdt_ro.c:158: warning: implicit declaration of function 'fdt_getprop_namelen' tools/fdt_ro.c:158: warning: assignment makes pointer from integer without a cast tools/fdt_ro.c: At top level:
tools/fdt_ro.c:281: error: conflicting types for 'fdt_getprop_namelen' tools/fdt_ro.c:158: error: previous implicit declaration of 'fdt_getprop_namelen' was here
...

Quoted 5 lines

...

Quoted 3 lines

??? I'm not seeing this, even with a fresh pull from the u-boot repository.

The function is declared in include/libfdt.h, properly in my copy.

(from your previous email):

Quoted 2 lines

It seems it happens only for out-of-tree builds (which is my standard mode of operation).

Yes, after I hit "send" and thought about the "../include", I had a bad feeling that that was the problem.

Quoted 6 lines

The problem comes from tools/fdt_host.h which includes:

	/* Make sure to include u-boot version of libfdt include files */
	#include "../include/fdt.h"
	#include "../include/libfdt.h"
	#include "../include/fdt_support.h"

There has to be a better way than the USE_HOSTCC / #include "fdt_host.h" (with a "up & over" relative path) mechanism. Unfortunately, I don't have any good ideas at the moment.

What we really need is $(obj)include instead of "../include", but that is crossing the make $(obj) and the C preprocessor. We could do it by running sed on fdt_host.h, but that wouldn't be a better way, just ugly.

[snip]

Quoted 1 line

Hm... not sure how to fix this.

Ditto. :-(

Quoted 3 lines

Best regards,

Wolfgang Denk

...thinking...
gvb
(...but don't expect much this weekend, it is Labor Day weekend in the USofA, the traditional last "hurrah" of summer).

#5 lore raw

Dear JerryVanBaren,

Quoted 5 lines · In message <[email protected]> you wrote:

...thinking...
gvb
(...but don't expect much this weekend, it is Labor Day weekend in the USofA, the traditional last "hurrah" of summer).

Any clever ideas yet? [I didn't find a god solution yet.]

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It is your destiny.                                     - Darth Vader
#6 lore raw

PATCH 1/1 Fix out-of-tree tools/fdt build

The fdt header files must come from the u-boot versions when building the tools (we must use the same definitions in the tools as in the u-boot image). To ensure this, generate the "fdt_host.h" file in the Makefile to use the full path to the u-boot fdt header files.

---

This is *NOT* a final answer. I'm still getting a build error that I cannot figure out so I figured I would appeal to the Wisdom of the List.

In this patch, I'm auto-generating the fdt_host.h header to specifically include the u-boot fdt headers (as opposed to the host's headers). There may be better way(s) of doing this and there are the aforementioned errors to fix. Treat this as a challenge for improvements. ;-)

Thanks,
gvb

 Makefile         |    1 +
 include/image.h  |    4 ++++
 tools/Makefile   |   36 ++++++++++++++++++++++++++----------
 tools/fdt_host.h |   28 ----------------------------
 tools/mkimage.h  |    2 +-
 5 files changed, 32 insertions(+), 39 deletions(-)
 delete mode 100644 tools/fdt_host.h
Makefile +1 -0
index 8d82ef5..be08685 100644
@@ -3152,6 +3152,7 @@ clean:
 	@rm -f $(obj)nand_spl/{u-boot-spl,u-boot-spl.map,System.map}
 	@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl-2k.bin,ipl-4k.bin,ipl.map}
 	@rm -f $(obj)api_examples/demo $(VERSION_FILE)
+	@rm -f $(SRCTREE)/tools/fdt_host.h
 	@find $(OBJTREE) -type f \
 		\( -name 'core' -o -name '*.bak' -o -name '*~' \
 		-o -name '*.o'	-o -name '*.a'	\) -print \
include/image.h +4 -0
index 9be806e..f28e9fc 100644
@@ -55,9 +55,13 @@
 #endif
 
 #if defined(CONFIG_FIT)
+#ifndef USE_HOSTCC
 #include <fdt.h>
 #include <libfdt.h>
 #include <fdt_support.h>
+#else
+#include <fdt_host.h>
+#endif
 #define CONFIG_MD5		/* FIT images need MD5 support */
 #endif
 
tools/Makefile +26 -10
index 21ea1c2..5ab5456 100644
@@ -124,9 +124,11 @@ BINS	:= $(addprefix $(obj),$(BIN_FILES))
 CPPFLAGS   = -idirafter $(SRCTREE)/include \
 		-idirafter $(OBJTREE)/include2 \
 		-idirafter $(OBJTREE)/include \
+		-idirafter $(OBJTREE)/tools \
 		-DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
 CFLAGS     = $(HOST_CFLAGS) $(CPPFLAGS) -O
 
+
 # No -pedantic switch to avoid libfdt compilation warnings
 FIT_CFLAGS = -Wall $(CPPFLAGS) -O
 
@@ -190,10 +192,10 @@ $(obj)md5.o:	$(obj)md5.c
 $(obj)sha1.o:	$(obj)sha1.c
 		$(CC) -g $(CFLAGS) -c -o $@ $<
 
-$(obj)image.o:	$(obj)image.c
+$(obj)image.o:	$(obj)image.c $(obj)fdt_host.h
 		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
-$(obj)mkimage.o:	$(src)mkimage.c
+$(obj)mkimage.o:	$(src)mkimage.c $(obj)fdt_host.h
 		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
 $(obj)ncb.o:		$(src)ncb.c
@@ -208,19 +210,19 @@ $(obj)inca-swap-bytes.o:	$(src)inca-swap-bytes.c
 $(obj)mpc86x_clk.o:	$(src)mpc86x_clk.c
 		$(CC) -g $(CFLAGS) -c -o $@ $<
 
-$(obj)fdt.o:	$(obj)fdt.c
+$(obj)fdt.o:	$(obj)fdt.c $(obj)fdt_host.h
 		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
-$(obj)fdt_ro.o:	$(obj)fdt_ro.c
+$(obj)fdt_ro.o:	$(obj)fdt_ro.c $(obj)fdt_host.h
 		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
-$(obj)fdt_rw.o:	$(obj)fdt_rw.c
+$(obj)fdt_rw.o:	$(obj)fdt_rw.c $(obj)fdt_host.h
 		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
-$(obj)fdt_strerror.o:	$(obj)fdt_strerror.c
+$(obj)fdt_strerror.o:	$(obj)fdt_strerror.c $(obj)fdt_host.h
 		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
-$(obj)fdt_wip.o:	$(obj)fdt_wip.c
+$(obj)fdt_wip.o:	$(obj)fdt_wip.c $(obj)fdt_host.h
 		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
 subdirs:
@@ -266,9 +268,6 @@ $(obj)image.c:
 		if [ ! -f $(obj)mkimage.h ] ; then \
 			ln -s $(src)../tools/mkimage.h $(obj)mkimage.h; \
 		fi
-		if [ ! -f $(obj)fdt_host.h ] ; then \
-			ln -s $(src)../tools/fdt_host.h $(obj)fdt_host.h; \
-		fi
 
 $(obj)fdt.c:	$(obj)libfdt_internal.h
 		@rm -f $(obj)fdt.c
@@ -297,6 +296,23 @@ $(obj)libfdt_internal.h:
 $(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
 		$(obj)./bmp_logo $(LOGO_BMP) >$@
 
+#
+# fdt_host.h has to point to the u-boot version of the libfdt headers
+#
+$(obj)fdt_host.h:
+		echo "Auto-generating fdt_host.h"
+		@echo "/* AUTO GENERATED, do not edit manually */" > $@
+		@echo "" >> $@
+		@echo "#ifndef __FDT_HOST_H__" >> $@
+		@echo "#define __FDT_HOST_H__" >> $@
+		@echo "" >> $@
+		@echo "/* Include u-boot, *not* the host, version of libfdt include files */" >> $@
+		@echo "#include \"$(SRCTREE)/include/fdt.h\"" >> $@
+		@echo "#include \"$(SRCTREE)/include/libfdt.h\"" >> $@
+		@echo "#include \"$(SRCTREE)/include/fdt_support.h\"" >> $@
+		@echo "" >> $@
+		@echo "#endif /* __FDT_HOST_H__ */" >> $@
+
 #########################################################################
 
 # defines $(obj).depend target
tools/fdt_host.h deleted +0 -28
deleted file mode 100644
index 085013e..0000000
@@ -1,28 +0,0 @@
-/*
- * (C) Copyright 2008 Semihalf
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef __FDT_HOST_H__
-#define __FDT_HOST_H__
-
-/* Make sure to include u-boot version of libfdt include files */
-#include "../include/fdt.h"
-#include "../include/libfdt.h"
-#include "../include/fdt_support.h"
-
-#endif /* __FDT_HOST_H__ */
tools/mkimage.h +1 -1
index a2d5248..be94a02 100644
@@ -33,7 +33,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <sha1.h>
-#include "fdt_host.h"
+#include <fdt_host.h>
 
 #define MKIMAGE_DEBUG
 
Signature · 1 line
1.5.6.5
#7 lore raw

PATCH 1/1 Fix out-of-tree tools/fdt build

Quoted 32 lines · Jerry Van Baren

The fdt header files must come from the u-boot versions when building the tools (we must use the same definitions in the tools as in the u-boot image). To ensure this, generate the "fdt_host.h" file in the Makefile to use the full path to the u-boot fdt header files.

---

This is *NOT* a final answer. I'm still getting a build error that I cannot figure out so I figured I would appeal to the Wisdom of the List.

In this patch, I'm auto-generating the fdt_host.h header to specifically include the u-boot fdt headers (as opposed to the host's headers). There may be better way(s) of doing this and there are the aforementioned errors to fix. Treat this as a challenge for improvements. ;-)

Thanks,
gvb

 Makefile         |    1 +
 include/image.h  |    4 ++++
 tools/Makefile   |   36 ++++++++++++++++++++++++++----------
 tools/fdt_host.h |   28 ----------------------------
 tools/mkimage.h  |    2 +-
 5 files changed, 32 insertions(+), 39 deletions(-)
 delete mode 100644 tools/fdt_host.h
Makefile +0 -0
index 8d82ef5..be08685 100644

Makefile clean: · line 3155

Quoted 4 lines
Makefile +1 -0
@@ -3152,6 +3152,7 @@ clean:
 	@rm -f $(obj)nand_spl/{u-boot-spl,u-boot-spl.map,System.map}
 	@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl-2k.bin,ipl-4k.bin,ipl.map}
 	@rm -f $(obj)api_examples/demo $(VERSION_FILE)
+	@rm -f $(SRCTREE)/tools/fdt_host.h

Arrgh, this should have been:

	@rm -f $(obj)fdt_host.h

(missed that change as my technique evolved). This doesn't affect the aforementioned errors to be fixed or the challenge for improvements.

gvb