[U-Boot] libfdt/fdt_ro.c build issues...

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

Wolfgang Denk wrote:
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
??? 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

Dear Jerry Van Baren,
In message 48B4B62E.5000301@gmail.com you wrote:
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 ...
...
??? 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

Dear Jerry Van Baren,
In message 48B4B62E.5000301@gmail.com you wrote:
... 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 ...
...
??? 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

Wolfgang Denk wrote:
Dear Jerry Van Baren,
In message 48B4B62E.5000301@gmail.com you wrote:
... 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 ...
...
??? 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):
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.
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]
Hm... not sure how to fix this.
Ditto. :-(
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).

Dear JerryVanBaren,
In message 48B53DB8.5040904@ge.com 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

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.
Signed-off-by: Gerald Van Baren vanbaren@cideas.com ---
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
diff --git a/Makefile b/Makefile index 8d82ef5..be08685 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/include/image.h b/include/image.h index 9be806e..f28e9fc 100644 --- a/include/image.h +++ b/include/image.h @@ -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
diff --git a/tools/Makefile b/tools/Makefile index 21ea1c2..5ab5456 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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 diff --git a/tools/fdt_host.h b/tools/fdt_host.h deleted file mode 100644 index 085013e..0000000 --- a/tools/fdt_host.h +++ /dev/null @@ -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__ */ diff --git a/tools/mkimage.h b/tools/mkimage.h index a2d5248..be94a02 100644 --- a/tools/mkimage.h +++ b/tools/mkimage.h @@ -33,7 +33,7 @@ #include <time.h> #include <unistd.h> #include <sha1.h> -#include "fdt_host.h" +#include <fdt_host.h>
#define MKIMAGE_DEBUG

Jerry Van Baren wrote:
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.
Signed-off-by: Gerald Van Baren vanbaren@cideas.com
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
diff --git a/Makefile b/Makefile index 8d82ef5..be08685 100644 --- a/Makefile +++ b/Makefile @@ -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
participants (3)
-
Jerry Van Baren
-
JerryVanBaren
-
Wolfgang Denk