Skip to contentSkip to conversation

configure: fix non-newlib cross-compiling

PATCH Applied Andrew Jones 3 participants 3 messages Jan 17, 2017 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 configure: fix non-newlib cross-compiling

Commit 529046c3 "libcflat: add PRI(dux)32 format types" applies a detection trick that requires native compiling or cross-compiling with newlib, an embedded system C standard library. We can avoid the new dependency with a different trick.

---
v3: don't forget to use cross-cc [Alex]
v2: drop the awk magic and just grep for long, as not all compilers
have long in the same place

---
 configure | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
configure +5 -9
index 127868ce3090..8821f3741836 100755
@@ -12,6 +12,7 @@ host=$arch
 cross_prefix=
 endian=""
 pretty_print_stacks=yes
+u32_long=
 
 usage() {
     cat <<-EOF
@@ -110,16 +111,11 @@ if [ -f $testdir/run ]; then
 fi
 
 # check if uint32_t needs a long format modifier
-cat << EOF > lib_test.c
-#include <inttypes.h>
+cat << EOF > lib-test.c
+__UINT32_TYPE__
 EOF
-
-$cross_prefix$cc lib_test.c -E | grep "typedef" | grep "long" | grep "uint32_t" &> /dev/null
-exit=$?
-if [ $exit -eq 0 ]; then
-    u32_long=true
-fi
-rm -f lib_test.c
+u32_long=$($cross_prefix$cc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)
+rm -f lib-test.c
 
 # check for dependent 32 bit libraries
 if [ "$arch" != "arm" ]; then
Signature · 1 line
2.9.3
Reviewed-by Tested-by on v3 1/1
#1 lore raw
Quoted 7 lines · Andrew Jones

Commit 529046c3 "libcflat: add PRI(dux)32 format types" applies a detection trick that requires native compiling or cross-compiling with newlib, an embedded system C standard library. We can avoid the new dependency with a different trick.

Quoted 32 lines

---
v3: don't forget to use cross-cc [Alex]
v2: drop the awk magic and just grep for long, as not all compilers
have long in the same place

---
 configure | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
configure +3 -4
index 127868ce3090..8821f3741836 100755
@@ -12,6 +12,7 @@ host=$arch
 cross_prefix=
 endian=""
 pretty_print_stacks=yes
+u32_long=
 
 usage() {
     cat <<-EOF
@@ -110,16 +111,11 @@ if [ -f $testdir/run ]; then
 fi
 
 # check if uint32_t needs a long format modifier
-cat << EOF > lib_test.c
-#include <inttypes.h>
+cat << EOF > lib-test.c
+__UINT32_TYPE__
 EOF
-
-$cross_prefix$cc lib_test.c -E | grep "typedef" | grep "long" | grep "uint32_t" &> /dev/null

configure if [ -f $testdir/run ]; then · line 121

Quoted 10 lines
configure +2 -5
-exit=$?
-if [ $exit -eq 0 ]; then
-    u32_long=true
-fi
-rm -f lib_test.c
+u32_long=$($cross_prefix$cc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)
+rm -f lib-test.c
 
 # check for dependent 32 bit libraries
 if [ "$arch" != "arm" ]; then

--
Alex Bennée

#2 lore raw

2017-01-17 17:03+0000, Alex Bennée:

Quoted 7 lines
Quoted 5 lines · Andrew Jones

Commit 529046c3 "libcflat: add PRI(dux)32 format types" applies a detection trick that requires native compiling or cross-compiling with newlib, an embedded system C standard library. We can avoid the new dependency with a different trick.

Quoted 5 lines
Quoted 2 lines

Applied, thanks.