configure: fix non-newlib cross-compiling
PATCH 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.
--- configure | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
configure +5 -9
@@ -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 | awk '! /^#/ && $2 == "long" {print "yes"}') +rm -f lib-test.c # check for dependent 32 bit libraries if [ "$arch" != "arm" ]; then
Signature · 1 line
2.9.3
Quoted 31 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.Cc Alex Bennée <[email protected]>Signed-off-by Andrew Jones <[email protected]>--- configure | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)configure +3
-2@@ -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__
configure if [ -f $testdir/run ]; then · line 118
Quoted 10 lines
configure +2
-7EOF - -$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 | awk '! /^#/ && $2 == "long" {print "yes"}') +rm -f lib-test.c
Hmm this fails on my system as the -E output is:
15:18 alex@overdrive01/aarch64 [kvm-unit-tests-32bit.git/review/drew-config@github] >arm-none-eabi-gcc -E test.c # 1 "test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.c"
long unsigned int
Changing the line to:
u32_long=$($cross_prefix$cc -E lib-test.c | awk '! /^#/ && $1 == "long" {print "yes"}')Fixes the detection for me but I wonder if there are other corner cases to catch?
The rest of the compile fails later due to un-merged format fixes for pci_setup_msi which I guess is expected.
configure if [ -f $testdir/run ]; then · line 121
Quoted 3 lines
configure +0
-0# check for dependent 32 bit libraries if [ "$arch" != "arm" ]; then
--
Alex Bennée
Quoted 54 lines · Alex Bennée
Quoted 31 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.Cc Alex Bennée <[email protected]>Signed-off-by Andrew Jones <[email protected]>--- configure | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)configure +3
-2@@ -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__configure if [ -f $testdir/run ]; then · line 118
Quoted 10 lines
configure +2
-7EOF - -$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 | awk '! /^#/ && $2 == "long" {print "yes"}') +rm -f lib-test.cHmm this fails on my system as the -E output is:
15:18 alex@overdrive01/aarch64 [kvm-unit-tests-32bit.git/review/drew-config@github] >arm-none-eabi-gcc -E
test.c# 1 "test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.c"
long unsigned int
Quoted 3 lines
Changing the line to:
u32_long=$($cross_prefix$cc -E lib-test.c | awk '! /^#/ && $1 == "long" {print "yes"}')
Let's change it to a couple simple greps then
u32_long=$(gcc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)
Quoted 3 lines
Fixes the detection for me but I wonder if there are other corner cases to catch?
Hope not, but I wouldn't be surprised. This type of detection is pretty fragile...
Quoted 3 lines
The rest of the compile fails later due to un-merged format fixes for
pci_setup_msiwhich I guess is expected.
Hmm, those are in master already. Did you apply this to a latest pull?
Thanks for testing! I'll send a v2.
drew
Quoted 12 lines
configure if [ -f $testdir/run ]; then · line 121
Quoted 4 lines
configure +0
-0# check for dependent 32 bit libraries if [ "$arch" != "arm" ]; then--
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
Quoted 55 lines · Andrew Jones
Quoted 54 lines · Alex Bennée
Quoted 31 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.Cc Alex Bennée <[email protected]>Signed-off-by Andrew Jones <[email protected]>--- configure | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)configure +3
-2@@ -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__configure if [ -f $testdir/run ]; then · line 118
Quoted 10 lines
configure +2
-7EOF - -$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 | awk '! /^#/ && $2 == "long" {print "yes"}') +rm -f lib-test.cHmm this fails on my system as the -E output is:
15:18 alex@overdrive01/aarch64 [kvm-unit-tests-32bit.git/review/drew-config@github] >arm-none-eabi-gcc -E
test.c# 1 "test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.c"
long unsigned int
Quoted 8 lines
Quoted 3 lines
Changing the line to:
u32_long=$($cross_prefix$cc -E lib-test.c | awk '! /^#/ && $1 == "long" {print "yes"}')Let's change it to a couple simple greps then
u32_long=$(gcc -E
lib-test.c| grep -v '^#' | grep -q long && echo yes)
Sounds good to me.
Quoted 5 lines
Quoted 4 lines
Fixes the detection for me but I wonder if there are other corner cases to catch?
Quoted 8 lines
Hope not, but I wouldn't be surprised. This type of detection is pretty fragile...
Quoted 3 lines
The rest of the compile fails later due to un-merged format fixes for
pci_setup_msiwhich I guess is expected.Hmm, those are in master already. Did you apply this to a latest pull?
Yeah I applied to tip. I think Paolo only took part of the merge but that's OK I'll re-submit what's left in my series after I've gone through comments.
Quoted 17 lines
Thanks for testing! I'll send a v2.
drew
Quoted 12 lines
configure if [ -f $testdir/run ]; then · line 121
Quoted 4 lines
configure +0
-0# check for dependent 32 bit libraries if [ "$arch" != "arm" ]; then--
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
--
Alex Bennée