Bug 242134 - graphics/openimageio: fix build on powerpc64 elfv2
Summary: graphics/openimageio: fix build on powerpc64 elfv2
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Piotr Kubaj
URL:
Keywords: buildisok
Depends on:
Blocks:
 
Reported: 2019-11-21 10:03 UTC by Piotr Kubaj
Modified: 2020-01-27 22:02 UTC (History)
1 user (show)

See Also:
FreeBSD: maintainer-feedback+


Attachments
patch (1.57 KB, patch)
2019-11-21 10:03 UTC, Piotr Kubaj
FreeBSD: maintainer-approval?
Details | Diff
patch to support non-clang build of graphics/openimageio (504 bytes, text/plain)
2019-11-26 03:04 UTC, Shane
FreeBSD: maintainer-approval+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Kubaj freebsd_committer freebsd_triage 2019-11-21 10:03:08 UTC
Created attachment 209314 [details]
patch

libc++ doesn't define _LIBCPP_BIG_ENDIAN, check for __BIG_ENDIAN__ instead.
Comment 1 Automation User 2019-11-22 01:38:51 UTC
Build info is available at https://gitlab.com/swills/freebsd-ports/pipelines/97725797
Comment 2 Shane 2019-11-22 01:40:58 UTC
Actually looking into this more, clang defines __BIG_ENDIAN__ but not gcc. I have emailed oiio-dev to look into this further.

Both clang and gcc defines __BYTE_ORDER__ so we could use.

# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__


Which is similar to sys/endian.h which has

#define	_LITTLE_ENDIAN	1234	/* LSB first: i386, vax */
#define	_BIG_ENDIAN	4321	/* MSB first: 68000, ibm, net */
#define	_BYTE_ORDER	_LITTLE_ENDIAN

So you could use

#if _BYTE_ORDER == _BIG_ENDIAN
Comment 3 Shane 2019-11-26 03:04:19 UTC
Created attachment 209439 [details]
patch to support non-clang build of graphics/openimageio

Larry suggests wrapping the whole _LIBCPP_ALTERNATE_STRING_LAYOUT if block in a test for _LIBCPP_VERSION.

See https://github.com/OpenImageIO/oiio/pull/2415

A quick test where _LIBCPP_VERSION is never defined builds for me.
Comment 4 Piotr Kubaj freebsd_committer freebsd_triage 2019-11-26 11:26:45 UTC
(In reply to Shane from comment #3)
Now I get those errors:
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:805:8: error: redefinition of enumerator 'libcpp_string__long_mask'
enum { libcpp_string__long_mask = 0x1ul };
       ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:332:8: note: previous definition is here
enum { libcpp_string__long_mask = 0x1ul };
       ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:805:1: warning: declaration does not declare anything [-Wmissing-declarations]
enum { libcpp_string__long_mask = 0x1ul };
^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:810:5: error: redefinition of enumerator 'libcpp_string__min_cap'
    libcpp_string__min_cap
    ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:337:5: note: previous definition is here
    libcpp_string__min_cap
    ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:809:1: warning: declaration does not declare anything [-Wmissing-declarations]
enum {
^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:820:20: error: redefinition of 'TableRep'
ustring::TableRep::TableRep(string_view strref, size_t hash)
                   ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:348:20: note: previous definition is here
ustring::TableRep::TableRep(string_view strref, size_t hash)
                   ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:888:20: error: redefinition of '~TableRep'
ustring::TableRep::~TableRep()
                   ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:416:20: note: previous definition is here
ustring::TableRep::~TableRep()
                   ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:899:10: error: redefinition of 'make_unique'
ustring::make_unique(string_view strref)
         ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:427:10: note: previous definition is here
ustring::make_unique(string_view strref)
         ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:916:10: error: redefinition of 'getstats'
ustring::getstats(bool verbose)
         ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:444:10: note: previous definition is here
ustring::getstats(bool verbose)
         ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:940:10: error: redefinition of 'memory'
ustring::memory()
         ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:468:10: note: previous definition is here
ustring::memory()
         ^
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:184:29: error: no matching constructor for initialization of 'ustring::TableRep'
        return new (repmem) ustring::TableRep(str, hash);
                            ^                 ~~~~~~~~~
Comment 5 Shane 2019-11-27 10:22:39 UTC
(In reply to Piotr Kubaj from comment #4)

Something went wrong, ustring.cpp is 472 lines and the error says line 805. The ifdef in the patch should hide the erring enum lines if the llvm libcpp is not used. It looks like the #endif is being added too early.

The pull request is made against master, while the patch I added here is against 2.0.11 - they have different line numbers.
Comment 6 Piotr Kubaj freebsd_committer freebsd_triage 2019-12-25 19:18:43 UTC
(In reply to Shane from comment #5)
OK, after patching it manually:
/tmp/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:329:27: error: expected value in expression
#    if _LIBCPP_BIG_ENDIAN
                          ^
1 error generated.
Comment 7 Shane 2019-12-30 05:59:06 UTC
(In reply to Piotr Kubaj from comment #6)

So it should use #ifdef or #if defined() ?
Comment 8 Piotr Kubaj freebsd_committer freebsd_triage 2020-01-12 22:02:48 UTC
(In reply to Shane from comment #7)
Yes, changing if _LIBCPP_BIG_ENDIAN to ifdef _LIBCPP_BIG_ENDIAN makes it build. This is the only change that is needed (your patch is unnecessary).
Comment 9 commit-hook freebsd_committer freebsd_triage 2020-01-27 22:02:30 UTC
A commit references this bug:

Author: pkubaj
Date: Mon Jan 27 22:01:49 UTC 2020
New revision: 524447
URL: https://svnweb.freebsd.org/changeset/ports/524447

Log:
  graphics/openimageio: fix build on powerpc64 elfv2

  Change if to explicit ifdef to prevent:
  /wrkdirs/usr/ports/graphics/openimageio/work/oiio-Release-2.0.10/src/libutil/ustring.cpp:328:27: error: expected value in expression
  #    if _LIBCPP_BIG_ENDIAN

  PR:		242134
  Approved by:	FreeBSD@ShaneWare.Biz (maintainer timeout)

Changes:
  head/graphics/openimageio/files/patch-src_libutil_ustring.cpp