Skip to contentSkip to conversation

util-linux: fix ncurses/wchar handling (again)

PATCH Superseded Carlos Santos 3 participants 12 messages Jan 13, 2017 – Jan 22, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 util-linux: fix ncurses/wchar handling (again)

util-linux #defines "wchar_t" as "char" when configured without widechar support. This conflicts with definition of wchar_t contained in stddef.h, so the compilation fails with

error: two or more data types in declaration specifiers #define
wchar_t char

The error can be reproduced rearrangin the incluson order in some files under the text-utils directory.

Fixes:

http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941

---
 ...3-Fix-compilation-with-ncurses-and-uClibc.patch | 70 ++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 package/util-linux/0003-Fix-compilation-with-ncurses-and-uClibc.patch
package/util-linux/0003-Fix-compilation-with-ncurses-and-uClibc.patch new file +70 -0
new file mode 100644
index 0000000..95f9e34
@@ -0,0 +1,70 @@
+From bcad0c3629101aeafec266ecb0221cac0f52fcec Mon Sep 17 00:00:00 2001
+From: Carlos Santos <[email protected]>
+Date: Fri, 13 Jan 2017 01:13:19 -0200
+Subject: [PATCH] Fix compilation with ncurses and uClibc
+
+Replacing "wchar_t" by "char" in widechar.h causes a conflict with the
+definition of wchar_t contained in stddef.h, which is included by c.h,
+so the compilation fails with
+
+   error: two or more data types in declaration specifiers #define
+   wchar_t char
+
+The error can be reproduced by configuring with --disable-widechar
+--without-ncursesw --with-ncurses. It can be avoided by moving the
+inclusion of widechar.h below the inclusion of c.h in colcrt.c,
+colrm.c and column.c.
+
+Signed-off-by: Carlos Santos <[email protected]>
+---
+ text-utils/colcrt.c | 2 +-
+ text-utils/colrm.c  | 2 +-
+ text-utils/column.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c
+index 62f8425..f376350 100644
+--- a/text-utils/colcrt.c
++++ b/text-utils/colcrt.c
+@@ -46,8 +46,8 @@
+ #include <getopt.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "closestream.h"
+ 
+ /*
+diff --git a/text-utils/colrm.c b/text-utils/colrm.c
+index 431eae0..e799cd1 100644
+--- a/text-utils/colrm.c
++++ b/text-utils/colrm.c
+@@ -44,9 +44,9 @@
+ #include <unistd.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "strutils.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "closestream.h"
+ 
+ /*
+diff --git a/text-utils/column.c b/text-utils/column.c
+index b8d31c9..e0144a2 100644
+--- a/text-utils/column.c
++++ b/text-utils/column.c
+@@ -50,8 +50,8 @@
+ #include <getopt.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "xalloc.h"
+ #include "strutils.h"
+ #include "closestream.h"
+-- 
+2.7.4
+
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 util-linux: fix ncurses/wchar handling (again)

util-linux #defines "wchar_t" as "char" when configured without widechar support. This conflicts with definition of wchar_t contained in stddef.h, so the compilation fails with

error: two or more data types in declaration specifiers #define
wchar_t char

The error can be avoided by rearranging the inclusion order in some files under the text-utils directory.

Fixes:

http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941

---
Changes v1 -> v2
- Fixed commit message (mental note: do not run "git commit" at 2:30 AM)

---
 ...3-Fix-compilation-with-ncurses-and-uClibc.patch | 70 ++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 package/util-linux/0003-Fix-compilation-with-ncurses-and-uClibc.patch
package/util-linux/0003-Fix-compilation-with-ncurses-and-uClibc.patch new file +70 -0
new file mode 100644
index 0000000..95f9e34
@@ -0,0 +1,70 @@
+From bcad0c3629101aeafec266ecb0221cac0f52fcec Mon Sep 17 00:00:00 2001
+From: Carlos Santos <[email protected]>
+Date: Fri, 13 Jan 2017 01:13:19 -0200
+Subject: [PATCH] Fix compilation with ncurses and uClibc
+
+Replacing "wchar_t" by "char" in widechar.h causes a conflict with the
+definition of wchar_t contained in stddef.h, which is included by c.h,
+so the compilation fails with
+
+   error: two or more data types in declaration specifiers #define
+   wchar_t char
+
+The error can be reproduced by configuring with --disable-widechar
+--without-ncursesw --with-ncurses. It can be avoided by moving the
+inclusion of widechar.h below the inclusion of c.h in colcrt.c,
+colrm.c and column.c.
+
+Signed-off-by: Carlos Santos <[email protected]>
+---
+ text-utils/colcrt.c | 2 +-
+ text-utils/colrm.c  | 2 +-
+ text-utils/column.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c
+index 62f8425..f376350 100644
+--- a/text-utils/colcrt.c
++++ b/text-utils/colcrt.c
+@@ -46,8 +46,8 @@
+ #include <getopt.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "closestream.h"
+ 
+ /*
+diff --git a/text-utils/colrm.c b/text-utils/colrm.c
+index 431eae0..e799cd1 100644
+--- a/text-utils/colrm.c
++++ b/text-utils/colrm.c
+@@ -44,9 +44,9 @@
+ #include <unistd.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "strutils.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "closestream.h"
+ 
+ /*
+diff --git a/text-utils/column.c b/text-utils/column.c
+index b8d31c9..e0144a2 100644
+--- a/text-utils/column.c
++++ b/text-utils/column.c
+@@ -50,8 +50,8 @@
+ #include <getopt.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "xalloc.h"
+ #include "strutils.h"
+ #include "closestream.h"
+-- 
+2.7.4
+
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/1 util-linux: fix ncurses/wchar handling (again)

Hello,

Quoted 11 lines · Carlos Santos

util-linux #defines "wchar_t" as "char" when configured without widechar support. This conflicts with definition of wchar_t contained in stddef.h, so the compilation fails with

error: two or more data types in declaration specifiers #define
wchar_t char

The error can be avoided by rearranging the inclusion order in some files under the text-utils directory.

Quoted 7 lines

Fixes:

http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941

I tried to fix the same problem in commit 5a18eabdf08564688761a9b2f35892d69d8f9a18, but apparently failed at taking into account all the possible situations.

So if we are going to merge a different solution, I'd like to see an investigation of whether commit 5a18eabdf08564688761a9b2f35892d69d8f9a18 is still needed or not. If it's not, then it should be reverted as well.

I must say I find the fix of playing with the ordering of includes to be somewhat hackish. Do we have a better solution? Is it really legal for util-linux to redefine wchar_t? Should it use a better autoconf check before doing this?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH v2 1/1 util-linux: fix ncurses/wchar handling (again)

Quoted 28 lines

From: "Thomas Petazzoni" <[email protected]>
To: "Carlos Santos" <[email protected]>
Cc: buildroot at buildroot.org
Sent: Tuesday, January 17, 2017 3:44:37 AM
Subject: Re: [Buildroot] [PATCH v2] util-linux: fix ncurses/wchar handling (again)

Hello,

Quoted 11 lines · Carlos Santos

util-linux #defines "wchar_t" as "char" when configured without widechar support. This conflicts with definition of wchar_t contained in stddef.h, so the compilation fails with

error: two or more data types in declaration specifiers #define
wchar_t char

The error can be avoided by rearranging the inclusion order in some files under the text-utils directory.

Quoted 7 lines

Fixes:

http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941

Quoted 8 lines

I tried to fix the same problem in commit 5a18eabdf08564688761a9b2f35892d69d8f9a18, but apparently failed at taking into account all the possible situations.

So if we are going to merge a different solution, I'd like to see an investigation of whether commit 5a18eabdf08564688761a9b2f35892d69d8f9a18 is still needed or not. If it's not, then it should be reverted as well.

Ok, I will take a look tonight.

Quoted 6 lines

I must say I find the fix of playing with the ordering of includes to be somewhat hackish. Do we have a better solution? Is it really legal for util-linux to redefine wchar_t? Should it use a better autoconf check before doing this?

Thomas

I'd rather disable ncurses support at all instead of resorting to ugly hacks. Looks like ncurses is important for other people, however, so I attempted to preserve it.

As far as I understand the redefinition aims to compile util-linux for systems whose C libraries do not support wide characters at all (and therefore do not define wchar_t). Perhaps this was easy to do a long time ago but now that C compilers provide wchar_t as a built-in type it became complicated.

Carlos Santos (Casantos) - DATACOM, P&D
?Something must be done. This is something. Therefore we must do it.? (from the BBC series ?Yes, Prime Minister?, ?Power to the people?)

#4 lore raw

PATCH v2 1/1 util-linux: fix ncurses/wchar handling (again)

In reply to Thomas Petazzoni
Quoted 31 lines · Thomas Petazzoni

Hello,

Quoted 11 lines · Carlos Santos

util-linux #defines "wchar_t" as "char" when configured without widechar support. This conflicts with definition of wchar_t contained in stddef.h, so the compilation fails with

error: two or more data types in declaration specifiers #define
wchar_t char

The error can be avoided by rearranging the inclusion order in some files under the text-utils directory.

Quoted 7 lines

Fixes:

http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941

I tried to fix the same problem in commit 5a18eabdf08564688761a9b2f35892d69d8f9a18, but apparently failed at taking into account all the possible situations.

So if we are going to merge a different solution, I'd like to see an investigation of whether commit 5a18eabdf08564688761a9b2f35892d69d8f9a18 is still needed or not. If it's not, then it should be reverted as well.

Quoted 4 lines

I must say I find the fix of playing with the ordering of includes to be somewhat hackish. Do we have a better solution? Is it really legal for util-linux to redefine wchar_t? Should it use a better autoconf check before doing this?

Maybe we should ask the util-linux list? There's often an active discussion, on what is the correct way to handle such things.

Marcus

Quoted 3 lines

Thomas

#5 lore raw

PATCH v2 1/1 util-linux: fix ncurses/wchar handling (again)

Quoted 5 lines

From: "Marcus Hoffmann" <[email protected]>
To: buildroot at busybox.net
Sent: Tuesday, January 17, 2017 11:57:12 AM
Subject: Re: [Buildroot] [PATCH v2] util-linux: fix ncurses/wchar handling (again)

Quoted 31 lines
Quoted 30 lines · Thomas Petazzoni

Hello,

Quoted 11 lines · Carlos Santos

util-linux #defines "wchar_t" as "char" when configured without widechar support. This conflicts with definition of wchar_t contained in stddef.h, so the compilation fails with

error: two or more data types in declaration specifiers #define
wchar_t char

The error can be avoided by rearranging the inclusion order in some files under the text-utils directory.

Quoted 7 lines

Fixes:

http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941

I tried to fix the same problem in commit 5a18eabdf08564688761a9b2f35892d69d8f9a18, but apparently failed at taking into account all the possible situations.

So if we are going to merge a different solution, I'd like to see an investigation of whether commit 5a18eabdf08564688761a9b2f35892d69d8f9a18 is still needed or not. If it's not, then it should be reverted as well.

It can be reverted. I just confirmed that my patch covers both the musl and uClibc cases.

Quoted 9 lines
Quoted 4 lines

I must say I find the fix of playing with the ordering of includes to be somewhat hackish. Do we have a better solution? Is it really legal for util-linux to redefine wchar_t? Should it use a better autoconf check before doing this?

Maybe we should ask the util-linux list? There's often an active discussion, on what is the correct way to handle such things.

Marcus

I just sent a patch to the util-linux list.

Carlos Santos (Casantos) - DATACOM, P&D
?Something must be done. This is something. Therefore we must do it.? (from the BBC series ?Yes, Prime Minister?, ?Power to the people?)

#6 lore raw

PATCH v2 1/1 util-linux: fix ncurses/wchar handling (again)

Quoted 13 lines

From: "Carlos Santos" <[email protected]>
To: "Hoffmann, Marcus" <[email protected]>, "Petazzoni, Thomas" <[email protected]>
Cc: buildroot at busybox.net
Sent: Thursday, January 19, 2017 5:28:50 PM
Subject: Re: [Buildroot] [PATCH v2] util-linux: fix ncurses/wchar handling (again)

Quoted 7 lines

From: "Marcus Hoffmann" <[email protected]>
To: buildroot at busybox.net
Sent: Tuesday, January 17, 2017 11:57:12 AM
Subject: Re: [Buildroot] [PATCH v2] util-linux: fix ncurses/wchar handling (again)

On 17.01.2017 06:44, Thomas Petazzoni wrote:

[...]

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines

So if we are going to merge a different solution, I'd like to see an investigation of whether commit 5a18eabdf08564688761a9b2f35892d69d8f9a18 is still needed or not. If it's not, then it should be reverted as well.

It can be reverted. I just confirmed that my patch covers both the musl and uClibc cases.

Quoted 5 lines
Quoted 4 lines

I must say I find the fix of playing with the ordering of includes to be somewhat hackish. Do we have a better solution? Is it really legal for util-linux to redefine wchar_t? Should it use a better autoconf check before doing this?

Quoted 6 lines
Quoted 4 lines

Maybe we should ask the util-linux list? There's often an active discussion, on what is the correct way to handle such things.

Marcus

I just sent a patch to the util-linux list.

Good news! My patch was accepted and applied upstream:

    http://git.kernel.org/cgit/utils/util-linux/util-linux.git/commit/?id=9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5

Carlos Santos (Casantos) - DATACOM, P&D
?Something must be done. This is something. Therefore we must do it.? (from the BBC series ?Yes, Prime Minister?, ?Power to the people?)

#7 lore raw

PATCH v2 1/1 util-linux: fix ncurses/wchar handling (again)

Quoted 5 lines

From: "Carlos Santos" <[email protected]>
To: "Marcus Hoffmann" <[email protected]>, "Thomas Petazzoni" <[email protected]>
Cc: buildroot at busybox.net
Sent: Friday, January 20, 2017 8:24:03 AM
Subject: Re: [Buildroot] [PATCH v2] util-linux: fix ncurses/wchar handling (again)

[...]

Quoted 4 lines

Good news! My patch was accepted and applied upstream:

   http://git.kernel.org/cgit/utils/util-linux/util-linux.git/commit/?id=9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5

Hi,

Would a solution like this be considered too much hacky?

package/util-linux/util-linux.hash +2 -0
index 4f19851..46b58f0 100644
@@ -1,2 +1,4 @@
 # From https://www.kernel.org/pub/linux/utils/util-linux/v2.29/sha256sums.asc
 sha256 2c59ea67cc7b564104f60532f6e0a95fe17a91acb870ba8fd7e986f273abf9e7  util-linux-2.29.tar.xz
+# Locally computed
+sha256 d0c3ecc2d80106b65a005056baab4be78bf7184d25fae88aa358c65db54b578c  ?id=9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5
package/util-linux/util-linux.mk +1 -0
index 51ece90..6140fe1 100644
@@ -8,6 +8,7 @@ UTIL_LINUX_VERSION_MAJOR = 2.29
 UTIL_LINUX_VERSION = $(UTIL_LINUX_VERSION_MAJOR)
 UTIL_LINUX_SOURCE = util-linux-$(UTIL_LINUX_VERSION).tar.xz
 UTIL_LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/util-linux/v$(UTIL_LINUX_VERSION_MAJOR)
+UTIL_LINUX_PATCH = http://git.kernel.org/cgit/utils/util-linux/util-linux.git/patch/?id=9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5
 
 # For 0001-build-sys-prefer-pkg-config-for-ncurses.patch and
 # 0002-build-sys-cleanup-UL_NCURSES_CHECK.patch

The only disadvantage seems to be the ugly file name. I looked ad the download support scripts and was unable to find a way to save with a more friendly name like ?util-linux-9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5.patch?.

Carlos Santos (Casantos) - DATACOM, P&D
?Something must be done. This is something. Therefore we must do it.? (from the BBC series ?Yes, Prime Minister?, ?Power to the people?)

#8 lore raw

PATCH v2 1/1 util-linux: fix ncurses/wchar handling (again)

Quoted 5 lines

From: "Carlos Santos" <[email protected]>
To: "Marcus Hoffmann" <[email protected]>, "Thomas Petazzoni" <[email protected]>
Cc: buildroot at busybox.net
Sent: Saturday, January 21, 2017 6:52:55 PM
Subject: Re: [Buildroot] [PATCH v2] util-linux: fix ncurses/wchar handling (again)

---8<---

Quoted 28 lines

Hi,

Would a solution like this be considered too much hacky?

package/util-linux/util-linux.hash +0 -0
index 4f19851..46b58f0 100644
@@ -1,2 +1,4 @@
 # From https://www.kernel.org/pub/linux/utils/util-linux/v2.29/sha256sums.asc

sha256 2c59ea67cc7b564104f60532f6e0a95fe17a91acb870ba8fd7e986f273abf9e7 util-linux-2.29.tar.xz

package/util-linux/util-linux.hash +2 -0
+# Locally computed
+sha256 d0c3ecc2d80106b65a005056baab4be78bf7184d25fae88aa358c65db54b578c

?id=9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5

package/util-linux/util-linux.mk +0 -0
index 51ece90..6140fe1 100644
@@ -8,6 +8,7 @@ UTIL_LINUX_VERSION_MAJOR = 2.29
 UTIL_LINUX_VERSION = $(UTIL_LINUX_VERSION_MAJOR)

UTIL_LINUX_SOURCE = util-linux-$(UTIL_LINUX_VERSION).tar.xz UTIL_LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/util-linux/v$(UTIL_LINUX_VERSION_MAJOR) +UTIL_LINUX_PATCH =
http://git.kernel.org/cgit/utils/util-linux/util-linux.git/patch/?id=9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5

Quoted 6 lines

# For 0001-build-sys-prefer-pkg-config-for-ncurses.patch and # 0002-build-sys-cleanup-UL_NCURSES_CHECK.patch

The only disadvantage seems to be the ugly file name. I looked ad the download support scripts and was unable to find a way to save with a more friendly name like ?util-linux-9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5.patch?.

Answering to my own question: cgit accepts a request like

    http://git.kernel.org/cgit/utils/util-linux/util-linux.git/patch/9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5.patch

Carlos Santos (Casantos) - DATACOM, P&D
?Something must be done. This is something. Therefore we must do it.? (from the BBC series ?Yes, Prime Minister?, ?Power to the people?)

#9 lore raw

PATCH v3 1/2 Revert "util-linux: fix ncurses/wchar handling"

In reply to Carlos Santos

This reverts commit 5a18eabdf08564688761a9b2f35892d69d8f9a18.

It did not take into account all the possible situations. A different fix will be provided in a forthcomming patch.

---
 package/util-linux/Config.in     |  5 -----
 package/util-linux/util-linux.mk | 20 ++++++++++----------
 2 files changed, 10 insertions(+), 15 deletions(-)
package/util-linux/Config.in +0 -5
index cfb2451..e957f84 100644
@@ -207,7 +207,6 @@ config BR2_PACKAGE_UTIL_LINUX_MORE
 	bool "more"
 	depends on BR2_USE_MMU # fork()
 	select BR2_PACKAGE_NCURSES
-	select BR2_PACKAGE_NCURSES_WCHAR if BR2_USE_WCHAR
 	help
 	  File perusal filter for crt viewing
 
@@ -253,7 +252,6 @@ config BR2_PACKAGE_UTIL_LINUX_PG
 	bool "pg"
 	depends on BR2_USE_MMU # fork()
 	select BR2_PACKAGE_NCURSES
-	select BR2_PACKAGE_NCURSES_WCHAR if BR2_USE_WCHAR
 	help
 	  Browse pagewise through text files
 
@@ -300,7 +298,6 @@ config BR2_PACKAGE_UTIL_LINUX_SETPRIV
 config BR2_PACKAGE_UTIL_LINUX_SETTERM
 	bool "setterm"
 	select BR2_PACKAGE_NCURSES
-	select BR2_PACKAGE_NCURSES_WCHAR if BR2_USE_WCHAR
 	help
 	  Set terminal attributes
 
@@ -313,14 +310,12 @@ config BR2_PACKAGE_UTIL_LINUX_SWITCH_ROOT
 config BR2_PACKAGE_UTIL_LINUX_TUNELP
 	bool "tunelp"
 	select BR2_PACKAGE_NCURSES
-	select BR2_PACKAGE_NCURSES_WCHAR if BR2_USE_WCHAR
 	help
 	  Set various parameters for the lp device
 
 config BR2_PACKAGE_UTIL_LINUX_UL
 	bool "ul"
 	select BR2_PACKAGE_NCURSES
-	select BR2_PACKAGE_NCURSES_WCHAR if BR2_USE_WCHAR
 	help
 	  Do underlining
 
package/util-linux/util-linux.mk +10 -10
index 414465c..51ece90 100644
@@ -45,21 +45,21 @@ ifeq ($(BR2_PACKAGE_BUSYBOX),y)
 UTIL_LINUX_DEPENDENCIES += busybox
 endif
 
-ifeq ($(BR2_USE_WCHAR),y)
-UTIL_LINUX_CONF_OPTS += --enable-widechar
-else
-UTIL_LINUX_CONF_OPTS += --disable-widechar
-endif
-
-ifeq ($(BR2_PACKAGE_NCURSES_WCHAR),y)
+ifeq ($(BR2_PACKAGE_NCURSES),y)
 UTIL_LINUX_DEPENDENCIES += ncurses
+ifeq ($(BR2_PACKAGE_NCURSES_WCHAR),y)
 UTIL_LINUX_CONF_OPTS += --with-ncursesw
 UTIL_LINUX_CONF_ENV += NCURSESW5_CONFIG=$(STAGING_DIR)/usr/bin/$(NCURSES_CONFIG_SCRIPTS)
-else ifeq ($(BR2_PACKAGE_NCURSES):$(BR2_USE_WCHAR),y:)
-UTIL_LINUX_DEPENDENCIES += ncurses
-UTIL_LINUX_CONF_OPTS += --without-ncursesw --with-ncurses
+else
+UTIL_LINUX_CONF_OPTS += --without-ncursesw --with-ncurses --disable-widechar
 UTIL_LINUX_CONF_ENV += NCURSES5_CONFIG=$(STAGING_DIR)/usr/bin/$(NCURSES_CONFIG_SCRIPTS)
+endif
+else
+ifeq ($(BR2_USE_WCHAR),y)
+UTIL_LINUX_CONF_OPTS += --enable-widechar
 else
+UTIL_LINUX_CONF_OPTS += --disable-widechar
+endif
 UTIL_LINUX_CONF_OPTS += --without-ncursesw --without-ncurses
 endif
 
Signature · 1 line
2.7.4
#10 lore raw

PATCH v3 2/2 util-linux: fix ncurses/wchar handling (again)

Since commit 006a328ad6bed214ec3c4d92120510ea37329dd1 ("util-linux: fix build with ncurses"), we have a build failure that occurs with musl and uClibc-ng toolchains when wide-char support is not enabled in ncurses.

The problem occurs because util-linux #defines its own wchar_t (as char) when configured without widechar support. It was fixed upstream, so pull the corresponding patch from the util-linux git repository.

Fixes:
http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941
http://autobuild.buildroot.net/results/8a9e197ba7a292b18f8c0c36dca974685556a38a

---
Changes v1 -> v2
- Fixed commit message (mental note: do not run "git commit" at 2:30 AM)
Changes v2 -> v3
- Pull the patch from the util-linux git repository
- Simplify commit message

---
 ...ix-compilation-with-ncurses-and-uClibc-or.patch | 92 ++++++++++++++++++++++
 1 file changed, 92 insertions(+)
 create mode 100644 package/util-linux/0003-build-sys-fix-compilation-with-ncurses-and-uClibc-or.patch
package/util-linux/0003-build-sys-fix-compilation-with-ncurses-and-uClibc-or.patch new file +92 -0
new file mode 100644
index 0000000..2a1e56d
@@ -0,0 +1,92 @@
+From 9ea8ded37b648bbd538cbf9c4d144b8b1a93c1b5 Mon Sep 17 00:00:00 2001
+From: Carlos Santos <[email protected]>
+Date: Thu, 19 Jan 2017 17:27:37 -0200
+Subject: [PATCH] build-sys: fix compilation with ncurses and uClibc or musl
+ libc
+
+Compiling util-linux with musl and uClibc-ng toolchains when wide-char
+support is not enabled in ncurses results in compilation failures with
+the following message:
+
+    error: two or more data types in declaration specifiers
+    #define
+     wchar_t char
+
+The problem occurs because util-linux #defines its own wchar_t (as char)
+when configured without widechar support. This conflicts with definition
+of wchar_t contained in stddef.h.
+
+This error can be reproduced running "<toolchain-cc -o test test.c" with
+the following test program:
+
+    #include <ctype.h>
+    #define wchar_t char
+    #include <stddef.h>
+
+    int main()
+    {
+        return 0;
+    }
+
+The only way to avoid the problem it to reorder the inclusion of headers
+in some files under the text-utils directory.
+
+Addresses:
+  http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
+  http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
+  http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941
+  http://autobuild.buildroot.net/results/8a9e197ba7a292b18f8c0c36dca974685556a38a
+
+Signed-off-by: Carlos Santos <[email protected]>
+---
+ text-utils/colcrt.c | 2 +-
+ text-utils/colrm.c  | 2 +-
+ text-utils/column.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c
+index c6bba4b..346a10f 100644
+--- a/text-utils/colcrt.c
++++ b/text-utils/colcrt.c
+@@ -46,8 +46,8 @@
+ #include <getopt.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "closestream.h"
+ 
+ /*
+diff --git a/text-utils/colrm.c b/text-utils/colrm.c
+index 9510b72..d474696 100644
+--- a/text-utils/colrm.c
++++ b/text-utils/colrm.c
+@@ -44,9 +44,9 @@
+ #include <unistd.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "strutils.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "closestream.h"
+ 
+ /*
+diff --git a/text-utils/column.c b/text-utils/column.c
+index 43b3af5..2eb47a3 100644
+--- a/text-utils/column.c
++++ b/text-utils/column.c
+@@ -50,8 +50,8 @@
+ #include <getopt.h>
+ 
+ #include "nls.h"
+-#include "widechar.h"
+ #include "c.h"
++#include "widechar.h"
+ #include "xalloc.h"
+ #include "strutils.h"
+ #include "closestream.h"
+-- 
+2.7.4
+
Signature · 1 line
2.7.4
#11 lore raw

PATCH v3 1/2 Revert "util-linux: fix ncurses/wchar handling"

In reply to Carlos Santos

Hello,

Quoted 10 lines · Carlos Santos

This reverts commit 5a18eabdf08564688761a9b2f35892d69d8f9a18.

It did not take into account all the possible situations. A different fix will be provided in a forthcomming patch.

---
 package/util-linux/Config.in     |  5 -----
 package/util-linux/util-linux.mk | 20 ++++++++++----------
 2 files changed, 10 insertions(+), 15 deletions(-)

Both applied to master. Let's see if it really fixes all the problems :-)

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com