Skip to contentSkip to conversation

common: fix building image.c

RFC PATCH New Igor Opaniuk 3 participants 5 messages Aug 13, 2019 – Aug 20, 2019

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 common: fix building image.c

From: Igor Opaniuk <[email protected]>

Wrap image_decomp() and all dependent functions with !ifdef(USE_HOSTCC) macro, as this function isn't used by any tool from /tools.

Without this it leads to compilation issues (because of CONFIG_LZMA from newly added #include <generated/autoconf.h> statement, which pulls all these definitions):

In file included from tools/common/image.c:1:0:
./tools/../common/image.c: In function ‘image_decomp’:
./tools/../common/image.c:428:9: warning: implicit declaration of function ‘gunzip’; did you mean ‘munmap’? [-Wimplicit-function-declaration]

   ret = gunzip(load_buf, unc_len, image_buf, &image_len);
         ^~~~~~
         munmap

./tools/../common/image.c:450:3: error: unknown type name ‘SizeT’; did you mean ‘size_t’?
SizeT lzma_len = unc_len;
^~~~~
size_t
./tools/../common/image.c:452:9: warning: implicit declaration of function ‘lzmaBuffToBuffDecompress’ [-Wimplicit-function-declaration]
ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,

         ^~~~~~~~~~~~~~~~~~~~~~~~

scripts/Makefile.host:114: recipe for target 'tools/common/image.o' failed

Fixes 2aa7f0fa51 ("habv4: tools: Avoid hardcoded CSF size for SPL target")

---

 common/image-fit.c | 5 ++++-
 common/image.c     | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)
common/image-fit.c +4 -1
index e346fed550..a064f38510 100644
@@ -1728,6 +1728,7 @@ int fit_conf_get_prop_node(const void *fit, int noffset,
 	return fit_conf_get_prop_node_index(fit, noffset, prop_name, 0);
 }
 
+#ifndef USE_HOSTCC
 static int fit_image_select(const void *fit, int rd_noffset, int verify)
 {
 	fit_image_print(fit, rd_noffset, "   ");
@@ -1743,6 +1744,7 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
 
 	return 0;
 }
+#endif /* USE_HOSTCC */
 
 int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
 			ulong addr)
@@ -1771,6 +1773,7 @@ int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
 	return noffset;
 }
 
+#ifndef USE_HOSTCC
 /**
  * fit_get_image_type_property() - get property name for IH_TYPE_...
  *
@@ -2009,6 +2012,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 		} else {
 			loadbuf = map_sysmem(load, max_decomp_len);
 		}
+
 		if (image_decomp(comp, load, data, image_type,
 				loadbuf, buf, len, max_decomp_len, &load_end)) {
 			printf("Error decompressing %s\n", prop_name);
@@ -2060,7 +2064,6 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
 	return ret;
 }
 
-#ifndef USE_HOSTCC
 int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
 		   const char **fit_unamep, const char **fit_uname_configp,
 		   int arch, ulong *datap, ulong *lenp)
common/image.c +1 -2
index 6da0513e8b..315ae89467 100644
@@ -383,6 +383,7 @@ void image_print_contents(const void *ptr)
 	}
 }
 
+#ifndef USE_HOSTCC
 /**
  * print_decomp_msg() - Print a suitable decompression/loading message
  *
@@ -483,8 +484,6 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 	return ret;
 }
 
-
-#ifndef USE_HOSTCC
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 /**
  * image_get_ramdisk - get and verify ramdisk image
Signature · 1 line
2.17.1
#1 lore raw

RFC PATCH 1/1 common: fix building image.c

Hi all,

Quoted 103 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Wrap image_decomp() and all dependent functions with !ifdef(USE_HOSTCC) macro, as this function isn't used by any tool from /tools.

Without this it leads to compilation issues (because of CONFIG_LZMA from newly added #include <generated/autoconf.h> statement, which pulls all these definitions):

In file included from tools/common/image.c:1:0:
./tools/../common/image.c: In function ‘image_decomp’:
./tools/../common/image.c:428:9: warning: implicit declaration of function ‘gunzip’; did you mean ‘munmap’? [-Wimplicit-function-declaration]

   ret = gunzip(load_buf, unc_len, image_buf, &image_len);
         ^~~~~~
         munmap
./tools/../common/image.c:450:3: error: unknown type name ‘SizeT’;
did you mean ‘size_t’?
   SizeT lzma_len = unc_len;
   ^~~~~
   size_t
./tools/../common/image.c:452:9: warning: implicit declaration of function
‘lzmaBuffToBuffDecompress’ [-Wimplicit-function-declaration]
   ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
         ^~~~~~~~~~~~~~~~~~~~~~~~

scripts/Makefile.host:114: recipe for target 'tools/common/image.o' failed

Fixes 2aa7f0fa51 ("habv4: tools: Avoid hardcoded CSF size for SPL target")

---

 common/image-fit.c | 5 ++++-
 common/image.c     | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)
common/image-fit.c +4 -1
index e346fed550..a064f38510 100644
@@ -1728,6 +1728,7 @@ int fit_conf_get_prop_node(const void *fit, int noffset,
        return fit_conf_get_prop_node_index(fit, noffset, prop_name, 0);
 }
 
+#ifndef USE_HOSTCC
 static int fit_image_select(const void *fit, int rd_noffset, int verify)
 {
        fit_image_print(fit, rd_noffset, "   ");
@@ -1743,6 +1744,7 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
 
        return 0;
 }
+#endif /* USE_HOSTCC */
 
 int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
                        ulong addr)
@@ -1771,6 +1773,7 @@ int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
        return noffset;
 }
 
+#ifndef USE_HOSTCC
 /**
  * fit_get_image_type_property() - get property name for IH_TYPE_...
  *
@@ -2009,6 +2012,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
                } else {
                        loadbuf = map_sysmem(load, max_decomp_len);
                }
+
                if (image_decomp(comp, load, data, image_type,
                                loadbuf, buf, len, max_decomp_len, &load_end)) {
                        printf("Error decompressing %s\n", prop_name);
@@ -2060,7 +2064,6 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
        return ret;
 }
 
-#ifndef USE_HOSTCC
 int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
                   const char **fit_unamep, const char **fit_uname_configp,
                   int arch, ulong *datap, ulong *lenp)
common/image.c +1 -3
index 6da0513e8b..315ae89467 100644
@@ -383,6 +383,7 @@ void image_print_contents(const void *ptr)
        }
 }
 
+#ifndef USE_HOSTCC
 /**
  * print_decomp_msg() - Print a suitable decompression/loading message
  *
@@ -483,8 +484,6 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
        return ret;
 }
 
-
-#ifndef USE_HOSTCC
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 /**
  * image_get_ramdisk - get and verify ramdisk image
--
Quoted 2 lines

2.17.1

JFYI: This is actual only for u-boot-imx custodian tree (which is broken), patch that brakes the build hasn't been pulled to u-boot/master yet.

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#2 lore raw

RFC PATCH 1/1 common: fix building image.c

In reply to Igor Opaniuk

Hi all,

Quoted 103 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Wrap image_decomp() and all dependent functions with !ifdef(USE_HOSTCC) macro, as this function isn't used by any tool from /tools.

Without this it leads to compilation issues (because of CONFIG_LZMA from newly added #include <generated/autoconf.h> statement, which pulls all these definitions):

In file included from tools/common/image.c:1:0:
./tools/../common/image.c: In function ‘image_decomp’:
./tools/../common/image.c:428:9: warning: implicit declaration of function ‘gunzip’; did you mean ‘munmap’? [-Wimplicit-function-declaration]

   ret = gunzip(load_buf, unc_len, image_buf, &image_len);
         ^~~~~~
         munmap
./tools/../common/image.c:450:3: error: unknown type name ‘SizeT’;
did you mean ‘size_t’?
   SizeT lzma_len = unc_len;
   ^~~~~
   size_t
./tools/../common/image.c:452:9: warning: implicit declaration of function
‘lzmaBuffToBuffDecompress’ [-Wimplicit-function-declaration]
   ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
         ^~~~~~~~~~~~~~~~~~~~~~~~

scripts/Makefile.host:114: recipe for target 'tools/common/image.o' failed

Fixes 2aa7f0fa51 ("habv4: tools: Avoid hardcoded CSF size for SPL target")

---

 common/image-fit.c | 5 ++++-
 common/image.c     | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)
common/image-fit.c +4 -1
index e346fed550..a064f38510 100644
@@ -1728,6 +1728,7 @@ int fit_conf_get_prop_node(const void *fit, int noffset,
        return fit_conf_get_prop_node_index(fit, noffset, prop_name, 0);
 }
 
+#ifndef USE_HOSTCC
 static int fit_image_select(const void *fit, int rd_noffset, int verify)
 {
        fit_image_print(fit, rd_noffset, "   ");
@@ -1743,6 +1744,7 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
 
        return 0;
 }
+#endif /* USE_HOSTCC */
 
 int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
                        ulong addr)
@@ -1771,6 +1773,7 @@ int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
        return noffset;
 }
 
+#ifndef USE_HOSTCC
 /**
  * fit_get_image_type_property() - get property name for IH_TYPE_...
  *
@@ -2009,6 +2012,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
                } else {
                        loadbuf = map_sysmem(load, max_decomp_len);
                }
+
                if (image_decomp(comp, load, data, image_type,
                                loadbuf, buf, len, max_decomp_len, &load_end)) {
                        printf("Error decompressing %s\n", prop_name);
@@ -2060,7 +2064,6 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
        return ret;
 }
 
-#ifndef USE_HOSTCC
 int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
                   const char **fit_unamep, const char **fit_uname_configp,
                   int arch, ulong *datap, ulong *lenp)
common/image.c +1 -3
index 6da0513e8b..315ae89467 100644
@@ -383,6 +383,7 @@ void image_print_contents(const void *ptr)
        }
 }
 
+#ifndef USE_HOSTCC
 /**
  * print_decomp_msg() - Print a suitable decompression/loading message
  *
@@ -483,8 +484,6 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
        return ret;
 }
 
-
-#ifndef USE_HOSTCC
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 /**
  * image_get_ramdisk - get and verify ramdisk image
--
Quoted 2 lines

2.17.1

JFYI: This is actual only for u-boot-imx custodian tree (which is broken), patch that brakes the build hasn't been pulled to u-boot/master yet.

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Senior Development Engineer,
Igor Opaniuk

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500 48
00 (main line)
#3 lore raw

RFC PATCH 1/1 common: fix building image.c

In reply to Igor Opaniuk

Hi Tom,

Quoted 103 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Wrap image_decomp() and all dependent functions with !ifdef(USE_HOSTCC) macro, as this function isn't used by any tool from /tools.

Without this it leads to compilation issues (because of CONFIG_LZMA from newly added #include <generated/autoconf.h> statement, which pulls all these definitions):

In file included from tools/common/image.c:1:0:
./tools/../common/image.c: In function ‘image_decomp’:
./tools/../common/image.c:428:9: warning: implicit declaration of function ‘gunzip’; did you mean ‘munmap’? [-Wimplicit-function-declaration]

   ret = gunzip(load_buf, unc_len, image_buf, &image_len);
         ^~~~~~
         munmap
./tools/../common/image.c:450:3: error: unknown type name ‘SizeT’;
did you mean ‘size_t’?
   SizeT lzma_len = unc_len;
   ^~~~~
   size_t
./tools/../common/image.c:452:9: warning: implicit declaration of function
‘lzmaBuffToBuffDecompress’ [-Wimplicit-function-declaration]
   ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
         ^~~~~~~~~~~~~~~~~~~~~~~~

scripts/Makefile.host:114: recipe for target 'tools/common/image.o' failed

Fixes 2aa7f0fa51 ("habv4: tools: Avoid hardcoded CSF size for SPL target")

---

 common/image-fit.c | 5 ++++-
 common/image.c     | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)
common/image-fit.c +4 -1
index e346fed550..a064f38510 100644
@@ -1728,6 +1728,7 @@ int fit_conf_get_prop_node(const void *fit, int noffset,
        return fit_conf_get_prop_node_index(fit, noffset, prop_name, 0);
 }
 
+#ifndef USE_HOSTCC
 static int fit_image_select(const void *fit, int rd_noffset, int verify)
 {
        fit_image_print(fit, rd_noffset, "   ");
@@ -1743,6 +1744,7 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
 
        return 0;
 }
+#endif /* USE_HOSTCC */
 
 int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
                        ulong addr)
@@ -1771,6 +1773,7 @@ int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
        return noffset;
 }
 
+#ifndef USE_HOSTCC
 /**
  * fit_get_image_type_property() - get property name for IH_TYPE_...
  *
@@ -2009,6 +2012,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
                } else {
                        loadbuf = map_sysmem(load, max_decomp_len);
                }
+
                if (image_decomp(comp, load, data, image_type,
                                loadbuf, buf, len, max_decomp_len, &load_end)) {
                        printf("Error decompressing %s\n", prop_name);
@@ -2060,7 +2064,6 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
        return ret;
 }
 
-#ifndef USE_HOSTCC
 int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
                   const char **fit_unamep, const char **fit_uname_configp,
                   int arch, ulong *datap, ulong *lenp)
common/image.c +1 -3
index 6da0513e8b..315ae89467 100644
@@ -383,6 +383,7 @@ void image_print_contents(const void *ptr)
        }
 }
 
+#ifndef USE_HOSTCC
 /**
  * print_decomp_msg() - Print a suitable decompression/loading message
  *
@@ -483,8 +484,6 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
        return ret;
 }
 
-
-#ifndef USE_HOSTCC
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 /**
  * image_get_ramdisk - get and verify ramdisk image
--
Quoted 2 lines

2.17.1

I saw you archived this patch in Patchwork,
but unfortunately the issue is still actual for u-boot-imx custodian tree as I'm still facing build issues:

In file included from tools/common/image.c:1:0:
./tools/../common/image.c: In function ‘image_decomp’:
./tools/../common/image.c:429:9: warning: implicit declaration of function ‘gunzip’; did you mean ‘munmap’? [-Wimplicit-function-declaration]

   ret = gunzip(load_buf, unc_len, image_buf, &image_len);
         ^~~~~~
         munmap

tools/common/image.o: In function `image_decomp':
image.c:(.text+0x297): undefined reference to `gunzip'
collect2: error: ld returned 1 exit status scripts/Makefile.host:106: recipe for target 'tools/dumpimage' failed make[1]: *** [tools/dumpimage] Error 1
Makefile:1588: recipe for target 'tools' failed
make: *** [tools] Error 2

Could you please delegate it to Stefano Babic, so he can at least look into it?

Thanks

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Senior Development Engineer,
Igor Opaniuk

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500 48
00 (main line)
#4 lore raw

RFC PATCH 1/1 common: fix building image.c

Quoted 131 lines · Igor Opaniuk

Hi Tom,

Quoted 103 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Wrap image_decomp() and all dependent functions with !ifdef(USE_HOSTCC) macro, as this function isn't used by any tool from /tools.

Without this it leads to compilation issues (because of CONFIG_LZMA from newly added #include <generated/autoconf.h> statement, which pulls all these definitions):

In file included from tools/common/image.c:1:0:
./tools/../common/image.c: In function ‘image_decomp’:
./tools/../common/image.c:428:9: warning: implicit declaration of function ‘gunzip’; did you mean ‘munmap’? [-Wimplicit-function-declaration]

   ret = gunzip(load_buf, unc_len, image_buf, &image_len);
         ^~~~~~
         munmap
./tools/../common/image.c:450:3: error: unknown type name ‘SizeT’;
did you mean ‘size_t’?
   SizeT lzma_len = unc_len;
   ^~~~~
   size_t
./tools/../common/image.c:452:9: warning: implicit declaration of function
‘lzmaBuffToBuffDecompress’ [-Wimplicit-function-declaration]
   ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
         ^~~~~~~~~~~~~~~~~~~~~~~~

scripts/Makefile.host:114: recipe for target 'tools/common/image.o' failed

Fixes 2aa7f0fa51 ("habv4: tools: Avoid hardcoded CSF size for SPL target")

---

 common/image-fit.c | 5 ++++-
 common/image.c     | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)
common/image-fit.c +4 -1
index e346fed550..a064f38510 100644
@@ -1728,6 +1728,7 @@ int fit_conf_get_prop_node(const void *fit, int noffset,
        return fit_conf_get_prop_node_index(fit, noffset, prop_name, 0);
 }
 
+#ifndef USE_HOSTCC
 static int fit_image_select(const void *fit, int rd_noffset, int verify)
 {
        fit_image_print(fit, rd_noffset, "   ");
@@ -1743,6 +1744,7 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
 
        return 0;
 }
+#endif /* USE_HOSTCC */
 
 int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
                        ulong addr)
@@ -1771,6 +1773,7 @@ int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
        return noffset;
 }
 
+#ifndef USE_HOSTCC
 /**
  * fit_get_image_type_property() - get property name for IH_TYPE_...
  *
@@ -2009,6 +2012,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
                } else {
                        loadbuf = map_sysmem(load, max_decomp_len);
                }
+
                if (image_decomp(comp, load, data, image_type,
                                loadbuf, buf, len, max_decomp_len, &load_end)) {
                        printf("Error decompressing %s\n", prop_name);
@@ -2060,7 +2064,6 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
        return ret;
 }
 
-#ifndef USE_HOSTCC
 int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
                   const char **fit_unamep, const char **fit_uname_configp,
                   int arch, ulong *datap, ulong *lenp)
common/image.c +1 -3
index 6da0513e8b..315ae89467 100644
@@ -383,6 +383,7 @@ void image_print_contents(const void *ptr)
        }
 }
 
+#ifndef USE_HOSTCC
 /**
  * print_decomp_msg() - Print a suitable decompression/loading message
  *
@@ -483,8 +484,6 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
        return ret;
 }
 
-
-#ifndef USE_HOSTCC
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 /**
  * image_get_ramdisk - get and verify ramdisk image
--
Quoted 2 lines

2.17.1

I saw you archived this patch in Patchwork,
but unfortunately the issue is still actual for u-boot-imx custodian tree as I'm still facing build issues:

In file included from tools/common/image.c:1:0:
./tools/../common/image.c: In function ‘image_decomp’:
./tools/../common/image.c:429:9: warning: implicit declaration of function ‘gunzip’; did you mean ‘munmap’? [-Wimplicit-function-declaration]

   ret = gunzip(load_buf, unc_len, image_buf, &image_len);
         ^~~~~~
         munmap

tools/common/image.o: In function `image_decomp':
image.c:(.text+0x297): undefined reference to `gunzip'
collect2: error: ld returned 1 exit status scripts/Makefile.host:106: recipe for target 'tools/dumpimage' failed make[1]: *** [tools/dumpimage] Error 1
Makefile:1588: recipe for target 'tools' failed
make: *** [tools] Error 2

Quoted 2 lines

Could you please delegate it to Stefano Babic, so he can at least look into it?

I marked it as RFC since you sent it as RFC. Please re-send without the RFC tag, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190820/2ff33a77/attachment.sig>