Created attachment 209314 [details] patch libc++ doesn't define _LIBCPP_BIG_ENDIAN, check for __BIG_ENDIAN__ instead.
Build info is available at https://gitlab.com/swills/freebsd-ports/pipelines/97725797
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
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.
(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); ^ ~~~~~~~~~
(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.
(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.
(In reply to Piotr Kubaj from comment #6) So it should use #ifdef or #if defined() ?
(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).
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