Skip to contentSkip to conversation

simpletrace: Thread-safe tracing

PATCH In review Stefan Hajnoczi 4 participants 11 messages Feb 28, 2011 – Mar 23, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 simpletrace: Thread-safe tracing

Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe. There is no check to prevent them being enabled so people sometimes learn this the hard way.

This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers. A writeout thread empties the trace buffer when threshold fill levels are reached. Should the writeout thread be unable to keep up with trace generation, records will simply be dropped.

Each time events are dropped a special record is written to the trace file indicating how many events were dropped. The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count).

---
v2:
* Add 'dropped' event so we know when events were lost.

 docs/tracing.txt       |    5 -
 scripts/simpletrace.py |    3 +-
 simpletrace.c          |  309 ++++++++++++++++++++++++++++++++----------------
 simpletrace.h          |    8 ++
 vl.c                   |   16 +--
 5 files changed, 219 insertions(+), 122 deletions(-)
docs/tracing.txt +0 -5
index a6cc56f..f15069c 100644
@@ -141,11 +141,6 @@ source tree.  It may not be as powerful as platform-specific or third-party
 trace backends but it is portable.  This is the recommended trace backend
 unless you have specific needs for more advanced backends.
 
-Warning: the "simple" backend is not thread-safe so only enable trace events
-that are executed while the global mutex is held.  Much of QEMU meets this
-requirement but some utility functions like qemu_malloc() or thread-related
-code cannot be safely traced using the "simple" backend.
-
 ==== Monitor commands ====
 
 * info trace
scripts/simpletrace.py +2 -1
index 9fe3dda..2ad5699 100755
@@ -16,6 +16,7 @@ import inspect
 header_event_id = 0xffffffffffffffff
 header_magic    = 0xf2b177cb0aa429b4
 header_version  = 0
+dropped_event_id = 0xfffffffffffffffe
 
 trace_fmt = '=QQQQQQQQ'
 trace_len = struct.calcsize(trace_fmt)
@@ -28,7 +29,7 @@ def parse_events(fobj):
         """Extract argument names from a parameter list."""
         return tuple(arg.split()[-1].lstrip('*') for arg in args.split(','))
 
-    events = {}
+    events = {dropped_event_id: ('dropped', 'count')}
     event_num = 0
     for line in fobj:
         m = event_re.match(line.strip())
simpletrace.c +205 -104

397 lines not on this page · raw message

simpletrace.h +8 -0
index 2f44ed3..3a5bd9f 100644
@@ -15,6 +15,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 
+#ifdef CONFIG_SIMPLE_TRACE
 typedef uint64_t TraceEventID;
 
 typedef struct {
@@ -36,5 +37,12 @@ void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf);
 void st_set_trace_file_enabled(bool enable);
 bool st_set_trace_file(const char *file);
 void st_flush_trace_buffer(void);
+void st_init(const char *file);
+#else
+static inline void st_init(const char *file)
+{
+    /* Do nothing */
+}
+#endif /* !CONFIG_SIMPLE_TRACE */
 
 #endif /* SIMPLETRACE_H */
vl.c +4 -12
index b436952..5e007a7 100644
@@ -47,9 +47,6 @@
 #include <dirent.h>
 #include <netdb.h>
 #include <sys/select.h>
-#ifdef CONFIG_SIMPLE_TRACE
-#include "trace.h"
-#endif
 
 #ifdef CONFIG_BSD
 #include <sys/stat.h>
@@ -159,6 +156,7 @@ int main(int argc, char **argv)
 #include "slirp/libslirp.h"
 
 #include "trace.h"
+#include "simpletrace.h"
 #include "qemu-queue.h"
 #include "cpus.h"
 #include "arch_init.h"
@@ -1941,10 +1939,8 @@ int main(int argc, char **argv, char **envp)
     const char *incoming = NULL;
     int show_vnc_port = 0;
     int defconfig = 1;
-
-#ifdef CONFIG_SIMPLE_TRACE
     const char *trace_file = NULL;
-#endif
+
     atexit(qemu_run_exit_notifiers);
     error_set_progname(argv[0]);
 
@@ -2770,6 +2766,8 @@ int main(int argc, char **argv, char **envp)
     }
     loc_set_none();
 
+    st_init(trace_file);
+
     /* If no data_dir is specified then try to find it relative to the
        executable path.  */
     if (!data_dir) {
@@ -2780,12 +2778,6 @@ int main(int argc, char **argv, char **envp)
         data_dir = CONFIG_QEMU_DATADIR;
     }
 
-#ifdef CONFIG_SIMPLE_TRACE
-    /*
-     * Set the trace file name, if specified.
-     */
-    st_set_trace_file(trace_file);
-#endif
     /*
      * Default to max_cpus = smp_cpus, in case the user doesn't
      * specify a max_cpus value.
Signature · 1 line
1.7.2.3
#1 lore raw

Am 28.02.2011 um 10:38 schrieb Stefan Hajnoczi:

Quoted 18 lines

Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe. There is no check to prevent them being enabled so people sometimes learn this the hard way.

This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers. A writeout thread empties the trace buffer when threshold fill levels are reached. Should the writeout thread be unable to keep up with trace generation, records will simply be dropped.

Each time events are dropped a special record is written to the trace file indicating how many events were dropped. The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count).

---
v2:
* Add 'dropped' event so we know when events were lost.

[...]

Quoted 2 lines

+ __sync_synchronize(); /* read memory barrier before accessing
record */

Getting this at HEAD on Darwin/ppc64:

CC simpletrace.o
/Users/andreas/QEMU/qemu/simpletrace.c: In function ‘get_trace_record’:
/Users/andreas/QEMU/qemu/simpletrace.c:81: warning: implicit declaration of function ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: nested extern declaration of ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c: In function ‘trace’:
/Users/andreas/QEMU/qemu/simpletrace.c:161: warning: implicit declaration of function ‘__sync_fetch_and_add’ /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: nested extern declaration of ‘__sync_fetch_and_add’ [...]
LINK qemu-nbd
Undefined symbols:
"___sync_fetch_and_add", referenced from:
_trace in simpletrace.o
"___sync_synchronize", referenced from:
_get_trace_record in simpletrace.o
_trace in simpletrace.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [qemu-nbd] Error 1

Haven't investigated further yet.

Andreas

#2 lore raw
Quoted 51 lines · Andreas Färber

Am 28.02.2011 um 10:38 schrieb Stefan Hajnoczi:

Quoted 18 lines

Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe.  There is no check to prevent them being enabled so people sometimes learn this the hard way.

This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers.  A writeout thread empties the trace buffer when threshold fill levels are reached.  Should the writeout thread be unable to keep up with trace generation, records will simply be dropped.

Each time events are dropped a special record is written to the trace file indicating how many events were dropped.  The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count).

---
v2:
* Add 'dropped' event so we know when events were lost.

[...]

Quoted 3 lines

+    __sync_synchronize(); /* read memory barrier before accessing record */

Getting this at HEAD on Darwin/ppc64:

 CC    simpletrace.o
/Users/andreas/QEMU/qemu/simpletrace.c: In function ‘get_trace_record’:
/Users/andreas/QEMU/qemu/simpletrace.c:81: warning: implicit declaration of function ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: nested extern declaration of ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c: In function ‘trace’:
/Users/andreas/QEMU/qemu/simpletrace.c:161: warning: implicit declaration of function ‘__sync_fetch_and_add’ /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: nested extern declaration of ‘__sync_fetch_and_add’
[...]
 LINK  qemu-nbd
Undefined symbols:
 "___sync_fetch_and_add", referenced from:
     _trace in simpletrace.o
 "___sync_synchronize", referenced from:
     _get_trace_record in simpletrace.o
     _trace in simpletrace.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [qemu-nbd] Error 1

Quoted 1 line

Haven't investigated further yet.

/me shakes his fist at Apple gcc!

These are gcc builtins, I believe the were added in gcc 4.1:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins

Which version of gcc are you running?

We can replace them with equivalent library functions or inline assembly code. Here's what we need:
Read memory barrier
Write memory barrier
Atomic load and increment

CCed Alex and Anthony who may have thoughts on adding these atomic ops to QEMU.

Stefan

#3 lore raw
Quoted 61 lines · Stefan Hajnoczi
Quoted 51 lines · Andreas Färber

Am 28.02.2011 um 10:38 schrieb Stefan Hajnoczi:

Quoted 18 lines

Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe.  There is no check to prevent them being enabled so people sometimes learn this the hard way.

This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers.  A writeout thread empties the trace buffer when threshold fill levels are reached.  Should the writeout thread be unable to keep up with trace generation, records will simply be dropped.

Each time events are dropped a special record is written to the trace file indicating how many events were dropped.  The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count).

---
v2:
* Add 'dropped' event so we know when events were lost.

[...]

Quoted 3 lines

+    __sync_synchronize(); /* read memory barrier before accessing record */

Getting this at HEAD on Darwin/ppc64:

 CC    simpletrace.o
/Users/andreas/QEMU/qemu/simpletrace.c: In function ‘get_trace_record’:
/Users/andreas/QEMU/qemu/simpletrace.c:81: warning: implicit declaration of function ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: nested extern declaration of ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c: In function ‘trace’:
/Users/andreas/QEMU/qemu/simpletrace.c:161: warning: implicit declaration of function ‘__sync_fetch_and_add’ /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: nested extern declaration of ‘__sync_fetch_and_add’
[...]
 LINK  qemu-nbd
Undefined symbols:
 "___sync_fetch_and_add", referenced from:
     _trace in simpletrace.o
 "___sync_synchronize", referenced from:
     _get_trace_record in simpletrace.o
     _trace in simpletrace.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [qemu-nbd] Error 1

Quoted 1 line

Haven't investigated further yet.

/me shakes his fist at Apple gcc!

These are gcc builtins, I believe the were added in gcc 4.1:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins

Which version of gcc are you running?

Quoted 7 lines

We can replace them with equivalent library functions or inline assembly code.  Here's what we need:
Read memory barrier
Write memory barrier
Atomic load and increment

CCed Alex and Anthony who may have thoughts on adding these atomic ops to QEMU.

Thinking about it more, the way I'd like to solve this (and make
simpletrace work on Windows too!) is to go ahead and use glib threads
and atomics. I don't want to be in the business of writing
portability wrappers for different OSes and architectures, and glib
already does this:
file:///usr/share/doc/libglib2.0-doc/glib/glib-Atomic-Operations.html#g-atomic-int-exchange-and-add

Stefan

#4 lore raw
Quoted 68 lines · Stefan Hajnoczi
Quoted 67 lines · Stefan Hajnoczi
Quoted 51 lines · Andreas Färber

Am 28.02.2011 um 10:38 schrieb Stefan Hajnoczi:

Quoted 18 lines

Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe.  There is no check to prevent them being enabled so people sometimes learn this the hard way.

This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers.  A writeout thread empties the trace buffer when threshold fill levels are reached.  Should the writeout thread be unable to keep up with trace generation, records will simply be dropped.

Each time events are dropped a special record is written to the trace file indicating how many events were dropped.  The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count).

---
v2:
* Add 'dropped' event so we know when events were lost.

[...]

Quoted 3 lines

+    __sync_synchronize(); /* read memory barrier before accessing record */

Getting this at HEAD on Darwin/ppc64:

 CC    simpletrace.o
/Users/andreas/QEMU/qemu/simpletrace.c: In function ‘get_trace_record’:
/Users/andreas/QEMU/qemu/simpletrace.c:81: warning: implicit declaration of function ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: nested extern declaration of ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c: In function ‘trace’:
/Users/andreas/QEMU/qemu/simpletrace.c:161: warning: implicit declaration of function ‘__sync_fetch_and_add’ /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: nested extern declaration of ‘__sync_fetch_and_add’
[...]
 LINK  qemu-nbd
Undefined symbols:
 "___sync_fetch_and_add", referenced from:
     _trace in simpletrace.o
 "___sync_synchronize", referenced from:
     _get_trace_record in simpletrace.o
     _trace in simpletrace.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [qemu-nbd] Error 1

Quoted 1 line

Haven't investigated further yet.

/me shakes his fist at Apple gcc!

These are gcc builtins, I believe the were added in gcc 4.1:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins

Which version of gcc are you running?

We can replace them with equivalent library functions or inline assembly code.  Here's what we need:
Read memory barrier
Write memory barrier
Atomic load and increment

Quoted 8 lines
Quoted 1 line

CCed Alex and Anthony who may have thoughts on adding these atomic ops to QEMU.

Thinking about it more, the way I'd like to solve this (and make
simpletrace work on Windows too!) is to go ahead and use glib threads
and atomics.  I don't want to be in the business of writing
portability wrappers for different OSes and architectures, and glib
already does this:
file:///usr/share/doc/libglib2.0-doc/glib/glib-Atomic-Operations.html#g-atomic-int-exchange-and-add

Corrected URI:
http://library.gnome.org/devel/glib/2.28/glib-Atomic-Operations.html#g-atomic-int-exchange-and-add

Stefan

#5 lore raw
Quoted 78 lines · Stefan Hajnoczi
Quoted 68 lines · Stefan Hajnoczi
Quoted 67 lines · Stefan Hajnoczi
Quoted 51 lines · Andreas Färber

Am 28.02.2011 um 10:38 schrieb Stefan Hajnoczi:

Quoted 18 lines

Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe. There is no check to prevent them being enabled so people sometimes learn this the hard way.

This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers. A writeout thread empties the trace buffer when threshold fill levels are reached. Should the writeout thread be unable to keep up with trace generation, records will simply be dropped.

Each time events are dropped a special record is written to the trace file indicating how many events were dropped. The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count).

---
v2:
* Add 'dropped' event so we know when events were lost.

[...]

Quoted 3 lines

+ __sync_synchronize(); /* read memory barrier before accessing record
*/

Getting this at HEAD on Darwin/ppc64:

CC simpletrace.o
/Users/andreas/QEMU/qemu/simpletrace.c: In function ‘get_trace_record’:
/Users/andreas/QEMU/qemu/simpletrace.c:81: warning: implicit declaration of function ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: nested extern declaration of ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c: In function ‘trace’:
/Users/andreas/QEMU/qemu/simpletrace.c:161: warning: implicit declaration of function ‘__sync_fetch_and_add’ /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: nested extern declaration of ‘__sync_fetch_and_add’
[...]
LINK qemu-nbd
Undefined symbols:
"___sync_fetch_and_add", referenced from:
_trace in simpletrace.o
"___sync_synchronize", referenced from:
_get_trace_record in simpletrace.o
_trace in simpletrace.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [qemu-nbd] Error 1

Quoted 1 line

Haven't investigated further yet.

/me shakes his fist at Apple gcc!

These are gcc builtins, I believe the were added in gcc 4.1:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins

Which version of gcc are you running?

We can replace them with equivalent library functions or inline assembly code. Here's what we need:
Read memory barrier
Write memory barrier
Atomic load and increment

Quoted 8 lines
Quoted 1 line

CCed Alex and Anthony who may have thoughts on adding these atomic ops to QEMU.

Thinking about it more, the way I'd like to solve this (and make
simpletrace work on Windows too!) is to go ahead and use glib threads
and atomics. I don't want to be in the business of writing
portability wrappers for different OSes and architectures, and glib
already does this:
file:///usr/share/doc/libglib2.0-doc/glib/glib-Atomic-Operations.html#g-atomic-int-exchange-and-add

Quoted 2 lines

Corrected URI:
http://library.gnome.org/devel/glib/2.28/glib-Atomic-Operations.html#g-atomic-int-exchange-and-add

Yeah, either that or adding a configure check for the availability of atomic operations. If the glib folks did go through the work already, I agree that it'd be nice to reuse that work though.

Alex

#6 lore raw
In reply to Stefan Hajnoczi

Am 23.03.2011 um 08:39 schrieb Stefan Hajnoczi:

Quoted 54 lines

On Tue, Mar 22, 2011 at 11:52 PM, Andreas Färber <[email protected]

Quoted 53 lines

wrote:
Am 28.02.2011 um 10:38 schrieb Stefan Hajnoczi:

Quoted 18 lines

Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe. There is no check to prevent them being enabled so people sometimes learn this the hard way.

This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers. A writeout thread empties the trace buffer when threshold fill levels are reached. Should the writeout thread be unable to keep up with trace generation, records will simply be dropped.

Each time events are dropped a special record is written to the trace file indicating how many events were dropped. The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count).

---
v2:
* Add 'dropped' event so we know when events were lost.

[...]

Quoted 4 lines

+ __sync_synchronize(); /* read memory barrier before accessing
record
*/

Getting this at HEAD on Darwin/ppc64:

CC simpletrace.o
/Users/andreas/QEMU/qemu/simpletrace.c: In function ‘get_trace_record’:
/Users/andreas/QEMU/qemu/simpletrace.c:81: warning: implicit declaration of function ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: nested extern declaration of ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c: In function ‘trace’:
/Users/andreas/QEMU/qemu/simpletrace.c:161: warning: implicit declaration of function ‘__sync_fetch_and_add’ /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: nested extern declaration of ‘__sync_fetch_and_add’
[...]
LINK qemu-nbd
Undefined symbols:
"___sync_fetch_and_add", referenced from:
_trace in simpletrace.o
"___sync_synchronize", referenced from:
_get_trace_record in simpletrace.o
_trace in simpletrace.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [qemu-nbd] Error 1

Quoted 3 lines
Quoted 1 line

Haven't investigated further yet.

/me shakes his fist at Apple gcc!

Well, due to ppc I'm stuck at Leopard. Could be different on Snow Leopard...

Quoted 4 lines

These are gcc builtins, I believe the were added in gcc 4.1:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins

Which version of gcc are you running?

$ gcc --version
powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Andreas

#7 lore raw
Quoted 5 lines · Andreas Färber

Am 23.03.2011 um 08:39 schrieb Stefan Hajnoczi:

Quoted 4 lines

These are gcc builtins, I believe the were added in gcc 4.1:

http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins

Quoted 7 lines
Quoted 1 line

Which version of gcc are you running?

$ gcc --version
powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Okay, that explains it.

Stefan

#8 lore raw
In reply to Andreas Färber

Am 23.03.2011 um 21:42 schrieb Andreas Färber:

Quoted 65 lines

Am 23.03.2011 um 08:39 schrieb Stefan Hajnoczi:

Quoted 54 lines

On Tue, Mar 22, 2011 at 11:52 PM, Andreas Färber <[email protected]

Quoted 53 lines

wrote:
Am 28.02.2011 um 10:38 schrieb Stefan Hajnoczi:

Quoted 18 lines

Trace events outside the global mutex cannot be used with the simple trace backend since it is not thread-safe. There is no check to prevent them being enabled so people sometimes learn this the hard way.

This patch restructures the simple trace backend with a ring buffer suitable for multiple concurrent writers. A writeout thread empties the trace buffer when threshold fill levels are reached. Should the writeout thread be unable to keep up with trace generation, records will simply be dropped.

Each time events are dropped a special record is written to the trace file indicating how many events were dropped. The event ID is 0xfffffffffffffffe and its signature is dropped(uint32_t count).

---
v2:
* Add 'dropped' event so we know when events were lost.

[...]

Quoted 4 lines

+ __sync_synchronize(); /* read memory barrier before
accessing record
*/

Getting this at HEAD on Darwin/ppc64:

CC simpletrace.o
/Users/andreas/QEMU/qemu/simpletrace.c: In function ‘get_trace_record’:
/Users/andreas/QEMU/qemu/simpletrace.c:81: warning: implicit declaration of function ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c:81: warning: nested extern declaration of ‘__sync_synchronize’ /Users/andreas/QEMU/qemu/simpletrace.c: In function ‘trace’:
/Users/andreas/QEMU/qemu/simpletrace.c:161: warning: implicit declaration of function ‘__sync_fetch_and_add’ /Users/andreas/QEMU/qemu/simpletrace.c:161: warning: nested extern declaration of ‘__sync_fetch_and_add’
[...]
LINK qemu-nbd
Undefined symbols:
"___sync_fetch_and_add", referenced from:
_trace in simpletrace.o
"___sync_synchronize", referenced from:
_get_trace_record in simpletrace.o
_trace in simpletrace.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [qemu-nbd] Error 1

Quoted 3 lines
Quoted 1 line

Haven't investigated further yet.

/me shakes his fist at Apple gcc!

Well, due to ppc I'm stuck at Leopard. Could be different on Snow Leopard...

Quoted 3 lines

These are gcc builtins, I believe the were added in gcc 4.1:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins

Quoted 7 lines
Quoted 1 line

Which version of gcc are you running?

$ gcc --version
powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Indeed it compiles with --cc=gcc-4.2 --host-cc=gcc-4.2:

powerpc-apple-darwin9-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5577) Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Still I would generally advise against requiring the latest and greatest GCC.
Unfortunately compiling GLib from scratch (e.g., on Haiku) can be a lot of work, too. The Mono folks abandoned it again in favor of their own stripped-down GLib-compatible eglib implementation.

Andreas

#9 lore raw
Quoted 2 lines · Andreas Färber

Still I would generally advise against requiring the latest and greatest GCC.

Yes, I think requiring 4.1 was too aggressive.

Quoted 3 lines

Unfortunately compiling GLib from scratch (e.g., on Haiku) can be a lot of work, too. The Mono folks abandoned it again in favor of their own stripped-down GLib-compatible eglib implementation.

Interesting, I haven't found much on eglib except the github repo which says:

"The purpose of eglib is to be an X11-licensed subset of glib that can be used with Mono when the Mono runtime is explicitly relicensed under a different license by Novell."

If that's the main reason to create the library, then I'm happy to stick with glib.

Stefan

#10 lore raw

Am 23.03.2011 um 22:05 schrieb Stefan Hajnoczi:

Quoted 6 lines

On Wed, Mar 23, 2011 at 8:58 PM, Andreas Färber <[email protected]

Quoted 4 lines

wrote:
Unfortunately compiling GLib from scratch (e.g., on Haiku) can be a lot of work, too. The Mono folks abandoned it again in favor of their own stripped-down GLib-compatible eglib implementation.

Quoted 8 lines

Interesting, I haven't found much on eglib except the github repo which says:

"The purpose of eglib is to be an X11-licensed subset of glib that can be used with Mono when the Mono runtime is explicitly relicensed under a different license by Novell."

If that's the main reason to create the library, then I'm happy to stick with glib.

I don't think so. That licensing issue was probably related to some game platform... certainly no reason to abondon LGPL, given the proximity to the GNOME community.

I believe there used to be no ppc64 and Win64 support in vanilla GLib (haven't checked ppc for a long time though). The e was supposed to be for embedded, i.e. for code size reduction - it's linked statically into Mono.

Just cautioning that GLib is really great when you have the packages on YourFavorite distro, but it can be a pain to deal with in some corner cases.

Andreas