Skip to contentSkip to conversation

Haiku host support and general configure issues

RFC PATCH In review Andreas Färber 5 participants 12 messages Feb 28, 2009 – Mar 9, 2009

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Haiku host support and general configure issues

Hello,

Haiku recently got an experimental GCC 4.3, so I was curious how far QEMU would get there now. This uncovered some generic issues with our configure tests that I think should be tackled before the release.

We have undocumented --extra-cflags= and --extra-ldflags= options that don't work as expected. They are ignored by all the configure tests, so it seems there is no direct equivalent to autoconf's CPPFLAGS to pass in additional header include paths. The OS_CFLAGS come closest, but they are ignored for some of the tests, too. Any preferences how to fix this?

On Haiku, zlib and ncurses headers are not in the default include path, so the current situation does not allow to configure QEMU at all. The attached patch adds a Haiku section to configure to hardcode the path in OS_CFLAGS and adds ${OS_CFLAGS} where necessary for Haiku.

It further sets OS_LDFLAGS to reference libnetwork.so, which contains the socket functions.

The optional curses support relies on -lcurses but it's called libncurses.a on Haiku, so add a check for -lncurses if -lcurses fails. It is then detected.

Unresolved issues include that AIO is detected, and as a consequence AIOLIBS is set to -lpthread but that is not available on Haiku.
The code still does not link qemu-img due to an unresolved symbol _IO in nbd code. Not sure if that's a missing check in QEMU or an issue in Haiku? There doesn't appear to be a switch to disable NBD altogether, so this seems like a blocker for now.

BTW, is it intentional that --disable-gfx-checks is not documented as part of --help, only when the checks do fail?

Andreas

configure +9 -1
Index: configure
===================================================================
@@ -297,6 +297,10 @@
 aix="yes"
 make="gmake"
 ;;
+Haiku)
+OS_CFLAGS="-I/boot/develop/headers/3rdparty"
+OS_LDFLAGS="-lnetwork"
+;;
 *)
 audio_drv_list="oss"
 audio_possible_drivers="oss alsa sdl esd pa"
@@ -933,8 +937,12 @@
 #include <curses.h>
 int main(void) { return curses_version(); }
 EOF
-  if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
+  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lcurses > /dev/null 2> /dev/null ; then
     curses=yes
+  else
+    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lncurses > /dev/null 2> /dev/null ; then
+      curses=yes
+    fi
   fi
 fi # test "$curses"
 

---
Haiku support for configure

Add zlib include path to OS_CFLAGS and link against libnetwork. Make the curses check respect OS_CFLAGS and check for -lncurses as well.

configure +9 -1
Index: configure
===================================================================
@@ -297,6 +297,10 @@
 aix="yes"
 make="gmake"
 ;;
+Haiku)
+OS_CFLAGS="-I/boot/develop/headers/3rdparty"
+OS_LDFLAGS="-lnetwork"
+;;
 *)
 audio_drv_list="oss"
 audio_possible_drivers="oss alsa sdl esd pa"
@@ -933,8 +937,12 @@
 #include <curses.h>
 int main(void) { return curses_version(); }
 EOF
-  if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
+  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lcurses > /dev/null 2> /dev/null ; then
     curses=yes
+  else
+    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lncurses > /dev/null 2> /dev/null ; then
+      curses=yes
+    fi
   fi
 fi # test "$curses"
 
#1 lore raw
Quoted 7 lines

We have undocumented --extra-cflags= and --extra-ldflags= options that
don't work as expected. They are ignored by all the configure tests, so it seems there is no direct equivalent to autoconf's CPPFLAGS to pass in additional header include paths. The OS_CFLAGS come closest, but they are ignored for some of the tests, too. Any preferences how to fix this?

Ideally those shouldn't be needed anyway.

Quoted 4 lines

The optional curses support relies on -lcurses but it's called libncurses.a on Haiku, so add a check for -lncurses if -lcurses fails.
It is then detected.

ncurses is a different implementation but should be compatible AFAIK.

Quoted 1 line

Unresolved issues include that AIO is detected, and as a consequence

Then the test is buggy as we don't have AIO in Haiku that I know of :)

Quoted 1 line

AIOLIBS is set to -lpthread but that is not available on Haiku.

Well we should have a pthread lib available though...

Quoted 5 lines

The code still does not link qemu-img due to an unresolved symbol _IO in nbd code. Not sure if that's a missing check in QEMU or an issue in
Haiku? There doesn't appear to be a switch to disable NBD altogether, so this seems like a blocker for now.

Another big issue that I mentionned earlier here is the widely used assumption that error codes are positive, which is not the case for BeOS and Haiku.
Not fixing this will result in a dangerous binary.

François.

#2 lore raw

Hello,

Am 28.02.2009 um 18:08 schrieb François Revol:

Quoted 9 lines
Quoted 7 lines

We have undocumented --extra-cflags= and --extra-ldflags= options that
don't work as expected. They are ignored by all the configure tests, so it seems there is no direct equivalent to autoconf's CPPFLAGS to pass in additional header include paths. The OS_CFLAGS come closest, but they are ignored for some of the tests, too. Any preferences how to fix this?

Ideally those shouldn't be needed anyway.

Not sure what exactly you're referring to, but both OS-specific as well as user-supplied settings may be necessary and should be working. Command line arguments are necessary to use self-compiled dependency libraries in their own prefix, for example.

Quoted 4 lines
Quoted 2 lines

Unresolved issues include that AIO is detected, and as a consequence

Then the test is buggy as we don't have AIO in Haiku that I know of :)

Hm, the so-called AIO check is rather a pthreads check:

#include <pthread.h>
int main(void) { pthread_mutex_t lock; return 0; }

If that compiles, a working -lpthread is assumed. It's buggy in itself because it first sets AIOLIBS="", then compiles with unchanged empty $AIOLIBS and then sets AIOLIBS="-lpthread".

Quoted 4 lines
Quoted 2 lines

AIOLIBS is set to -lpthread but that is not available on Haiku.

Well we should have a pthread lib available though...

It's part of libroot.so, I thought, and thus referenced without extra linker arguments.

Quoted 4 lines

Another big issue that I mentionned earlier here is the widely used assumption that error codes are positive, which is not the case for BeOS and Haiku.
Not fixing this will result in a dangerous binary.

Thanks for the reminder. But that also reminds me, you wanted to supply a patch for that! :)

Andreas

#3 lore raw
Quoted 17 lines
Quoted 5 lines
Quoted 2 lines

Unresolved issues include that AIO is detected, and as a consequence

Then the test is buggy as we don't have AIO in Haiku that I know of :)

Hm, the so-called AIO check is rather a pthreads check:

#include <pthread.h>
int main(void) { pthread_mutex_t lock; return 0; }

If that compiles, a working -lpthread is assumed. It's buggy in itself
because it first sets AIOLIBS="", then compiles with unchanged empty $AIOLIBS and then sets AIOLIBS="-lpthread".

Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

AIOLIBS is set to -lpthread but that is not available on Haiku.

Well we should have a pthread lib available though...

It's part of libroot.so, I thought, and thus referenced without extra linker arguments.

Not sure we really want to keep it that way in Haiku then...

Quoted 7 lines
Quoted 4 lines

Another big issue that I mentionned earlier here is the widely used assumption that error codes are positive, which is not the case for BeOS and Haiku.
Not fixing this will result in a dangerous binary.

Thanks for the reminder. But that also reminds me, you wanted to supply a patch for that! :)

You can always beat me to it.

François.

#4 lore raw
In reply to Andreas Färber
Quoted 12 lines · Andreas Färber

Hm, the so-called AIO check is rather a pthreads check:

#include <pthread.h>
int main(void) { pthread_mutex_t lock; return 0; }

If that compiles, a working -lpthread is assumed. It's buggy in itself because it first sets AIOLIBS="", then compiles with unchanged empty $AIOLIBS and then sets AIOLIBS="-lpthread".

Quoted 3 lines
Quoted 1 line

AIOLIBS is set to -lpthread but that is not available on Haiku.

Well we should have a pthread lib available though...

Note that "-lpthread" is not even a portable way to get pthreads - even if it links successfully, it need not behave correctly. (Think of libc having different versions for threads and no-threads).

Maybe that's why Haiku doesn't have -lpthread.

-- Jamie

#5 lore raw
Quoted 12 lines
Quoted 11 lines · Andreas Färber

Hm, the so-called AIO check is rather a pthreads check:

#include <pthread.h>
int main(void) { pthread_mutex_t lock; return 0; }

If that compiles, a working -lpthread is assumed. It's buggy in itself
because it first sets AIOLIBS="", then compiles with unchanged empty
$AIOLIBS and then sets AIOLIBS="-lpthread".

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

AIOLIBS is set to -lpthread but that is not available on Haiku.

Well we should have a pthread lib available though...

Note that "-lpthread" is not even a portable way to get pthreads - even if it links successfully, it need not behave correctly. (Think of libc having different versions for threads and no-threads).

Note also some systems use -lpthreads and even others use a gcc flag - pthread...

Quoted 2 lines

Maybe that's why Haiku doesn't have -lpthread.

Most likely just to avoid spreading things outside of libroot.

Just like we don't have libm (it's in libroot, but noone ever checks for it... you wonder what they use autoconf for then).

François.

#6 lore raw
In reply to Andreas Färber
Quoted 12 lines · Andreas Färber

Hello,

Am 28.02.2009 um 18:08 schrieb François Revol:

Quoted 8 lines
Quoted 7 lines

We have undocumented --extra-cflags= and --extra-ldflags= options that
don't work as expected. They are ignored by all the configure tests, so it seems there is no direct equivalent to autoconf's CPPFLAGS to pass in additional header include paths. The OS_CFLAGS come closest, but they are ignored for some of the tests, too. Any preferences how to fix this?

Quoted 3 lines
Quoted 1 line

Ideally those shouldn't be needed anyway.

Not sure what exactly you're referring to, but both OS-specific as well as user-supplied settings may be necessary and should be working. Command line arguments are necessary to use self-compiled dependency libraries in their own prefix, for example.

Because any use of them usually signifies that someone is doing something wrong. For libraries that have non-standard install paths, we should be detecting it via pkg-config or the appropriate tool (like sdl-config). For libraries that don't support these (like zlib), the expectation is that they will be available in prefix.

Quoted 10 lines
Quoted 3 lines
Quoted 1 line

Unresolved issues include that AIO is detected, and as a consequence

Then the test is buggy as we don't have AIO in Haiku that I know of :)

Hm, the so-called AIO check is rather a pthreads check:

#include <pthread.h>
int main(void) { pthread_mutex_t lock; return 0; }

If that compiles, a working -lpthread is assumed. It's buggy in itself because it first sets AIOLIBS="", then compiles with unchanged empty $AIOLIBS and then sets AIOLIBS="-lpthread".

So we need to also make a pthread call. Like int main(void) { pthread_mutex_init; return 0; }

Quoted 3 lines
Quoted 1 line

Well we should have a pthread lib available though...

It's part of libroot.so, I thought, and thus referenced without extra linker arguments.

So we should try to compile against -lpthread and then try to compile against -lroot. Or better yet, does -pthread do the right thing on haiku? We could just switch to that.

Quoted 7 lines
Quoted 5 lines

Another big issue that I mentionned earlier here is the widely used assumption that error codes are positive, which is not the case for BeOS and Haiku.
Not fixing this will result in a dangerous binary.

Thanks for the reminder. But that also reminds me, you wanted to supply a patch for that! :)

Such a patch may be something ya'll have to maintain on your own. This has been discussed a lot in the past and I'm concerned that it's going to be too invasive.

Regards,

Anthony Liguori

Quoted 5 lines

Andreas

#7 lore raw
Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Well we should have a pthread lib available though...

It's part of libroot.so, I thought, and thus referenced without extra
linker arguments.

So we should try to compile against -lpthread and then try to compile against -lroot. Or better yet, does -pthread do the right thing on haiku? We could just switch to that.

-lroot is implied, not needed, so pthread is available without any flag.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

Another big issue that I mentionned earlier here is the widely used
assumption that error codes are positive, which is not the case for
BeOS and Haiku.
Not fixing this will result in a dangerous binary.

Quoted 8 lines
Quoted 2 lines

Thanks for the reminder. But that also reminds me, you wanted to supply a patch for that! :)

Such a patch may be something ya'll have to maintain on your own. This
has been discussed a lot in the past and I'm concerned that it's going
to be too invasive.

Too busy to start on it again.
There is nothing wrong with it if done cleanly. It might even help catch up mistakes.

François.

#8 lore raw
In reply to Anthony Liguori
Quoted 9 lines · Anthony Liguori
Quoted 7 lines
Quoted 5 lines

Another big issue that I mentionned earlier here is the widely used assumption that error codes are positive, which is not the case for BeOS and Haiku.
Not fixing this will result in a dangerous binary.

Thanks for the reminder. But that also reminds me, you wanted to supply a patch for that! :)

Such a patch may be something ya'll have to maintain on your own. This has been discussed a lot in the past and I'm concerned that it's going to be too invasive.

We could define a qemu_errno() which returns errno converted to positive numbers. While it will touch a lot of places, I don't think it can be considered invasive.

Signature · 1 line
error compiling committee.c: too many arguments to function
#9 lore raw
Quoted 17 lines
Quoted 8 lines · Anthony Liguori
Quoted 8 lines
Quoted 7 lines

Another big issue that I mentionned earlier here is the widely used
assumption that error codes are positive, which is not the case for
BeOS and Haiku.
Not fixing this will result in a dangerous binary.

Quoted 7 lines
Quoted 2 lines

Thanks for the reminder. But that also reminds me, you wanted to supply a patch for that! :)

Such a patch may be something ya'll have to maintain on your own. This has been discussed a lot in the past and I'm concerned that it's
going to be too invasive.

Quoted 5 lines

We could define a qemu_errno() which returns errno converted to positive
numbers. While it will touch a lot of places, I don't think it can be
considered invasive.

I'm used to using the opposite, RETERR() returning always negative codes from either errno or E*, and it works quite well.

I don't see the point in making stuff positive to return them negated.

Besides, one of the error codes in BeOS & Haiku will certainly overflow on 32bit (B_NO_MEMORY = B_GENERAL_ERROR_BASE = LONG_MIN).

François.

#10 lore raw
Quoted 7 lines · François Revol
Quoted 2 lines

We could define a qemu_errno() which returns errno converted to positive numbers. While it will touch a lot of places, I don't think it can be considered invasive.

I'm used to using the opposite, RETERR() returning always negative codes from either errno or E*, and it works quite well.

I don't see the point in making stuff positive to return them negated.

Changing errno to qemu_errno() is not an invasive change (at least, not much). Adding a RETERR() is, with significant chance for regressions.

Quoted 2 lines

Besides, one of the error codes in BeOS & Haiku will certainly overflow on 32bit (B_NO_MEMORY = B_GENERAL_ERROR_BASE = LONG_MIN).

qemu_errno() on Haiku could change it to something else.

Signature · 1 line
error compiling committee.c: too many arguments to function
#11 lore raw
Quoted 12 lines
Quoted 11 lines · François Revol
Quoted 7 lines

We could define a qemu_errno() which returns errno converted to positive
numbers. While it will touch a lot of places, I don't think it can
be
considered invasive.

I'm used to using the opposite, RETERR() returning always negative codes from either errno or E*, and it works quite well.

Quoted 8 lines
Quoted 3 lines

I don't see the point in making stuff positive to return them negated.

Changing errno to qemu_errno() is not an invasive change (at least, not
much). Adding a RETERR() is, with significant chance for regressions.

Except it's not enough.
It's _not_ only errno that is < 0, but the E* codes too. so all return -EFOO are indeed broken.

Another option is tu #define other codes from E* like QEINVAL, ... OSSv4 does this.

Anyway, I'm too busy to look into it yet, will see later.

François.