Skip to contentSkip to conversation

configure: fix non-newlib cross-compiling

PATCH Superseded Andrew Jones 2 participants 5 messages Jan 16, 2017 – Jan 17, 2017 KVM

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
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..a05a4e3a5bc3 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=$(gcc -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
#1 lore raw
Quoted 34 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.

---
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 +2 -2
index 127868ce3090..a05a4e3a5bc3 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

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

Quoted 10 lines
configure +2 -7
+__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=$(gcc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)

Erm you'll need to use the cross compiler here...

  u32_long=$($cross_prefix$cc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)

--
Alex Bennée

#2 lore raw
Quoted 33 lines · Alex Bennée
Quoted 30 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.

---
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 +1 -0
index 127868ce3090..a05a4e3a5bc3 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
 
Quoted 16 lines
Quoted 4 lines
configure +1 -2
 # check if uint32_t needs a long format modifier
-cat << EOF > lib_test.c
-#include <inttypes.h>
+cat << EOF > lib-test.c

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

Quoted 10 lines
configure +2 -7
+__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=$(gcc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)

Erm you'll need to use the cross compiler here...

Argh. I copy+pasted that from my 3-line test script without remembering to change it. v3 coming...

Thanks,
drew

Quoted 9 lines
  u32_long=$($cross_prefix$cc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)

--
Alex Bennée
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 51 lines · Andrew Jones
Quoted 33 lines · Alex Bennée
Quoted 30 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.

---
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 +1 -0
index 127868ce3090..a05a4e3a5bc3 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
 
Quoted 16 lines
Quoted 4 lines
configure +1 -2
 # check if uint32_t needs a long format modifier
-cat << EOF > lib_test.c
-#include <inttypes.h>
+cat << EOF > lib-test.c

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

Quoted 10 lines
configure +2 -7
+__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=$(gcc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)

Erm you'll need to use the cross compiler here...

Quoted 2 lines

Argh. I copy+pasted that from my 3-line test script without remembering to change it. v3 coming...

I can include your fixed patch in the series I'm about to post if you want?

--
Alex Bennée

#4 lore raw
Quoted 54 lines · Alex Bennée
Quoted 51 lines · Andrew Jones
Quoted 49 lines · Alex Bennée
Quoted 34 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.

---
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 +2 -2
index 127868ce3090..a05a4e3a5bc3 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

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

Quoted 10 lines
configure +2 -7
+__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=$(gcc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)

Erm you'll need to use the cross compiler here...

Quoted 5 lines
Quoted 2 lines

Argh. I copy+pasted that from my 3-line test script without remembering to change it. v3 coming...

I can include your fixed patch in the series I'm about to post if you want?

I already posted it and Radim says he'll pick it up now if you say it's good to go.

Thanks,
drew

Quoted 3 lines

--
Alex Bennée