Opened 3 years ago

Last modified 21 months ago

#63467 assigned enhancement

opencv4: Add a universal variant

Reported by: MarkCallow (Mark Callow) Owned by: stromnov (Andrey Stromnov)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: mascguy (Christopher Nielsen), cooljeanius (Eric Gallager)
Port: opencv4

Description

I am trying to sudo port install openimageio +universal. After a while it fails with

Error: Cannot install openimageio for the archs 'arm64 x86_64' because
Error: its dependency opencv4 does not build for the required archs by default
Error: and does not have a universal variant.
Error: Follow https://guide.macports.org/#project.tickets if you believe there
is a bug.

I need to use openimageio in a tool I distribute and I need to make an Apple Silicon version of that tool so please make it possible to build an arm64 version of opencv4.

Change History (9)

comment:1 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to stromnov
Status: newassigned
Summary: opencv4 has no universal variantopencv4: Add a universal variant
Type: defectenhancement

It is already possible to build opencv4 on arm64. But what is not possible, as you note, is to build it universal. The port deliberately disables the universal variant. This has been in the port ever since it was added. Perhaps it was found not to work, or perhaps it works fine and was just never tested. If you like, you can try to remove that line, and if it works, or if it doesn't work and you can figure out what else needs to be changed, you could submit the fix to us.

comment:2 Changed 3 years ago by MarkCallow (Mark Callow)

you can try to remove that line,

From where?

comment:3 Changed 3 years ago by mascguy (Christopher Nielsen)

Cc: mascguy added

comment:4 Changed 3 years ago by MarkCallow (Mark Callow)

I found the Portfile in my installation in /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/graphics/opencv4 and changed universal_variant no to universal_variant yes. The build fails while compiling gmake.

:info:build /usr/bin/clang -DHAVE_CONFIG_H -I. -I../src   -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk  -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -arch arm64 -arch x86_64 -c -o fnmatch.o fnmatch.c
:info:build In file included from basename-lgpl.c:23:
:info:build In file included from ./string.h:41:
:info:build In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/string.h:152:
:info:build /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/_types/_ssize_t.h:31:33: error: cannot combine with previous 'type-name' declaration specifier
:info:build typedef __darwin_ssize_t        ssize_t;
:info:build                                 ^
:info:build ../src/config.h:1079:17: note: expanded from macro 'ssize_t'
:info:build #define ssize_t int
:info:build                 ^
:info:build In file included from fnmatch.c:34:
:info:build In file included from ./string.h:41:
:info:build In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/string.h:152:
:info:build /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/_types/_ssize_t.h:31:33: error: cannot combine with previous 'type-name' declaration specifier
:info:build typedef __darwin_ssize_t        ssize_t;
:info:build                                 ^
:info:build ../src/config.h:1079:17: note: expanded from macro 'ssize_t'
:info:build #define ssize_t int
:info:build                 ^
:info:build 1 error generated.

I am surprised because I expect gmake is a dependency of quite a few ports. The issue most likely is that there is a config macro controlling some cpu-specific behaviour but since both architectures are being compiled in a single call to clang only one set of macros can be defined. For universal builds to work cpu-specific behaviour needs to be controlled using compiler pre-defined macros.

It looks like I will have to abandon plans for a universal build and make 2 cpu-specific builds instead.

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

if you install gmake by itself first, you should be ok:

sudo port clean gmake
sudo port install gmake

then try your universal build of opencv4

MacPorts idiosyncracy

comment:6 Changed 3 years ago by MarkCallow (Mark Callow)

Thanks for the suggestion @kencu. I did that and gmake was successfully installed but when I try sudo port install opencv4 +universal again, port still tries to build gmake and it fails with the same error I described.

It makes sense that what you say should work since gmake is, presumably, just needed for building opencv4 so no need for a universal variant of it. This is the second time where I am getting a different result from you in this regard. Is there perhaps some MacPorts config setting that I need to change? Note that I do NOT have +universal set in /opt/local/etc/macports/variants.conf.

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

well I am unable to presently explain it, indeed.

The line installs_libs no in the gmake Portfile is supposed to stop MacPorts from asking for it to be rebuilt universal.

You can try specifically forcing opencv to ignore the architecture of gmake by adding this to the opencv Portfile:

depends_skip_archcheck-append gmake

but you ideally should not be needing to do this.

Puzzled...

comment:8 Changed 23 months ago by hmeine (Hans Meine)

FWIW, I did *not* have the gmake problem (i.e., gmake @4.3_0+universal was implicitly built and installed as a dependency just fine), but jemalloc does not install due to a problem with two conflicting -config scripts (#65213).

comment:9 Changed 21 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added
Note: See TracTickets for help on using tickets.