Bug 278722 - graphics/bgfx: build error on i386 with CPUTYPE=nehalem and newer
Summary: graphics/bgfx: build error on i386 with CPUTYPE=nehalem and newer
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Some People
Assignee: Vladimir Druzenko
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-03 17:38 UTC by Vladimir Druzenko
Modified: 2024-05-19 15:47 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (yuri)


Attachments
Fix build error on i386 with CPUTYPE=nehalem and newer (481 bytes, patch)
2024-05-03 17:38 UTC, Vladimir Druzenko
vvd: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-03 17:38:31 UTC
Created attachment 250356 [details]
Fix build error on i386 with CPUTYPE=nehalem and newer

Tested on 13.2 i386 with CPUTYPE=nehalem and newer:

/wrkdirs/usr/ports/graphics/bgfx/work/bgfx.cmake-1.127.8725-465/bimg/3rdparty/astc-encoder/source/astcenc_vecmathlib_sse_4.h:1313:26: error: use of undeclared identifier '_mm_popcnt_u64'; did you mean '_mm_popcnt_u32'?
        return static_cast<int>(_mm_popcnt_u64(v));
                                ^~~~~~~~~~~~~~
                                _mm_popcnt_u32
/usr/lib/clang/14.0.5/include/popcntintrin.h:33:1: note: '_mm_popcnt_u32' declared here
_mm_popcnt_u32(unsigned int __A)
^
1 error generated.
===============================
This patch work for me:

--- bimg/3rdparty/astc-encoder/source/astcenc_vecmathlib_sse_4.h.orig
+++ bimg/3rdparty/astc-encoder/source/astcenc_vecmathlib_sse_4.h
@@ -1309,5 +1309,7 @@ ASTCENC_SIMD_INLINE int popcount(uint64_t v)
 {
 #if defined(__MINGW32__)
        return static_cast<int>(__builtin_popcountll(v));
+#elif defined(__FreeBSD__) && !defined(__x86_64__)
+       return static_cast<int>(_mm_popcnt_u32(static_cast<uint32_t>(v)));
 #else
        return static_cast<int>(_mm_popcnt_u64(v));
 #endif // defined(__MINGW32__)
===============================
Reported upstream: https://github.com/bkaradzic/bgfx/pull/2929#issuecomment-2093377116
Comment 1 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-18 09:52:49 UTC
Maintainer timeout > 14 days.
Comment 2 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-18 10:23:32 UTC
Real upstream bug report: https://github.com/ARM-software/astc-encoder/issues/468
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-05-18 14:10:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=656401a10b46a87dcc5f62b884da4ea4e10e74b2

commit 656401a10b46a87dcc5f62b884da4ea4e10e74b2
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2024-05-18 14:04:08 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-05-18 14:04:08 +0000

    graphics/bgfx: fix build on i386 with CPUTYPE=nehalem and newer

    Build error:
    /wrkdirs/usr/ports/graphics/bgfx/work/bgfx.cmake-1.127.8725-465/bimg/3rdparty/astc-encoder/source/astcenc_vecmathlib_sse_4.h:1313:26: error: use of undeclared identifier '_mm_popcnt_u64'; did you mean '_mm_popcnt_u32'?
            return static_cast<int>(_mm_popcnt_u64(v));
                                    ^~~~~~~~~~~~~~
                                    _mm_popcnt_u32
    /usr/lib/clang/14.0.5/include/popcntintrin.h:33:1: note: '_mm_popcnt_u32' declared here
    _mm_popcnt_u32(unsigned int __A)
    ^
    1 error generated.

    Upstream issues:
    https://github.com/ARM-software/astc-encoder/issues/468
    https://github.com/bkaradzic/bgfx/pull/2929#issuecomment-2093377116

    PR:             278722
    Approved by:    yuri (maintainer timeout, 15 days)

 ...rty_astc-encoder_source_astcenc__vecmathlib__sse__4.h (new) | 10 ++++++++++
 1 file changed, 10 insertions(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-05-19 15:47:55 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=86ab24e19ebb6f64d34ef2fd10d5185e1c3c742a

commit 86ab24e19ebb6f64d34ef2fd10d5185e1c3c742a
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2024-05-19 15:37:58 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-05-19 15:37:58 +0000

    graphics/bgfx: correction for fix build on i386 with CPUTYPE=nehalem and newer

    Previous patch truncating the value to 32-bits before taking the popcount.
    Upstream made correct patch:
    https://github.com/ARM-software/astc-encoder/issues/468#issuecomment-2119169136
    This patch will be included in next release of the astc-encoder 4.9.
    Also we can apply this patch to misc/astc-encoder (4.7 in ports).

    PR:     278722
    Fixes:  656401a (fix build on i386 with CPUTYPE=nehalem and newer)

 ...mg_3rdparty_astc-encoder_source_astcenc__vecmathlib__sse__4.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)