Flexible I/O Tester development
 help / color / mirror / Atom feed
* [BUG] [PATCH] Undefined symbols: "_posix_memalign" on Mac OS X
@ 2011-04-23  3:57 Filip Sneppe
  2011-04-23  9:42 ` Filip Sneppe
  2011-04-23 10:06 ` Bruce Cran
  0 siblings, 2 replies; 5+ messages in thread
From: Filip Sneppe @ 2011-04-23  3:57 UTC (permalink / raw)
  To: fio

[-- Attachment #1: Type: text/plain, Size: 1630 bytes --]

Hi,

(I am not subscribed to this list, nor am I a Unix developer).

I wanted to give fio a try on my OS X 10.5.8 machine, but
this is the error I received when compiling:

    CC helpers.o
    CC engines/posixaio.o
    DEP depend
    CC fio
Undefined symbols:
  "_posix_memalign", referenced from:
      _thread_main in fio.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [fio] Error 1

After some googling, I learned that OS X doesn't
provide _posix_memalign, and that apparently it's not
needed on this platform. I "fixed" my compile problem with the
attached patch. You may find it useful to write a better fix for this.

Best regards and thanks for providing this tool,
Filip

diff -urN fio/Makefile fio-patched/Makefile
--- fio/Makefile        2011-04-23 05:40:54.000000000 +0200
+++ fio-patched/Makefile        2011-04-23 05:39:13.000000000 +0200
@@ -46,7 +46,7 @@
   CPPFLAGS += -D_LARGE_FILES -D__ppc__
 endif
 ifeq ($(UNAME), Darwin)
-  SOURCE += helpers.c engines/posixaio.c
+  SOURCE += helpers.c darwin.c engines/posixaio.c
   LIBS  += -lpthread -ldl
 endif
 ifneq (,$(findstring CYGWIN,$(UNAME)))
diff -urN fio/darwin.c fio-patched/darwin.c
--- fio/darwin.c        1970-01-01 01:00:00.000000000 +0100
+++ fio-patched/darwin.c        2011-04-23 05:38:54.000000000 +0200
@@ -0,0 +1,15 @@
+#include <stdlib.h>
+#include <errno.h>
+#include "compiler/compiler.h"
+
+/*
+ * Darwin doesn't have posix_memalign(), provide a private
+ * weak alternative
+ */
+int __weak posix_memalign(void **ptr, size_t align, size_t size)
+{
+       if (*ptr)
+               return 0;
+
+       return ENOMEM;
+}

[-- Attachment #2: fio.darwin.patch --]
[-- Type: application/octet-stream, Size: 871 bytes --]

diff -urN fio/Makefile fio-patched/Makefile
--- fio/Makefile	2011-04-23 05:40:54.000000000 +0200
+++ fio-patched/Makefile	2011-04-23 05:39:13.000000000 +0200
@@ -46,7 +46,7 @@
   CPPFLAGS += -D_LARGE_FILES -D__ppc__
 endif
 ifeq ($(UNAME), Darwin)
-  SOURCE += helpers.c engines/posixaio.c
+  SOURCE += helpers.c darwin.c engines/posixaio.c
   LIBS	 += -lpthread -ldl
 endif
 ifneq (,$(findstring CYGWIN,$(UNAME)))
diff -urN fio/darwin.c fio-patched/darwin.c
--- fio/darwin.c	1970-01-01 01:00:00.000000000 +0100
+++ fio-patched/darwin.c	2011-04-23 05:38:54.000000000 +0200
@@ -0,0 +1,15 @@
+#include <stdlib.h>
+#include <errno.h>
+#include "compiler/compiler.h"
+
+/*
+ * Darwin doesn't have posix_memalign(), provide a private
+ * weak alternative
+ */
+int __weak posix_memalign(void **ptr, size_t align, size_t size)
+{
+	if (*ptr)
+		return 0;
+
+	return ENOMEM;
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-25 18:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-23  3:57 [BUG] [PATCH] Undefined symbols: "_posix_memalign" on Mac OS X Filip Sneppe
2011-04-23  9:42 ` Filip Sneppe
2011-04-23 10:06 ` Bruce Cran
2011-04-25 11:42   ` Jens Axboe
2011-04-25 18:51     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox