Skip to contentSkip to conversation

configure: verify stdio.h

PATCH In review Michael S. Tsirkin 4 participants 9 messages Jan 26, 2010 – Jan 28, 2010

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 configure: verify stdio.h

Verify that stdio.h supports %lld %zd.
Some migw variants don't unless requested explicitly (see
http://www.mail-archive.com/[email protected]/msg00417.html)
), detect them early.

---

changes from v1:
removed leftover chunk

 configure |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
configure +20 -0
index 5631bbb..6ba06d6 100755
@@ -123,6 +123,26 @@ else
     exit 1
 fi
 
+# Check that stdio.h compiler is sane: some
+# mingw variants do not support %z %l that we rely on
+cat > $TMPC <<EOF
+#include <stddef.h>
+#include <stdio.h>
+size_t z = 1;
+long long ll = 2;
+int main(void) {
+  printf("z=%zd;ll=%lld;\n", z, ll);
+  return 0;
+}
+EOF
+
+if compile_prog && ($TMPE | grep "z=1;ll=2;" > /dev/null); then
+  : C compiler works ok
+else
+    echo "ERROR: \"$cc\" does not have a working stdio.h"
+    exit 1
+fi
+
 check_define() {
 cat > $TMPC <<EOF
 #if !defined($1)
Signature · 1 line
1.6.6.144.g5c3af
#1 lore raw
Quoted 37 lines · Michael S. Tsirkin

Verify that stdio.h supports %lld %zd.
Some migw variants don't unless requested explicitly (see
http://www.mail-archive.com/[email protected]/msg00417.html)
), detect them early.

---

changes from v1:
removed leftover chunk

 configure |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
configure +13 -0
index 5631bbb..6ba06d6 100755
@@ -123,6 +123,26 @@ else
     exit 1
 fi
 
+# Check that stdio.h compiler is sane: some
+# mingw variants do not support %z %l that we rely on
+cat > $TMPC <<EOF
+#include <stddef.h>
+#include <stdio.h>
+size_t z = 1;
+long long ll = 2;
+int main(void) {
+  printf("z=%zd;ll=%lld;\n", z, ll);
+  return 0;
+}
+EOF
+

configure else · line 148

Quoted 10 lines
configure +7 -0
+if compile_prog && ($TMPE | grep "z=1;ll=2;" > /dev/null); then
+  : C compiler works ok
+else
+    echo "ERROR: \"$cc\" does not have a working stdio.h"
+    exit 1
+fi
+
 check_define() {
 cat > $TMPC <<EOF
 #if !defined($1)

This makes cross-compiling impossible. Is that really desirable?

Signature · 2 lines
Måns Rullgård
[email protected]
#2 lore raw

2010/1/26 Måns Rullgård <[email protected]>:

Quoted 43 lines
Quoted 41 lines · Michael S. Tsirkin

Verify that stdio.h supports %lld %zd.
Some migw variants don't unless requested explicitly (see
http://www.mail-archive.com/[email protected]/msg00417.html)
), detect them early.

---

changes from v1:
      removed leftover chunk

 configure |   20 ++++++++++++++++++++

 1 files changed, 20 insertions(+), 0 deletions(-)
configure +0 -0
index 5631bbb..6ba06d6 100755
@@ -123,6 +123,26 @@ else

     exit 1
 fi

configure +17 -0
+# Check that stdio.h compiler is sane: some
+# mingw variants do not support %z %l that we rely on
+cat > $TMPC <<EOF
+#include <stddef.h>
+#include <stdio.h>
+size_t z = 1;
+long long ll = 2;
+int main(void) {
+  printf("z=%zd;ll=%lld;\n", z, ll);
+  return 0;
+}
+EOF
+
+if compile_prog && ($TMPE | grep "z=1;ll=2;" > /dev/null); then
+  : C compiler works ok
+else
+    echo "ERROR: \"$cc\" does not have a working stdio.h"
Quoted 8 lines
Quoted 6 lines

+    exit 1

configure +2 -0
+fi
+

 check_define() {
 cat > $TMPC <<EOF
 #if !defined($1)

This makes cross-compiling impossible.  Is that really desirable?

I'd rather drop %ll and %z.

#3 lore raw
In reply to Michael S. Tsirkin
Quoted 2 lines · Michael S. Tsirkin

Verify that stdio.h supports %lld %zd.
Some migw variants don't unless requested explicitly (see

migw -> mingw

I don't know any ming32 variant which supports %lld, %zd. There is a new mingw-w64 were people are addressing the problem, but that variant is unsupported by qemu.

Quoted 42 lines

http://www.mail-archive.com/[email protected]/msg00417.html)
), detect them early.

---

changes from v1:
removed leftover chunk

configure | 20 ++++++++++++++++++++

1 files changed, 20 insertions(+), 0 deletions(-)
configure +0 -0
index 5631bbb..6ba06d6 100755
@@ -123,6 +123,26 @@ else

exit 1
fi

configure +20 -0
+# Check that stdio.h compiler is sane: some
+# mingw variants do not support %z %l that we rely on
+cat > $TMPC <<EOF
+#include <stddef.h>
+#include <stdio.h>
+size_t z = 1;
+long long ll = 2;
+int main(void) {
+ printf("z=%zd;ll=%lld;\n", z, ll);
+ return 0;
+}
+EOF
+
+if compile_prog && ($TMPE | grep "z=1;ll=2;" > /dev/null); then
+ : C compiler works ok
+else
+ echo "ERROR: \"$cc\" does not have a working stdio.h"
+ exit 1
+fi
+
Quoted 3 lines

check_define() {
cat > $TMPC <<EOF
#if !defined($1)

Tests of %lld must use a 64 bit pattern (ll = 0x0123456789abcdefLL). Otherwise, %lld, %ld and %d with ll = 1 will all print 1 on little endian machines, and the %lld test won't detect missing support.

The problem is now several years old, it can be avoided for really important output, so it seems acceptable to wait another period of time until a working mingw is supported by qemu.

A test which prevents qemu builds on windows with current mingw32 or cross builds with current debian cross mingw32 would not help. Both variants work for me even without full format support.

Regards,
Stefan Weil

#4 lore raw
Quoted 9 lines · Stefan Weil
Quoted 2 lines · Michael S. Tsirkin

Verify that stdio.h supports %lld %zd.
Some migw variants don't unless requested explicitly (see

migw -> mingw

I don't know any ming32 variant which supports %lld, %zd. There is a new mingw-w64 were people are addressing the problem,

Did you try with -D__USE_MINGW_ANSI_STDIO=1 ?
This is what the link below mentions.

Quoted 1 line

but that variant is unsupported by qemu.

What are the issues?

Quoted 62 lines
Quoted 43 lines

http://www.mail-archive.com/[email protected]/msg00417.html)
), detect them early.

---

changes from v1:
removed leftover chunk

configure | 20 ++++++++++++++++++++

1 files changed, 20 insertions(+), 0 deletions(-)
configure +0 -0
index 5631bbb..6ba06d6 100755
@@ -123,6 +123,26 @@ else

exit 1
fi

configure +20 -0
+# Check that stdio.h compiler is sane: some
+# mingw variants do not support %z %l that we rely on
+cat > $TMPC <<EOF
+#include <stddef.h>
+#include <stdio.h>
+size_t z = 1;
+long long ll = 2;
+int main(void) {
+ printf("z=%zd;ll=%lld;\n", z, ll);
+ return 0;
+}
+EOF
+
+if compile_prog && ($TMPE | grep "z=1;ll=2;" > /dev/null); then
+ : C compiler works ok
+else
+ echo "ERROR: \"$cc\" does not have a working stdio.h"
+ exit 1
+fi
+
Quoted 3 lines

check_define() {
cat > $TMPC <<EOF
#if !defined($1)

Tests of %lld must use a 64 bit pattern (ll = 0x0123456789abcdefLL). Otherwise, %lld, %ld and %d with ll = 1 will all print 1 on little endian machines, and the %lld test won't detect missing support.

The problem is now several years old, it can be avoided for really important output, so it seems acceptable to wait another period of time until a working mingw is supported by qemu.

A test which prevents qemu builds on windows with current mingw32 or cross builds with current debian cross mingw32 would not help. Both variants work for me even without full format support.

Regards,
Stefan Weil

#5 lore raw
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Stefan Weil
Quoted 2 lines · Michael S. Tsirkin

Verify that stdio.h supports %lld %zd.
Some migw variants don't unless requested explicitly (see

Quoted 8 lines
Quoted 5 lines

migw -> mingw

I don't know any ming32 variant which supports %lld, %zd. There is a new mingw-w64 were people are addressing the problem,

Did you try with -D__USE_MINGW_ANSI_STDIO=1 ?
This is what the link below mentions.

New information on this issue:

mingw-runtime 3.15 (2008-09-07) added support for standard format conversion:

http://sourceforge.net/project/shownotes.php?release_id=24832

The release note also says how to select MS or C99/POSIX format strings.

Debian still does not include that version:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498529

Maybe someone knows how we can help to get the new release for debian. It's needed for cross compilation (at least for users who don't want to install it manually).

Quoted 5 lines
Quoted 2 lines

but that variant is unsupported by qemu.

What are the issues?

Good question. I don't know because I did not try it. It was only a guess that qemu would not work with mingw-w64 without modifications.

#6 lore raw
Quoted 25 lines · Stefan Weil
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Stefan Weil
Quoted 2 lines · Michael S. Tsirkin

Verify that stdio.h supports %lld %zd.
Some migw variants don't unless requested explicitly (see

Quoted 8 lines
Quoted 5 lines

migw -> mingw

I don't know any ming32 variant which supports %lld, %zd. There is a new mingw-w64 were people are addressing the problem,

Did you try with -D__USE_MINGW_ANSI_STDIO=1 ?
This is what the link below mentions.

New information on this issue:

mingw-runtime 3.15 (2008-09-07) added support for standard format conversion:

http://sourceforge.net/project/shownotes.php?release_id=24832

The release note also says how to select MS or C99/POSIX format strings.

Quoted 7 lines

Debian still does not include that version:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498529

Maybe someone knows how we can help to get the new release for debian. It's needed for cross compilation (at least for users who don't want to install it manually).

Heh, configure script runs the program it's built
in a couple of places. This probably does not
work for cross-builds:

if compile_prog "" "" ; then
$TMPE && bigendian="yes"
else
echo big/little test failed
fi

likely works by luck for build to intel, because error is interpreted as little-endian.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

but that variant is unsupported by qemu.

What are the issues?

Good question. I don't know because I did not try it. It was only a guess that qemu would not work with mingw-w64 without modifications.

#7 lore raw
Quoted 4 lines · Michael S. Tsirkin

Heh, configure script runs the program it's built
in a couple of places. This probably does not
work for cross-builds:

Quoted 8 lines

if compile_prog "" "" ; then
$TMPE && bigendian="yes"
else
echo big/little test failed
fi

likely works by luck for build to intel, because error is interpreted as little-endian.

In FFmpeg we check the endianness like this:

check_cc <<EOF || die "endian test failed"
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E'; EOF
od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian

This works on every combination of build and target system we use.

Signature · 2 lines
Måns Rullgård
[email protected]
#8 lore raw
In reply to Stefan Weil
Quoted 25 lines · Stefan Weil
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Stefan Weil
Quoted 2 lines · Michael S. Tsirkin

Verify that stdio.h supports %lld %zd.
Some migw variants don't unless requested explicitly (see

Quoted 8 lines
Quoted 5 lines

migw -> mingw

I don't know any ming32 variant which supports %lld, %zd. There is a new mingw-w64 were people are addressing the problem,

Did you try with -D__USE_MINGW_ANSI_STDIO=1 ?
This is what the link below mentions.

New information on this issue:

mingw-runtime 3.15 (2008-09-07) added support for standard format conversion:

http://sourceforge.net/project/shownotes.php?release_id=24832

The release note also says how to select MS or C99/POSIX format strings.

Quoted 7 lines

Debian still does not include that version:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498529

Maybe someone knows how we can help to get the new release for debian. It's needed for cross compilation (at least for users who don't want to install it manually).

Format disk, install Fedora :)

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

but that variant is unsupported by qemu.

What are the issues?

Good question. I don't know because I did not try it. It was only a guess that qemu would not work with mingw-w64 without modifications.