* [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* Re: [BUG] [PATCH] Undefined symbols: "_posix_memalign" on Mac OS X
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
1 sibling, 0 replies; 5+ messages in thread
From: Filip Sneppe @ 2011-04-23 9:42 UTC (permalink / raw)
To: fio
On Sat, Apr 23, 2011 at 5:57 AM, Filip Sneppe <filip.sneppe@gmail.com> wrote:
> 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.
>
For completeness I should say that this patch was wrong
(you can see I'm not a developer).
The function required:
*ptr = malloc(align * size);
for my workaround to work.
Best regards,
Filip
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG] [PATCH] Undefined symbols: "_posix_memalign" on Mac OS X
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
1 sibling, 1 reply; 5+ messages in thread
From: Bruce Cran @ 2011-04-23 10:06 UTC (permalink / raw)
To: Filip Sneppe; +Cc: fio
On Sat, 23 Apr 2011 05:57:26 +0200
Filip Sneppe <filip.sneppe@gmail.com> wrote:
> (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.
I think Apple have added it in 10.6, but obviously fio needs to run on
older versions too.
--
Bruce Cran
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG] [PATCH] Undefined symbols: "_posix_memalign" on Mac OS X
2011-04-23 10:06 ` Bruce Cran
@ 2011-04-25 11:42 ` Jens Axboe
2011-04-25 18:51 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2011-04-25 11:42 UTC (permalink / raw)
To: Bruce Cran; +Cc: Filip Sneppe, fio
On 2011-04-23 12:06, Bruce Cran wrote:
> On Sat, 23 Apr 2011 05:57:26 +0200
> Filip Sneppe <filip.sneppe@gmail.com> wrote:
>
>> (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.
>
> I think Apple have added it in 10.6, but obviously fio needs to run on
> older versions too.
Solaris has a helper, too. Does 10.6 have memalign or another
alternative function?
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG] [PATCH] Undefined symbols: "_posix_memalign" on Mac OS X
2011-04-25 11:42 ` Jens Axboe
@ 2011-04-25 18:51 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2011-04-25 18:51 UTC (permalink / raw)
To: Bruce Cran; +Cc: Filip Sneppe, fio
On 2011-04-25 13:42, Jens Axboe wrote:
> On 2011-04-23 12:06, Bruce Cran wrote:
>> On Sat, 23 Apr 2011 05:57:26 +0200
>> Filip Sneppe <filip.sneppe@gmail.com> wrote:
>>
>>> (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.
>>
>> I think Apple have added it in 10.6, but obviously fio needs to run on
>> older versions too.
>
> Solaris has a helper, too. Does 10.6 have memalign or another
> alternative function?
We only use it for io_u allocations outside of places where we do have
posix_memalign() support. I just added a simpler malloc() wrapper that
aligns for that purpose, so we don't use posix_memalign() in the core
code anymore.
--
Jens Axboe
^ 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