OSX is one of our primary build platforms, and we build it daily there. posix_memalign exists in 10.6. Your fix needs to be restricted to 10.5, as we cannot rely on undocumented OS behaviors.
The fix for the Makefile is unnecessary and subtly harmful. With your change, "make -j5" no longer builds the dependencies before evaluating the makefile. There's a bit of arcane magic there about OBJDIR not being set correctly the first time, IIRC.
Regards
Christophe
On 28 août 2011, at 07:31, Marc Coram wrote:
> Hi Christophe,
>
> I was trying to build xlr on my OS X machine. I needed to make a couple changes for it to compile. I'm not sure if these just reflect vagaries of my system or what.
> The first is one call to OBJDIR in Makefile.rules (it had an extra / in this instance, but not others; I do not understand this; perhaps there's a more uniform fix).
>
> ; git diff
> diff --git a/xlr/Makefile.rules b/xlr/Makefile.rules
> index e064a66..c5e87a3 100644
> --- a/xlr/Makefile.rules
> +++ b/xlr/Makefile.rules
> @@ -192,5 +192,5 @@ endif
>
> # Include dependencies from current directory
> ifdef SOURCES
> --include $(OBJDIR)/Makefile.depend
> +-include $(OBJDIR)Makefile.depend
> endif
> diff --git a/xlr/gc.cpp b/xlr/gc.cpp
> index eb90373..b44f90b 100644
> --- a/xlr/gc.cpp
> +++ b/xlr/gc.cpp
> @@ -316,10 +316,16 @@ void *TypeAllocator::operator new(size_t size)
> result = __mingw_aligned_malloc(size, PTR_MASK+1);
> if (!result)
> throw std::bad_alloc();
> +#else
> +#ifdef CONFIG_MACOSX // OS_X doesn't "need" alignment (c.f. http://stackoverflo
> w.com/questions/196329/osx-lacks-memalign)
> + result = malloc(size);
> + if (!result)
> + throw std::bad_alloc();
> #else // Real operating systems
> if (posix_memalign(&result, PTR_MASK+1, size))
> throw std::bad_alloc();
> -#endif // WINDOWS or real operating system
> +#endif // MACOSX or real operating system
> +#endif // WINDOWS or not
> return result;
> }
>
>
> The fix for the Makefile is unnecessary
To be more specific : I believe it is unecessary. I would appreciate if you could tell me why you thought it was required...
Also, I tried to find a way to detect 10.5 vs 10.6, and the only way I found was to use a MacOSX specific header, Availability.h. If there's a better way, I'd like to learn about it.
Thanks
Christophe