Skip to contentSkip to conversation

bash: fix linking for static builds with uClibc toolchains

PATCH Superseded Vicente Olivert Riera 4 participants 5 messages Oct 22, 2014 – Oct 25, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 bash: fix linking for static builds with uClibc toolchains

bash fails to link for static builds with uClibc toolchains due to getenv redefinitions. This is caused because bash is unable to check if getenv is already defined when cross-compiling, so it defaults to 'yes':

configure:14438: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes

We can avoid this redefinition by passing bash_cv_getenv_redef=no to the configure script.

Related:

	http://lists.gnu.org/archive/html/bug-bash/2012-03/msg00052.html

Fixes:

	http://autobuild.buildroot.net/results/a20/a2007e6dbcfe53e7cd837ae642869ee26376826a/
---
 package/bash/bash.mk |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
package/bash/bash.mk +11 -0
index 34a3a73..5eec3cc 100644
@@ -28,6 +28,17 @@ BASH_MAKE = $(MAKE1)
 # The static build needs some trickery
 ifeq ($(BR2_PREFER_STATIC_LIB),y)
 BASH_CONF_OPTS += --enable-static-link --without-bash-malloc
+# bash wants to redefine the getenv() function. To check whether this is
+# possible, AC_TRY_RUN is used which is not possible in
+# cross-compilation.
+# On uClibc, redefining getenv is not possible; on glibc and musl it is.
+# Related:
+# http://lists.gnu.org/archive/html/bug-bash/2012-03/msg00052.html
+ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
+BASH_CONF_ENV += bash_cv_getenv_redef=no
+else
+BASH_CONF_ENV += bash_cv_getenv_redef=yes
+endif
 endif
 
 # Make /bin/sh -> bash (no other shell, better than busybox shells)
Signature · 1 line
1.7.1
#1 lore raw

PATCH v4 1/1 bash: fix linking for static builds with uClibc toolchains

Quoted 10 lines · Vicente Olivert Riera

bash fails to link for static builds with uClibc toolchains due to getenv redefinitions. This is caused because bash is unable to check if getenv is already defined when cross-compiling, so it defaults to 'yes':

configure:14438: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes

We can avoid this redefinition by passing bash_cv_getenv_redef=no to the configure script.

Quoted 8 lines

Related:

	http://lists.gnu.org/archive/html/bug-bash/2012-03/msg00052.html

Fixes:

	http://autobuild.buildroot.net/results/a20/a2007e6dbcfe53e7cd837ae642869ee26376826a/

---

It's best if you write something here ^^^ (below the ---, notes section) when you send a new version of the patch so we now what changed from the previous version, because it's not always obvious what changed between the different versions.

For example

---
Changes since v3:
- Added foo

Changes since v2:
- Added bar

Changes since v1:
- More foobar

Signature · 1 line
markos
#2 lore raw

PATCH v4 1/1 bash: fix linking for static builds with uClibc toolchains

Dear Markos Chandras,

Quoted 32 lines · Markos Chandras
Quoted 10 lines · Vicente Olivert Riera

bash fails to link for static builds with uClibc toolchains due to getenv redefinitions. This is caused because bash is unable to check if getenv is already defined when cross-compiling, so it defaults to 'yes':

configure:14438: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes

We can avoid this redefinition by passing bash_cv_getenv_redef=no to the configure script.

Quoted 8 lines

Related:

	http://lists.gnu.org/archive/html/bug-bash/2012-03/msg00052.html

Fixes:

	http://autobuild.buildroot.net/results/a20/a2007e6dbcfe53e7cd837ae642869ee26376826a/

---

It's best if you write something here ^^^ (below the ---, notes section) when you send a new version of the patch so we now what changed from the previous version, because it's not always obvious what changed between the different versions.

For example

---
Changes since v3:
- Added foo

Quoted 6 lines

Changes since v2:
- Added bar

Changes since v1:
- More foobar

Good advice; I'll take it into account for future patches. Thank you!

Best regards,

Signature · 5 lines
Vicente Olivert Riera
Graduate Software Engineer, MIPS Processor IP
Imagination Technologies Limited
t: +44 (0)113 2429814
www.imgtec.com
#3 lore raw

PATCH v4 1/1 bash: fix linking for static builds with uClibc toolchains

In reply to Vicente Olivert Riera
Quoted 10 lines · Vicente Olivert Riera

bash fails to link for static builds with uClibc toolchains due to getenv redefinitions. This is caused because bash is unable to check if getenv is already defined when cross-compiling, so it defaults to 'yes':

configure:14438: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes

We can avoid this redefinition by passing bash_cv_getenv_redef=no to the configure script.

Quoted 7 lines

Related:

	http://lists.gnu.org/archive/html/bug-bash/2012-03/msg00052.html

Fixes:

	http://autobuild.buildroot.net/results/a20/a2007e6dbcfe53e7cd837ae642869ee26376826a/

Small additional remark...

Quoted 9 lines
---
 package/bash/bash.mk |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
package/bash/bash.mk +0 -0
index 34a3a73..5eec3cc 100644

package/bash/bash.mk BASH_MAKE = $(MAKE1) · line 34

Quoted 7 lines
package/bash/bash.mk +4 -0
@@ -28,6 +28,17 @@ BASH_MAKE = $(MAKE1)
 # The static build needs some trickery
 ifeq ($(BR2_PREFER_STATIC_LIB),y)
 BASH_CONF_OPTS += --enable-static-link --without-bash-malloc
+# bash wants to redefine the getenv() function. To check whether this is
+# possible, AC_TRY_RUN is used which is not possible in
+# cross-compilation.
+# On uClibc, redefining getenv is not possible; on glibc and musl it is.

I failed to notice earlier: glibc is not available on static builds so it
doesn't make a lot of sense to mention it here.

Regards,
Arnout

Quoted 11 lines
package/bash/bash.mk +7 -0
+# Related:
+# http://lists.gnu.org/archive/html/bug-bash/2012-03/msg00052.html
+ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
+BASH_CONF_ENV += bash_cv_getenv_redef=no
+else
+BASH_CONF_ENV += bash_cv_getenv_redef=yes
+endif
 endif
 
 # Make /bin/sh -> bash (no other shell, better than busybox shells)
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#4 lore raw

PATCH v4 1/1 bash: fix linking for static builds with uClibc toolchains

In reply to Vicente Olivert Riera

Dear Vicente Olivert Riera,

Quoted 13 lines · Vicente Olivert Riera

bash fails to link for static builds with uClibc toolchains due to getenv redefinitions. This is caused because bash is unable to check if getenv is already defined when cross-compiling, so it defaults to 'yes':

configure:14438: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes

We can avoid this redefinition by passing bash_cv_getenv_redef=no to the configure script.

Related:

	http://lists.gnu.org/archive/html/bug-bash/2012-03/msg00052.html
Quoted 7 lines

Fixes:

	http://autobuild.buildroot.net/results/a20/a2007e6dbcfe53e7cd837ae642869ee26376826a/
---
 package/bash/bash.mk |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

Applied, thanks.

Thomas

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