Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] quashfs-tools: make it be able to be compiled by gcc5 with "-O0"
@ 2015-09-14  7:33 rongqing.li
  2015-09-14  7:41 ` Khem Raj
  2015-09-14  9:07 ` Mike Looijmans
  0 siblings, 2 replies; 4+ messages in thread
From: rongqing.li @ 2015-09-14  7:33 UTC (permalink / raw)
  To: openembedded-core

From: Roy Li <rongqing.li@windriver.com>

Signed-off-by: Roy Li <rongqing.li@windriver.com>
---
 ...shfs.c-get-inline-functions-work-with-C99.patch | 154 +++++++++++++++++++++
 .../squashfs-tools/squashfs-tools_git.bb           |   1 +
 2 files changed, 155 insertions(+)
 create mode 100644 meta/recipes-devtools/squashfs-tools/squashfs-tools/0001-mksquashfs.c-get-inline-functions-work-with-C99.patch

diff --git a/meta/recipes-devtools/squashfs-tools/squashfs-tools/0001-mksquashfs.c-get-inline-functions-work-with-C99.patch b/meta/recipes-devtools/squashfs-tools/squashfs-tools/0001-mksquashfs.c-get-inline-functions-work-with-C99.patch
new file mode 100644
index 0000000..fefe9f6
--- /dev/null
+++ b/meta/recipes-devtools/squashfs-tools/squashfs-tools/0001-mksquashfs.c-get-inline-functions-work-with-C99.patch
@@ -0,0 +1,154 @@
+From ac6268e843c43286eebff2a1052182c2393cdb2e Mon Sep 17 00:00:00 2001
+From: Roy Li <rongqing.li@windriver.com>
+Date: Mon, 14 Sep 2015 12:31:42 +0800
+Subject: [PATCH] mksquashfs.c:  get inline functions work with both gnu11 and gnu89
+
+Upstream-status: pending
+
+After gcc upgraded to gcc5, and if the codes is compiled without optimization(-O0),
+and the below error will happen:
+
+| mksquashfs.o: In function `create_inode':
+| git/squashfs-tools/mksquashfs.c:897: undefined reference to `get_inode_no'
+| git/squashfs-tools/mksquashfs.c:960: undefined reference to `get_parent_no'
+| git/squashfs-tools/mksquashfs.c:983: undefined reference to `get_parent_no'
+| mksquashfs.o: In function `reader_read_process':
+| git/squashfs-tools/mksquashfs.c:2132: undefined reference to `is_fragment'
+| mksquashfs.o: In function `reader_read_file':
+| git/squashfs-tools/mksquashfs.c:2228: undefined reference to `is_fragment'
+| mksquashfs.o: In function `dir_scan':
+| git/squashfs-tools/mksquashfs.c:3101: undefined reference to `create_dir_entry'
+
+gcc5 defaults to -std=gnu11 instead of -std=gnu89, and it requires that exactly one C
+source file has the callable copy of the inline function. Consider the following
+program:
+
+  inline int
+  foo (void)
+  {
+    return 42;
+  }
+
+  int
+  main (void)
+  {
+    return foo ();
+  }
+
+The program above will not link with the C99 inline semantics, because no out-of-line
+function foo is generated. To fix this, either mark the function foo as static, or
+add the following declaration:
+  static inline int foo (void);
+
+more information refer to: https://gcc.gnu.org/gcc-5/porting_to.html;
+
+but the use of "extern inline" will lead to the compilation issue if gcc is not
+gcc5, as the commit in oe-core d0af30c92fde [alsa-lib: Change function type to
+"static __inline__"]
+    "static __inline__ function()" is the inlined version that
+    can be used in this compilation unit, but there will be another
+    definition of this function somewhere, so compiler will not emit
+    any code for the function body. This causes problem in -O0,
+    where functions are never inlined, the function call is preserved,
+    but linker can't find the symbol, thus the error happens.
+
+so replace "inline" with "static inline" to make it work with both gnu11 and gnu89
+
+Signed-off-by: Roy Li <rongqing.li@windriver.com>
+---
+ squashfs-tools/mksquashfs.c | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
+index d221c35..6bba1d2 100644
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -828,13 +828,13 @@ char *subpathname(struct dir_ent *dir_ent)
+ }
+ 
+ 
+-inline unsigned int get_inode_no(struct inode_info *inode)
++static inline unsigned int get_inode_no(struct inode_info *inode)
+ {
+ 	return inode->inode_number;
+ }
+ 
+ 
+-inline unsigned int get_parent_no(struct dir_info *dir)
++static inline unsigned int get_parent_no(struct dir_info *dir)
+ {
+ 	return dir->depth ? get_inode_no(dir->dir_ent->inode) : inode_no;
+ }
+@@ -2027,7 +2027,7 @@ struct file_info *duplicate(long long file_size, long long bytes,
+ }
+ 
+ 
+-inline int is_fragment(struct inode_info *inode)
++static inline int is_fragment(struct inode_info *inode)
+ {
+ 	off_t file_size = inode->buf.st_size;
+ 
+@@ -2996,13 +2996,13 @@ struct inode_info *lookup_inode2(struct stat *buf, int pseudo, int id)
+ }
+ 
+ 
+-inline struct inode_info *lookup_inode(struct stat *buf)
++static inline struct inode_info *lookup_inode(struct stat *buf)
+ {
+ 	return lookup_inode2(buf, 0, 0);
+ }
+ 
+ 
+-inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
++static inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
+ {
+ 	if (inode->inode_number == 0) {
+ 		inode->inode_number = use_this ? : inode_no ++;
+@@ -3013,7 +3013,7 @@ inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
+ }
+ 
+ 
+-inline struct dir_ent *create_dir_entry(char *name, char *source_name,
++static inline struct dir_ent *create_dir_entry(char *name, char *source_name,
+ 	char *nonstandard_pathname, struct dir_info *dir)
+ {
+ 	struct dir_ent *dir_ent = malloc(sizeof(struct dir_ent));
+@@ -3031,7 +3031,7 @@ inline struct dir_ent *create_dir_entry(char *name, char *source_name,
+ }
+ 
+ 
+-inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
++static inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
+ 	struct inode_info *inode_info)
+ {
+ 	struct dir_info *dir = dir_ent->our_dir;
+@@ -3047,7 +3047,7 @@ inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
+ }
+ 
+ 
+-inline void add_dir_entry2(char *name, char *source_name,
++static inline void add_dir_entry2(char *name, char *source_name,
+ 	char *nonstandard_pathname, struct dir_info *sub_dir,
+ 	struct inode_info *inode_info, struct dir_info *dir)
+ {
+@@ -3059,7 +3059,7 @@ inline void add_dir_entry2(char *name, char *source_name,
+ }
+ 
+ 
+-inline void free_dir_entry(struct dir_ent *dir_ent)
++static inline void free_dir_entry(struct dir_ent *dir_ent)
+ {
+ 	if(dir_ent->name)
+ 		free(dir_ent->name);
+@@ -3080,7 +3080,7 @@ inline void free_dir_entry(struct dir_ent *dir_ent)
+ }
+ 
+ 
+-inline void add_excluded(struct dir_info *dir)
++static inline void add_excluded(struct dir_info *dir)
+ {
+ 	dir->excluded ++;
+ }
+-- 
+1.9.1
+
diff --git a/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb b/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
index 497b282..7aebd00 100644
--- a/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
+++ b/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
@@ -12,6 +12,7 @@ PV = "4.3+gitr${SRCPV}"
 SRCREV = "9c1db6d13a51a2e009f0027ef336ce03624eac0d"
 SRC_URI = "git://github.com/plougher/squashfs-tools.git;protocol=https \
            http://downloads.sourceforge.net/sevenzip/lzma465.tar.bz2;name=lzma \
+           file://0001-mksquashfs.c-get-inline-functions-work-with-C99.patch;striplevel=2 \
 "
 SRC_URI[lzma.md5sum] = "29d5ffd03a5a3e51aef6a74e9eafb759"
 SRC_URI[lzma.sha256sum] = "c935fd04dd8e0e8c688a3078f3675d699679a90be81c12686837e0880aa0fa1e"
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] quashfs-tools: make it be able to be compiled by gcc5 with "-O0"
  2015-09-14  7:33 [PATCH] quashfs-tools: make it be able to be compiled by gcc5 with "-O0" rongqing.li
@ 2015-09-14  7:41 ` Khem Raj
  2015-09-14  9:07 ` Mike Looijmans
  1 sibling, 0 replies; 4+ messages in thread
From: Khem Raj @ 2015-09-14  7:41 UTC (permalink / raw)
  To: rongqing.li; +Cc: openembedded-core


> On Sep 14, 2015, at 12:33 AM, <rongqing.li@windriver.com> <rongqing.li@windriver.com> wrote:
> 
> From: Roy Li <rongqing.li@windriver.com>
> 
> Signed-off-by: Roy Li <rongqing.li@windriver.com>
> ---
> ...shfs.c-get-inline-functions-work-with-C99.patch | 154 +++++++++++++++++++++
> .../squashfs-tools/squashfs-tools_git.bb           |   1 +
> 2 files changed, 155 insertions(+)
> create mode 100644 meta/recipes-devtools/squashfs-tools/squashfs-tools/0001-mksquashfs.c-get-inline-functions-work-with-C99.patch
> 
> diff --git a/meta/recipes-devtools/squashfs-tools/squashfs-tools/0001-mksquashfs.c-get-inline-functions-work-with-C99.patch b/meta/recipes-devtools/squashfs-tools/squashfs-tools/0001-mksquashfs.c-get-inline-functions-work-with-C99.patch
> new file mode 100644
> index 0000000..fefe9f6
> --- /dev/null
> +++ b/meta/recipes-devtools/squashfs-tools/squashfs-tools/0001-mksquashfs.c-get-inline-functions-work-with-C99.patch
> @@ -0,0 +1,154 @@
> +From ac6268e843c43286eebff2a1052182c2393cdb2e Mon Sep 17 00:00:00 2001
> +From: Roy Li <rongqing.li@windriver.com>
> +Date: Mon, 14 Sep 2015 12:31:42 +0800
> +Subject: [PATCH] mksquashfs.c:  get inline functions work with both gnu11 and gnu89
> +

this looks ok.

> +Upstream-status: pending
> +
> +After gcc upgraded to gcc5, and if the codes is compiled without optimization(-O0),
> +and the below error will happen:
> +
> +| mksquashfs.o: In function `create_inode':
> +| git/squashfs-tools/mksquashfs.c:897: undefined reference to `get_inode_no'
> +| git/squashfs-tools/mksquashfs.c:960: undefined reference to `get_parent_no'
> +| git/squashfs-tools/mksquashfs.c:983: undefined reference to `get_parent_no'
> +| mksquashfs.o: In function `reader_read_process':
> +| git/squashfs-tools/mksquashfs.c:2132: undefined reference to `is_fragment'
> +| mksquashfs.o: In function `reader_read_file':
> +| git/squashfs-tools/mksquashfs.c:2228: undefined reference to `is_fragment'
> +| mksquashfs.o: In function `dir_scan':
> +| git/squashfs-tools/mksquashfs.c:3101: undefined reference to `create_dir_entry'
> +
> +gcc5 defaults to -std=gnu11 instead of -std=gnu89, and it requires that exactly one C
> +source file has the callable copy of the inline function. Consider the following
> +program:
> +
> +  inline int
> +  foo (void)
> +  {
> +    return 42;
> +  }
> +
> +  int
> +  main (void)
> +  {
> +    return foo ();
> +  }
> +
> +The program above will not link with the C99 inline semantics, because no out-of-line
> +function foo is generated. To fix this, either mark the function foo as static, or
> +add the following declaration:
> +  static inline int foo (void);
> +
> +more information refer to: https://gcc.gnu.org/gcc-5/porting_to.html;
> +
> +but the use of "extern inline" will lead to the compilation issue if gcc is not
> +gcc5, as the commit in oe-core d0af30c92fde [alsa-lib: Change function type to
> +"static __inline__"]
> +    "static __inline__ function()" is the inlined version that
> +    can be used in this compilation unit, but there will be another
> +    definition of this function somewhere, so compiler will not emit
> +    any code for the function body. This causes problem in -O0,
> +    where functions are never inlined, the function call is preserved,
> +    but linker can't find the symbol, thus the error happens.
> +
> +so replace "inline" with "static inline" to make it work with both gnu11 and gnu89
> +
> +Signed-off-by: Roy Li <rongqing.li@windriver.com>
> +---
> + squashfs-tools/mksquashfs.c | 20 ++++++++++----------
> + 1 file changed, 10 insertions(+), 10 deletions(-)
> +
> +diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
> +index d221c35..6bba1d2 100644
> +--- a/squashfs-tools/mksquashfs.c
> ++++ b/squashfs-tools/mksquashfs.c
> +@@ -828,13 +828,13 @@ char *subpathname(struct dir_ent *dir_ent)
> + }
> + 
> + 
> +-inline unsigned int get_inode_no(struct inode_info *inode)
> ++static inline unsigned int get_inode_no(struct inode_info *inode)
> + {
> + 	return inode->inode_number;
> + }
> + 
> + 
> +-inline unsigned int get_parent_no(struct dir_info *dir)
> ++static inline unsigned int get_parent_no(struct dir_info *dir)
> + {
> + 	return dir->depth ? get_inode_no(dir->dir_ent->inode) : inode_no;
> + }
> +@@ -2027,7 +2027,7 @@ struct file_info *duplicate(long long file_size, long long bytes,
> + }
> + 
> + 
> +-inline int is_fragment(struct inode_info *inode)
> ++static inline int is_fragment(struct inode_info *inode)
> + {
> + 	off_t file_size = inode->buf.st_size;
> + 
> +@@ -2996,13 +2996,13 @@ struct inode_info *lookup_inode2(struct stat *buf, int pseudo, int id)
> + }
> + 
> + 
> +-inline struct inode_info *lookup_inode(struct stat *buf)
> ++static inline struct inode_info *lookup_inode(struct stat *buf)
> + {
> + 	return lookup_inode2(buf, 0, 0);
> + }
> + 
> + 
> +-inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
> ++static inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
> + {
> + 	if (inode->inode_number == 0) {
> + 		inode->inode_number = use_this ? : inode_no ++;
> +@@ -3013,7 +3013,7 @@ inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
> + }
> + 
> + 
> +-inline struct dir_ent *create_dir_entry(char *name, char *source_name,
> ++static inline struct dir_ent *create_dir_entry(char *name, char *source_name,
> + 	char *nonstandard_pathname, struct dir_info *dir)
> + {
> + 	struct dir_ent *dir_ent = malloc(sizeof(struct dir_ent));
> +@@ -3031,7 +3031,7 @@ inline struct dir_ent *create_dir_entry(char *name, char *source_name,
> + }
> + 
> + 
> +-inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
> ++static inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
> + 	struct inode_info *inode_info)
> + {
> + 	struct dir_info *dir = dir_ent->our_dir;
> +@@ -3047,7 +3047,7 @@ inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
> + }
> + 
> + 
> +-inline void add_dir_entry2(char *name, char *source_name,
> ++static inline void add_dir_entry2(char *name, char *source_name,
> + 	char *nonstandard_pathname, struct dir_info *sub_dir,
> + 	struct inode_info *inode_info, struct dir_info *dir)
> + {
> +@@ -3059,7 +3059,7 @@ inline void add_dir_entry2(char *name, char *source_name,
> + }
> + 
> + 
> +-inline void free_dir_entry(struct dir_ent *dir_ent)
> ++static inline void free_dir_entry(struct dir_ent *dir_ent)
> + {
> + 	if(dir_ent->name)
> + 		free(dir_ent->name);
> +@@ -3080,7 +3080,7 @@ inline void free_dir_entry(struct dir_ent *dir_ent)
> + }
> + 
> + 
> +-inline void add_excluded(struct dir_info *dir)
> ++static inline void add_excluded(struct dir_info *dir)
> + {
> + 	dir->excluded ++;
> + }
> +-- 
> +1.9.1
> +
> diff --git a/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb b/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
> index 497b282..7aebd00 100644
> --- a/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
> +++ b/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
> @@ -12,6 +12,7 @@ PV = "4.3+gitr${SRCPV}"
> SRCREV = "9c1db6d13a51a2e009f0027ef336ce03624eac0d"
> SRC_URI = "git://github.com/plougher/squashfs-tools.git;protocol=https \
>            http://downloads.sourceforge.net/sevenzip/lzma465.tar.bz2;name=lzma \
> +           file://0001-mksquashfs.c-get-inline-functions-work-with-C99.patch;striplevel=2 \
> "
> SRC_URI[lzma.md5sum] = "29d5ffd03a5a3e51aef6a74e9eafb759"
> SRC_URI[lzma.sha256sum] = "c935fd04dd8e0e8c688a3078f3675d699679a90be81c12686837e0880aa0fa1e"
> -- 
> 1.9.1
> 
> -- 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] quashfs-tools: make it be able to be compiled by gcc5 with "-O0"
  2015-09-14  7:33 [PATCH] quashfs-tools: make it be able to be compiled by gcc5 with "-O0" rongqing.li
  2015-09-14  7:41 ` Khem Raj
@ 2015-09-14  9:07 ` Mike Looijmans
  2015-09-14  9:32   ` Rongqing Li
  1 sibling, 1 reply; 4+ messages in thread
From: Mike Looijmans @ 2015-09-14  9:07 UTC (permalink / raw)
  To: rongqing.li, openembedded-core

Typo: "(s)quashfs"



Kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Products
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
Telefax: +31 (0) 499 33 69 70
E-mail: mike.looijmans@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] quashfs-tools: make it be able to be compiled by gcc5 with "-O0"
  2015-09-14  9:07 ` Mike Looijmans
@ 2015-09-14  9:32   ` Rongqing Li
  0 siblings, 0 replies; 4+ messages in thread
From: Rongqing Li @ 2015-09-14  9:32 UTC (permalink / raw)
  To: Mike Looijmans, openembedded-core



On 2015年09月14日 17:07, Mike Looijmans wrote:
> Typo: "(s)quashfs"
>
>

thanks

-Roy

>
> Kind regards,
>
> Mike Looijmans
> System Expert
>
> TOPIC Embedded Products
> Eindhovenseweg 32-C, NL-5683 KH Best
> Postbus 440, NL-5680 AK Best
> Telefoon: +31 (0) 499 33 69 79
> Telefax: +31 (0) 499 33 69 70
> E-mail: mike.looijmans@topicproducts.com
> Website: www.topicproducts.com
>
> Please consider the environment before printing this e-mail
>
>
>
>
>
>
>

-- 
Best Reagrds,
Roy | RongQing Li


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-14 11:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-14  7:33 [PATCH] quashfs-tools: make it be able to be compiled by gcc5 with "-O0" rongqing.li
2015-09-14  7:41 ` Khem Raj
2015-09-14  9:07 ` Mike Looijmans
2015-09-14  9:32   ` Rongqing Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox