[BUG] [PATCH] Undefined symbols: "_posix_memalign" on Mac OS X

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: fio.darwin.patch
Description: Binary data


[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux