Bug 270955 - graphics/libjxl: fails to build when base built WITH_LLVM_BINUTILS
Summary: graphics/libjxl: fails to build when base built WITH_LLVM_BINUTILS
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks: 258872
  Show dependency treegraph
 
Reported: 2023-04-20 17:54 UTC by Ed Maste
Modified: 2023-04-27 18:21 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2023-04-20 17:54:59 UTC
From exp-run PR258872
https://pkg-status.freebsd.org/gohan05/data/mainamd64PR258872-default/2023-04-17_22h40m57s/logs/errors/libjxl-0.8.1.log

[  5% 15/259] /usr/bin/c++ -DHWY_DISABLED_TARGETS="(HWY_SVE|HWY_SVE2|HWY_SVE_256|HWY_SVE2_128|HWY_RVV)" -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\" -I/wrkdirs/usr/ports/graphics/libjxl/work/libjxl-0.8.1/third_party/sjpeg/src -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -fno-rtti -funwind-tables -Xclang -mrelax-all -Xclang -mconstructor-aliases -fno-omit-frame-pointer   -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -DNDEBUG -O2 -std=c++11 -flto=thin -fPIC -fmacro-prefix-map=/wrkdirs/usr/ports/graphics/libjxl/work/libjxl-0.8.1=. -Wno-builtin-macro-redefined -Wall -MD -MT third_party/sjpeg/CMakeFiles/sjpeg.dir/src/yuv_convert.cc.o -MF third_party/sjpeg/CMakeFiles/sjpeg.dir/src/yuv_convert.cc.o.d -o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/yuv_convert.cc.o -c /wrkdirs/usr/ports/graphics/libjxl/work/libjxl-0.8.1/third_party/sjpeg/src/yuv_convert.cc
[  6% 16/259] : && /usr/local/bin/cmake -E rm -f third_party/sjpeg/libsjpeg.a && "/usr/bin/llvm-ar" cr third_party/sjpeg/libsjpeg.a  third_party/sjpeg/CMakeFiles/sjpeg.dir/src/bit_writer.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/colors_rgb.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/dichotomy.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/enc.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/fdct.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/headers.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/jpeg_tools.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/score_7.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/yuv_convert.cc.o && "CMAKE_CXX_COMPILER_RANLIB-NOTFOUND" third_party/sjpeg/libsjpeg.a && :
FAILED: third_party/sjpeg/libsjpeg.a 
: && /usr/local/bin/cmake -E rm -f third_party/sjpeg/libsjpeg.a && "/usr/bin/llvm-ar" cr third_party/sjpeg/libsjpeg.a  third_party/sjpeg/CMakeFiles/sjpeg.dir/src/bit_writer.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/colors_rgb.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/dichotomy.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/enc.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/fdct.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/headers.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/jpeg_tools.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/score_7.cc.o third_party/sjpeg/CMakeFiles/sjpeg.dir/src/yuv_convert.cc.o && "CMAKE_CXX_COMPILER_RANLIB-NOTFOUND" third_party/sjpeg/libsjpeg.a && :
/bin/sh: CMAKE_CXX_COMPILER_RANLIB-NOTFOUND: not found
ninja: build stopped: subcommand failed.
*** Error code 1
Comment 1 Ed Maste freebsd_committer freebsd_triage 2023-04-20 17:59:53 UTC
misc/astc-encoder fails the same way:
CMAKE_CXX_COMPILER_RANLIB-NOTFOUND: not found

I guess there is some standard cmake idiom for ranlib search that's failing
Comment 2 Evgenii Khramtsov 2023-04-20 20:17:06 UTC
Build fails only when the LTO option is on (default).

Note, HardenedBSD -CURRENT switched to LLVM binutils earlier, and applied workaround:

https://github.com/HardenedBSD/ports/commit/6074fa0ef643
Comment 3 Jan Beich freebsd_committer freebsd_triage 2023-04-21 11:36:18 UTC
(In reply to Ed Maste from comment #1)
> I guess there is some standard cmake idiom for ranlib search that's failing

See /usr/local/share/cmake/Modules/CMakeFindBinUtils.cmake
LTO requires "llvm-ranlib", so try the following:

diff --git a/usr.bin/clang/llvm-ar/Makefile b/usr.bin/clang/llvm-ar/Makefile
index a6a480bce359..3718248f5de9 100644
--- a/usr.bin/clang/llvm-ar/Makefile
+++ b/usr.bin/clang/llvm-ar/Makefile
@@ -15,8 +15,8 @@ LIBADD+=	z
 LINKS+=		${BINDIR}/llvm-ar ${BINDIR}/llvm-ranlib
 
 .if ${MK_LLVM_BINUTILS} != "no"
-LINKS=		${BINDIR}/llvm-ar ${BINDIR}/ar ${BINDIR}/llvm-ar ${BINDIR}/ranlib
-MLINKS=		llvm-ar.1 ar.1 llvm-ar.1 ranlib.1
+LINKS+=		${BINDIR}/llvm-ar ${BINDIR}/ar ${BINDIR}/llvm-ar ${BINDIR}/ranlib
+MLINKS+=	llvm-ar.1 ar.1 llvm-ar.1 ranlib.1
 .endif
 
 .include "../llvm.prog.mk"
Comment 4 Ed Maste freebsd_committer freebsd_triage 2023-04-21 13:22:01 UTC
(In reply to Jan Beich from comment #3)
Thanks, and sorry I missed that. It seems I still had llvm-ranlib on my WITH_LLVM_BINUTILS test machine from the original install, so did not notice that it was missing.

I found llvm-symbolizer had the same issue (for llvm-addr2line) and created a review in https://reviews.freebsd.org/D39747.
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-04-21 16:52:04 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=41df1d60e3237df2106dddf357e3205bf29f85d5

commit 41df1d60e3237df2106dddf357e3205bf29f85d5
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-04-21 13:11:45 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-04-21 16:49:05 +0000

    llvm: fix some llvm-* tool links when WITH_LLVM_BINUTILS is set

    A few Makefiles overrode LINKS and MLINKS when WITH_LLVM_BINUTILS was
    set, which caused some llvm- prefixed tools to disappear.  One such case
    was llvm-ranlib, which some ports invoke explicitly.

    Use += when adding to LINKS and MLINKS under WITH_LLVM_BINUTILS.

    PR:             270955, 270956, 270959
    Submitted by:   jbeich
    Reviewed by:    arichardson
    Fixes: 021385aba562 ("Add WITH_LLVM_BINUTILS to install LLVM binuti...")
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D39747

 usr.bin/clang/llvm-ar/Makefile         | 4 ++--
 usr.bin/clang/llvm-nm/Makefile         | 4 ++--
 usr.bin/clang/llvm-size/Makefile       | 4 ++--
 usr.bin/clang/llvm-symbolizer/Makefile | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)
Comment 6 Evgenii Khramtsov 2023-04-21 18:26:57 UTC
Port builds fine here in poudriere pkgbase jail with WITH_LLVM_BINUTILS and LTO=on after base 41df1d60e323. x11/swayimg also displays JXL images. Thanks.
Comment 7 Ed Maste freebsd_committer freebsd_triage 2023-04-21 18:39:24 UTC
(In reply to throwaway_vthgwq4 from comment #6)
Thanks for testing and confirming. Closing as "not a bug" (in graphics/libjxl).
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-04-27 18:21:06 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3b63f0b7067129ec7a75b9324acf4ded30d8fc44

commit 3b63f0b7067129ec7a75b9324acf4ded30d8fc44
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-04-21 13:11:45 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-04-27 17:03:26 +0000

    llvm: fix some llvm-* tool links when WITH_LLVM_BINUTILS is set

    A few Makefiles overrode LINKS and MLINKS when WITH_LLVM_BINUTILS was
    set, which caused some llvm- prefixed tools to disappear.  One such case
    was llvm-ranlib, which some ports invoke explicitly.

    Use += when adding to LINKS and MLINKS under WITH_LLVM_BINUTILS.

    PR:             270955, 270956, 270959
    Submitted by:   jbeich
    Reviewed by:    arichardson
    Fixes: 021385aba562 ("Add WITH_LLVM_BINUTILS to install LLVM binuti...")
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D39747

    (cherry picked from commit 41df1d60e3237df2106dddf357e3205bf29f85d5)

 usr.bin/clang/llvm-ar/Makefile         | 4 ++--
 usr.bin/clang/llvm-nm/Makefile         | 4 ++--
 usr.bin/clang/llvm-size/Makefile       | 4 ++--
 usr.bin/clang/llvm-symbolizer/Makefile | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)