Bug 285977 - devel/highway fails to build in poudriere
Summary: devel/highway fails to build in poudriere
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: riscv Any
: --- Affects Only Me
Assignee: Jan Beich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-09 07:49 UTC by rdunkle
Modified: 2025-04-11 17:17 UTC (History)
1 user (show)

See Also:
jbeich: maintainer-feedback+
jbeich: merge-quarterly+


Attachments
poudriere build log (4.50 KB, application/x-compressed)
2025-04-09 07:49 UTC, rdunkle
no flags Details
highway build on riscv64 hardware (1.98 KB, application/x-compressed)
2025-04-09 12:03 UTC, rdunkle
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description rdunkle 2025-04-09 07:49:28 UTC
Created attachment 259404 [details]
poudriere build log

this is compiling for riscv64
I see this error on poudriere (qemu riscv) and poudriere cross compiling on amd64

/wrkdirs/usr/ports/devel/highway/work/highway-1.2.0/hwy/detect_targets.h:750:2: error: "Logic error: best baseline should be included in dynamic targets"
  750 | #error "Logic error: best baseline should be included in dynamic targets"
Comment 1 rdunkle 2025-04-09 12:03:03 UTC
Created attachment 259411 [details]
highway build on riscv64 hardware
Comment 2 Jan Beich freebsd_committer freebsd_triage 2025-04-09 21:41:36 UTC
Do you run poudriere under qemu-system-riscv64 instead of qemu-riscv64-static? When cross compiling QEMU_EMULATING=1 is defined unless ABI is natively supported (sysctl kern.supported_archs).
Did you build poudriere jail without native-xtools (-X flag)? CC/CXX/LD/etc should contain /nxb-bin. Emulating Clang/LLD via qemu-user is far less robust than using it as a cross compiler.

emulators/qemu-user-static hasn't been updated for years, so the build doesn't reach devel/highway here:

$ poudriere jail -cj 142riscv64 -a riscv.riscv64 -v 14.2-STABLE
$ poudriere bulk -rtk -j 142riscv64 devel/highway
[...]
[00:13:50] Failed ports: devel/gettext-tools:build
[00:13:50] Skipped ports: devel/cmake-core devel/highway devel/jsoncpp devel/meson@py311 devel/ninja devel/p5-Locale-gettext devel/p5-Locale-libintl devel/py-build@py311 devel/py-flit-core@py311 devel/py-installer@py311 devel/py-packaging@py311 devel/py-pyproject-hooks@py311 devel/py-setuptools@py311 devel/py-wheel044@py311 devel/py-wheel@py311 dns/libidn2 lang/python311 misc/help2man print/texinfo security/rhash

Anyway, I don't have riscv64 hardware, https://www.freebsd.org/internal/machines/ lacks riscv64 and riscv64 is Tier2 thus not required to be supported by port maintainers (aka "patches welcome"). See also https://docs.freebsd.org/en/articles/committers-guide/#_tier_2_developmental_and_niche_architectures
Comment 3 Jan Beich freebsd_committer freebsd_triage 2025-04-09 21:51:22 UTC
> hwy/detect_targets.h:750:2: error: "Logic error: best baseline should be included in dynamic targets"

Try building highway from Git checkout. HWY_ARCH_RVV should be defined when __riscv is but maybe your compiler is broken or there's an upstream bug.

$ cc -target riscv64-unknown-freebsd15.0 -dM -E -</dev/null | fgrep __riscv
#define __riscv 1
#define __riscv_a 2001000
#define __riscv_arch_test 1
[...]
Comment 4 rdunkle 2025-04-10 11:17:34 UTC
This is on actual ricv64 hardware.  
Did a git clone of google-highway.
I am not familiar with cmake.
Here is what I see:
 cc -target riscv64-unknown-freebsd15.0 -dM -E -</dev/null | fgrep __riscv
#define __riscv 1
#define __riscv_a 2001000
#define __riscv_arch_test 1
#define __riscv_atomic 1
#define __riscv_c 2000000
#define __riscv_cmodel_medlow 1
#define __riscv_compressed 1
#define __riscv_d 2002000
#define __riscv_div 1
#define __riscv_f 2002000
#define __riscv_fdiv 1
#define __riscv_flen 64
#define __riscv_float_abi_double 1
#define __riscv_fsqrt 1
#define __riscv_i 2001000
#define __riscv_m 2000000
#define __riscv_misaligned_avoid 1
#define __riscv_mul 1
#define __riscv_muldiv 1
#define __riscv_xlen 64
#define __riscv_zicsr 2000000
#define __riscv_zmmul 1000000

-----------------------------------------
~richd/tmp/highway/hwy# cmake ..


~richd/tmp/highway/hwy# cmake --build . --config Release

--8<-- snip -- 8< --snip--

      |                            ^
/home/richd/tmp/highway/hwy/base.h:140:28: note: expanded from macro 'HWY_PRAGMA'
  140 | #define HWY_PRAGMA(tokens) _Pragma(#tokens)
      |                            ^
<scratch space>:130:8: note: expanded from here
  130 |  clang attribute pop
      |        ^
1 warning generated.
[ 17%] Building CXX object CMakeFiles/hwy_contrib.dir/contrib/thread_pool/topology.cc.o
[ 17%] Linking CXX static library libhwy_contrib.a
[ 17%] Built target hwy_contrib
[ 17%] Building CXX object CMakeFiles/hwy_test.dir/tests/test_util.cc.o
[ 18%] Linking CXX static library libhwy_test.a
[ 18%] Built target hwy_test
[ 18%] Building CXX object CMakeFiles/hwy_list_targets.dir/tests/list_targets.cc.o
[ 19%] Linking CXX executable hwy_list_targets
Compiler: Clang 1901
Config: emu128:0 scalar:0 static:0 all_attain:0 is_test:0
Have: constexpr_lanes:0 runtime_dispatch:0 auxv:1f16 type:0/ops0 bf16 type:0/ops0
Compiled HWY_TARGETS:   RVV
HWY_ATTAINABLE_TARGETS: RVV EMU128
HWY_BASELINE_TARGETS:   RVV EMU128
HWY_STATIC_TARGET:      RVV
HWY_BROKEN_TARGETS:     Unknown Unknown Unknown Unknown
HWY_DISABLED_TARGETS:
Current CPU supports:   RVV EMU128 SCALAR
[ 19%] Built target hwy_list_targets
[ 20%] Building CXX object CMakeFiles/hwy_benchmark.dir/examples/benchmark.cc.o
[ 20%] Linking CXX executable examples/hwy_benchmark
[ 20%] Built target hwy_benchmark
[ 20%] Building CXX object CMakeFiles/hwy_profiler_example.dir/examples/profiler_example.cc.o
[ 21%] Linking CXX executable examples/hwy_profiler_example
[ 21%] Built target hwy_profiler_example
[ 21%] Building CXX object googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 21%] Linking CXX static library ../../lib/libgtest.a
[ 21%] Built target gtest
[ 22%] Building CXX object googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[ 22%] Linking CXX static library ../../lib/libgtest_main.a
[ 22%] Built target gtest_main
[ 22%] Building CXX object CMakeFiles/abort_test.dir/abort_test.cc.o
[ 22%] Linking CXX executable tests/abort_test
CMake Error at /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake:132 (message):
  Error running test executable.

    Path: '/home/richd/tmp/highway/hwy/tests/abort_test'
    Working directory: '/home/richd/tmp/highway/hwy'
    Result: Illegal instruction
    Output:


Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake:275 (gtest_discover_tests_impl)


*** Error code 1
make[2]: *** tests/abort_test removed

Stop.
make[2]: stopped making "CMakeFiles/abort_test.dir/build" in /home/richd/tmp/highway/hwy
*** Error code 1

Stop.
make[1]: stopped making "all" in /home/richd/tmp/highway/hwy
*** Error code 1

Stop.
make: stopped making "default_target" in /home/richd/tmp/highway/hwy
Comment 5 Jan Beich freebsd_committer freebsd_triage 2025-04-10 16:47:52 UTC
(In reply to rdunkle from comment #4)
> cc -target riscv64-unknown-freebsd15.0 -dM -E -</dev/null | fgrep __riscv

Don't pass -target riscv64-unknown-freebsd15.0 when testing natively. Sometimes native and cross targets differ e.g., FreeBSD armv7 has NEON but armv7-unknown-freebsd15.0 doesn't.

> CMake Error at /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake:132 (message):
>   Error running test executable.

Re-run CMake with either -DBUILD_TESTING=OFF (default in the port) or -DHWY_SYSTEM_GTEST=ON (passed in the port during "make test").

> [ 17%] Linking CXX static library libhwy_contrib.a

Looks like the lib built fine (libhwy_contrib depends on libhwy). Can you confirm 1.2.0 tag fails (in case the port itself is bugged)? If so bisect to find out which commit fixed it for the port to cherry-pick.

# Example inverse bisecting (doesn't "skip" unrelated errors)
$ git bisect start --term-bad=fixed --term-good=broken origin 1.2.0
$ git bisect run sh -c 'b=/tmp/hwy_build; rm -fr $b && cmake -G Ninja -B $b -DBUILD_TESTING=OFF && ! cmake --build $b'
$ git bisect log
Comment 6 rdunkle 2025-04-11 10:18:13 UTC
exactly correct- tag 1.2.0 is broken

here is the bisect log:
# fixed: [4434594c4e43452358425c38526b267a6df6ffdd] Make abort.h/cc header only, refs #2114
# broken: [457c891775a7397bdb0376bb1031e6e027af1c48] remove HWY_HAS_INCLUDE - mishandled by clang
git bisect start '--term-bad=fixed' '--term-good=broken' 'origin' '1.2.0'
# fixed: [87848c46fd1339a4c63df88870ce29cf1ea8298d] add warning if TSC is not invariant
git bisect fixed 87848c46fd1339a4c63df88870ce29cf1ea8298d
# fixed: [15dccd5a51cb3a085275543d94ae045f1e4fb434] Merge pull request #2337 from johnplatts:hwy_sort_test_co
mpile_fix_100124
git bisect fixed 15dccd5a51cb3a085275543d94ae045f1e4fb434
# fixed: [3c01e17947efd261aa0d34d1785cdfbb2c5cb8ec] Merge pull request #2273 from johnplatts:hwy_mul_flt_by_p
ow2_071624
git bisect fixed 3c01e17947efd261aa0d34d1785cdfbb2c5cb8ec
# fixed: [76f5baa8615313c52e73d4cb3a110240a505294a] Merge pull request #2244 from johnplatts:jep_hwy_ubuntu24
04_workflow_061124_2
git bisect fixed 76f5baa8615313c52e73d4cb3a110240a505294a
# fixed: [d06ebe0710de156f69342066f9b030e421aba3cb] opt-in to reduce set of MSVC targets. Fixes #2220
git bisect fixed d06ebe0710de156f69342066f9b030e421aba3cb
# broken: [b6e1402767ff9e12915df9876546700f3eb7e9ce] Merge pull request #2223 from johnplatts:hwy_nearestint_
053024
git bisect broken b6e1402767ff9e12915df9876546700f3eb7e9ce
# fixed: [b609655d158d41b6218b7751014b11065fd54b8d] clarify ZEN4 enabling
git bisect fixed b609655d158d41b6218b7751014b11065fd54b8d
# fixed: [309d2709e95fc2a3f3a0fd9da2e1dcc087b46817] Internal
git bisect fixed 309d2709e95fc2a3f3a0fd9da2e1dcc087b46817
# fixed: [c95cc0237d2f7a0f5ca5dc3fb4b5961b2b1dcdfc] Disable RVV runtime dispatch. Fixes #2227
git bisect fixed c95cc0237d2f7a0f5ca5dc3fb4b5961b2b1dcdfc
# first fixed commit: [c95cc0237d2f7a0f5ca5dc3fb4b5961b2b1dcdfc] Disable RVV runtime dispatch. Fixes #2227
~
Comment 7 commit-hook freebsd_committer freebsd_triage 2025-04-11 14:18:12 UTC
A commit in branch main references this bug:

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

commit eabed8b1aa83e6b1965101c8cdd662f6a40ed7b7
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2025-04-11 14:04:50 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2025-04-11 14:16:43 +0000

    devel/highway: unbreak build on riscv64

    In file included from hwy/nanobenchmark.cc:28:
    In file included from hwy/timer-inl.h:26:
    In file included from hwy/highway.h:21:
    hwy/detect_targets.h:750:2: error: "Logic error: best baseline should be included in dynamic targets"
      750 | #error "Logic error: best baseline should be included in dynamic targets"
          |  ^

    PR:             285977
    Reported by:    Rich Dunkle
    Tested by:      Rich Dunkle

 devel/highway/Makefile | 3 +++
 devel/highway/distinfo | 2 ++
 2 files changed, 5 insertions(+)
Comment 8 commit-hook freebsd_committer freebsd_triage 2025-04-11 14:19:13 UTC
A commit in branch 2025Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=072b5cdbca9150c2a1a69ff2cdc06d7329386ee3

commit 072b5cdbca9150c2a1a69ff2cdc06d7329386ee3
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2025-04-11 14:04:50 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2025-04-11 14:18:13 +0000

    devel/highway: unbreak build on riscv64

    In file included from hwy/nanobenchmark.cc:28:
    In file included from hwy/timer-inl.h:26:
    In file included from hwy/highway.h:21:
    hwy/detect_targets.h:750:2: error: "Logic error: best baseline should be included in dynamic targets"
      750 | #error "Logic error: best baseline should be included in dynamic targets"
          |  ^

    PR:             285977
    Reported by:    Rich Dunkle
    Tested by:      Rich Dunkle

    (cherry picked from commit eabed8b1aa83e6b1965101c8cdd662f6a40ed7b7)

 devel/highway/Makefile | 3 +++
 devel/highway/distinfo | 2 ++
 2 files changed, 5 insertions(+)
Comment 9 Jan Beich freebsd_committer freebsd_triage 2025-04-11 14:25:16 UTC
Can you confirm the port builds fine then close the bug? Upstream commit mentions Clang 16-18 but -CURRENT has Clang 19.
Comment 10 rdunkle 2025-04-11 15:18:17 UTC
built OK on native riscv64 hardware: visionfive2

built OK on amd64 poudriere with riscv64 jail (qemu-user-static):
poudriere jail -c -a riscv.riscv64 -x -j riscv-15-current -m ftp -v 15.0-CURRENT

looks good
--Thank you!