Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#60624 closed defect (fixed)

freeimage @3.18.0 build failure - 'posix_memalign' was not declared in this scope

Reported by: programmingkidx Owned by: kencu (Ken)
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: legacy-os tiger leopard snowleopard Cc:
Port: freeimage

Description

Freeimage 3.18.0 fails to build on Mac OS 10.4.11 (x86). Compilation stops because of this error:

Source/OpenEXR/IlmImf/ImfFrameBuffer.cpp -o Source/OpenEXR/IlmImf/ImfFrameBuffer.o
:info:build make: *** [Source/OpenEXR/IlmImf/ImfFastHuf.o] Error 1
:info:build make: *** Waiting for unfinished jobs....
:info:build In file included from Source/OpenEXR/IlmImf/ImfDwaCompressorSimd.h:48,
:info:build                  from Source/OpenEXR/IlmImf/ImfDwaCompressor.cpp:131:
:info:build Source/OpenEXR/IlmImf/ImfSystemSpecific.h: In function 'void* Imf_2_2::EXRAllocAligned(size_t, size_t)':
:info:build Source/OpenEXR/IlmImf/ImfSystemSpecific.h:66: error: 'posix_memalign' was not declared in this scope
:info:build Source/OpenEXR/IlmImf/ImfDwaCompressor.cpp: In member function 'int Imf_2_2::DwaCompressor::uncompress(const char*, int, Imath_2_2::Box2i, const char*&)':
:info:build Source/OpenEXR/IlmImf/ImfDwaCompressor.cpp:2412: warning: comparison is always false due to limited range of data type
:info:build make: *** [Source/OpenEXR/IlmImf/ImfDwaCompressor.o] Error 1

Change History (10)

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

hello again. posix_memalign is one of the common functios replaced by the legacy-support system -- in fact, was one of the very first ones I added. <https://github.com/macports/macports-legacy-support>

To add it to a port's build is quite easy. You add a single line to the Portfile, and that usually fixes it, like this:

<https://github.com/macports/macports-ports/blob/53165cdc831872f370fbd8374480986fd640cd04/devel/libuv/Portfile#L5>.

to edit the portfile, you find it with

port file freeimage

and then edit it with some editor you like.

Please report back if that works. If it does work, and you want to make a PR, that would be extremely great.

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

Keywords: legacy tiger leopard snowleopard added; freeimage posix_memalign removed
Port: Freeimage 3.18.0 removed
Summary: freeimage build failure - 'posix_memalign' was not declared in this scopefreeimage @3.18.0 build failure - 'posix_memalign' was not declared in this scope

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

Port: freeimage added

comment:4 Changed 4 years ago by mf2k (Frank Schima)

Keywords: legacy-os added; legacy removed

comment:5 Changed 4 years ago by programmingkidx

I did the change that you wanted. I added "PortGroup legacysupport 1.0" right below the "PortSystem" text. This did appear to eliminate the posix_memalign problem.

The next problem I encountered were with literals that had really large values in the file ImfFastHuf.cpp. This was solved by adding "ULL" to the right side of the literals.

The current problem I have are these errors:

info:build Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp: In constructor 'Imf_2_2::CpuId::CpuId()':
:info:build Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp:51: error: can't find a register in class 'BREG' while reloading 'asm'
:info:build Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp:51: error: can't find a register in class 'BREG' while reloading 'asm'
:info:build Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp:51: error: 'asm' operand has impossible constraints
:info:build Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp:51: error: 'asm' operand has impossible constraints

This is the code that causes the error:

#if defined(IMF_HAVE_SSE2) &&  defined(__GNUC__)

    // Helper functions for gcc + SSE enabled
    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
    {
        __asm__ __volatile__ (
            "cpuid"
            : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) 
            : /* Input   */ "a"(n)
            : /* Clobber */);
    }

My x86 assembly language is kind of rusty. Anyone have a clue how to fix this problem?

Last edited 4 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

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

The easiest thing to do here is to try compiling the software with a newer compiler. I can't quite tell which compiler is being used right now, but your options are to bump the compiler up to gcc7 or clang-3.4 or newer.

sudo port -v install MYPORT configure.compiler=macports-gcc-7

is the easiest way to try out different compilers. There is a big list of compiler specs here you can find to try out clang compilers you might have installed, etc.

UsingTheRightCompiler

Last edited 4 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

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

There is also this stackoverflow post <https://stackoverflow.com/questions/4010069/problem-on-mac-cant-find-a-register-in-class-breg-while-reloading-asm> that looks to be relevant to the specific error.

-- edit -- although I don't like their solution. I'd try a newer compiler instead:

and indeed, gcc-7 saves the day:

$ port -v installed freeimage
The following ports are currently installed:
  freeimage @3.18.0_0 (active) platform='darwin 8' archs='i386' date='2020-06-11T19:23:02-0700'

so we will need to blacklist gcc-4.2 and ilk in the portfile (unless someone really cares to figure out how to make this compile with gcc-4.2, which I most certainly do NOT, as life is short and we all have better things to do than that.).

compiler.blacklist-append *gcc-3.* *gcc-4.*

and base is still a bit broken on older systems, so it will probably automatically call in clang-3.4, which might or might not actually work depending on c++11 ....

My patch for base is here attachment:ticket:59717:patch-portconfigure-properly-support-less-than-snowleopard.diff which you can use on your own system if you like (I do).

Last edited 4 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

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

Owner: set to kencu
Resolution: fixed
Status: newclosed

In 5542644dc957bf0bf0f9d67998ab38b35e00e9b6/macports-ports (master):

freeimage: fix build with older systems

use legacysupport for posix_memalign
use newer compilers on intel for cpuid.h

closes: #60624

comment:9 Changed 4 years ago by programmingkidx

Thank you so much for the info :)

I just added this to the top of the portfile:

PortGroup           legacysupport 1.0
compiler.blacklist-append *gcc-3.* *gcc-4.*

This made clang++-mp-3.4 to be used. It worked.

Last edited 4 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

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

excellent. If you're building things on Tiger, you will come across similar issues many times.

This process here is how you fix them.

Note: See TracTickets for help on using tickets.