Opened 6 years ago

Closed 6 years ago

#57630 closed defect (fixed)

blosc @ 1.14.4: build fails due to undefined symbols on OS X Leopard PPC

Reported by: SerpentChris (Chris Calderon) Owned by: stromnov (Andrey Stromnov)
Priority: Normal Milestone:
Component: ports Version: 2.5.4
Keywords: leopard tiger Cc:
Port: blosc

Description

Build seems to go fine until it gets here:

:info:build /usr/bin/gcc-4.2 -pipe -Os -DNDEBUG -I/opt/local/include -arch ppc -mmacosx-version-min=10.5 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/opt/local/lib -Wl,-headerpad_max_install_names CMakeFiles/bench.dir/bench.c.o  -o bench -Wl,-rpath,/opt/local/lib ../blosc/libblosc.1.14.4.dylib /opt/local/lib/liblz4.dylib /opt/local/lib/libz.dylib /opt/local/lib/libzstd.dylib 
:info:build Undefined symbols:
:info:build   "_posix_memalign", referenced from:
:info:build       _do_bench in bench.c.o
:info:build       _do_bench in bench.c.o
:info:build       _do_bench in bench.c.o
:info:build ld: symbol(s) not found
:info:build collect2: ld returned 1 exit status
:info:build make[2]: *** [bench/bench] Error 1

Attachments (1)

main.log (212.6 KB) - added by SerpentChris (Chris Calderon) 6 years ago.

Download all attachments as: .zip

Change History (10)

Changed 6 years ago by SerpentChris (Chris Calderon)

Attachment: main.log added

comment:1 Changed 6 years ago by kencu (Ken)

yep, there is no posix_memalign on 10.5. I've been thinking of adding it to the macports-legacy port, and in fact I have written up the replacement already, but it didn't always seem to work as I wanted it to, so I'm still sitting on it for now.

Is this a port you really want on 10.5 PPC? You can use valloc instead, to get a block of memory aligned on a page boundary.

It would take a minor patch to the source to make it use valloc instead of posix_memalign, but it's a fairly trivial fix.

comment:2 Changed 6 years ago by jmroot (Joshua Root)

Cc: stromnov@… removed
Owner: changed from stromnov@… to stromnov

comment:3 Changed 6 years ago by mf2k (Frank Schima)

Keywords: leopard powerpc added

comment:4 Changed 6 years ago by kencu (Ken)

Keywords: tiger added; powerpc removed
Summary: bloc @ 1.14.4: build fails due to undefined symbols on OS X Leopard PPCblosc @ 1.14.4: build fails due to undefined symbols on OS X Leopard PPC

comment:5 Changed 6 years ago by kencu (Ken)

I put together a little patch for this. You can check this out here if you want <https://github.com/kencu/LeopardPorts/tree/master/archivers/blosc>. If it works for you as well, we can put together a PR for it.

Last edited 6 years ago by kencu (Ken) (previous) (diff)

comment:6 Changed 6 years ago by SerpentChris (Chris Calderon)

Your patch doesn't check the alignment argument the way it is supposed to. Shouldn't a posix_memalign look more like this?

#include <stdlib.h>
#include <errno.h>

const size_t _SIZE_OF_VOID_PTR = sizeof(void *);

bool
check_power_of_two(int val)
{
  while(val&1 == 0){
    val >>= 1;
  }
  return (val == 1);
}

int
posix_memalign(void **memptr, size_t alignment, size_t size)
{
  // First check alignment
  div_t result = divmod(alignment, _SIZE_OF_VOID_PTR);
  if(!(result.rem == 0 && check_power_of_two(result.quot))){
    *memptr = NULL;
    return EINVAL;
  }
  // Do nothing if size is 0
  if(size == 0){
    *memptr = NULL;
    return 0;
  }

  errno = 0;
  *memptr = valloc(size);
  // If valloc errors, it will set errno to ENOMEM.
  // Folks online don't like posix_memalign to set errno though.
  // Also, if valloc errors it will return NULL which is OK.
  if(errno == ENOMEM){
    errno = 0;
    return ENOMEM;
  }

  return 0;
}

The problem with this (besides the fact that I haven't tested it yet ;) is that the result might not be aligned properly if the alignment is greater than the page size, but I bet that is typically not the case anyway.

comment:7 Changed 6 years ago by SerpentChris (Chris Calderon)

Oh, and the reason I want blosc on Leopard is to install py37-pandas. I'm trying to get a fully modern scipy config running so I can help family members with college homework.

comment:8 Changed 6 years ago by kencu (Ken)

you're right, I skipped an alignment check.

I like your extra bits. I think we can massage a bit more and find a way to find something acceptible. If alignment is <= 16 we can just use malloc, as macos guarantees 16 byte alignment at all times. That will likely save a few K of memory.

There is a very complete replacement available called dlmalloc <ftp://g.oswego.edu/pub/misc/malloc.c> with a very liberal license. I wasn't clear how to make it only cough up posix_memalign without all the other memory functions trampling us. I was looking at that one if we could use it.

For blosc, it turns out the author has previously supported macs < 10.6 in the code; he's just recently added a new benchmark.c that doesn't . You can skip the build of benchmark.c by turning off tests. Then you have what we had before. My PR does that. So you can use that right now if you want...

btw blosc with or without the posix_memalign patch will pass nearly all tests -- high 90s -- and i suspect it always did not get 100% on 10.5 PPC as the tested part of the code has not changed.

If you have interest, please consider helping add to the macports_legacy project to help keep your PPC mac alive!

Last edited 6 years ago by kencu (Ken) (previous) (diff)

comment:9 Changed 6 years ago by kencu (Ken)

Resolution: fixed
Status: assignedclosed

In 591337f116ff9ae2ae20fab954605b943fcf7c30/macports-ports (master):

blosc: disable tests and benchmarks

not installed anyway
don't easily work
newer benchmarks use posix_memalign which fails on
some older systems

closes: #57630

Note: See TracTickets for help on using tickets.