Repository navigation
[BUILD] Fix the ICU and compression link-interface rewrites for static brew Boost - #10187
Conversation
cmake_findExternalLibs.cmake rewrites Boost::regex's link interface to the imported ICU targets when Boost is a static build from brew, but the middle entry was spelled "ICU:uc" with a single colon. CMake only treats a name as a target when it contains "::", so "ICU:uc" is passed through as a plain library name and lands on the link line as -lICU:uc, which fails with "cannot find -lICU:uc". The two neighbouring entries and FindICU itself use ICU::<component>, lower case. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0172Te4jm5uUVnb42TADzMe2
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe CMake configuration detects multiple Homebrew prefixes and adds reusable mapping for selected Boost linker flags. Static Boost iostreams and regex fixups resolve available compression and ICU targets while preserving unresolved flags with warnings. ChangesBoost link flag target mapping
Priority: ⬇️ Low Change: Bug fix Merge Risk: ⚪ Minimal · up to The Homebrew-specific rewrite is conditionally applied and preserves unsupported linker flags; no actionable merge-blocking risk was identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit checks each Homebrew trail Comment |
…ound
The overwrite was unguarded: find_package(ICU) ran only when an icui18n
entry was present in Boost::regex's link interface, but the
set_target_properties call that depends on it ran for every static brew
Boost under /usr/local/. This is the only find_package(ICU) in the
project, so a Boost whose regex was not built against ICU -- or any
build where ICU is not found -- names three imported targets that exist
nowhere and CMake stops at generate time:
The link interface of target "Boost::regex" contains:
ICU::data
but the target was not found.
Guard the rewrite on the targets actually existing, and replace only the
ICU entries instead of discarding the whole interface. When ICU is
missing, leave boost's plain -licu* flags in place and warn: a later
linker error naming icu beats a configure error about a missing imported
target. Same shape the opentims block further down already uses.
Verified with the block extracted verbatim into a scratch project:
no ICU in the interface -> untouched; ICU present but not findable ->
untouched plus warning; ICU found -> the three targets substituted with
the non-ICU entries preserved. All three configure cleanly; the first
two were hard errors before.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0172Te4jm5uUVnb42TADzMe2
| # imported target that no find_package created is a hard error at generate | ||
| # time ("the link interface contains ICU::data but the target was not | ||
| # found"), and this is the only find_package(ICU) in the project. | ||
| if (libs MATCHES "icui18n") |
There was a problem hiding this comment.
in theory this is still not correct. You are assuming if i18n is found that all the others are needed, which is not necessarily true.
If you fix this, fix it completely
There was a problem hiding this comment.
You're right — keying off icui18n and then demanding all three was still an assumption about how boost was built. Fixed in 074e3ee: each FindICU component is detected in the existing link interface, only those are requested, and each is substituted only if its imported target exists; otherwise boost's plain flag for that one component stays and the warning names that component alone.
Verified by extracting the block verbatim into a scratch project with a fake Boost::regex and a stub FindICU that can withhold components:
| interface before | requested | result |
|---|---|---|
-lpthread;-lm |
(find_package not called) | untouched |
-licuuc;-licudata;-lpthread |
data;uc |
-lpthread;ICU::data;ICU::uc — no invented ICU::i18n |
-licui18n;-licuuc;-licudata, i18n unavailable |
data;i18n;uc |
-licui18n;ICU::data;ICU::uc + one warning naming i18n |
-licui18n;-licuuc;-licudata;-lpthread, all available |
data;i18n;uc |
-lpthread;ICU::data;ICU::i18n;ICU::uc |
brew absolute paths (/usr/local/opt/icu4c/lib/libicuuc.dylib, …) |
i18n;uc |
ICU::i18n;ICU::uc |
One thing I'd like your call on before calling it complete: the Boost::iostreams block directly above (lines 42–56) has the same defect — zstd/LibLZMA are found conditionally, but "BZip2::BZip2;ZLIB::ZLIB;zstd::libzstd_shared;LibLZMA::LibLZMA" is set unconditionally. ZLIB::ZLIB and BZip2::BZip2 survive because they're found unconditionally later in the file (lines 174, 190), but an iostreams interface listing zstd without lzma hits the same generate-time error, and zstd::libzstd_shared doesn't exist when zstd resolves only as zstd::libzstd_static. I can apply the same per-entry treatment here (falling back to zstd::libzstd_static, then to leaving the flag, as the opentims block at line 658 already does) — want that in this PR, or separately?
Generated by Claude Code
There was a problem hiding this comment.
Went ahead with the Boost::iostreams block too, in 5e5e3e3 — sorry for the extra push after your approval; it was the same defect and leaving half of it fixed didn't seem right given "fix it completely".
Both blocks now swap only what boost actually listed, for the first candidate target that exists, and leave boost's flag in place with a warning otherwise. zstd falls back to zstd::libzstd_static when the shared target is absent, as the opentims block at line 658 does. Boost::regex is unchanged from what you approved.
The shared helper is a macro, not a function, so the imported targets its find_package creates stay visible to the caller. That bit me while writing it and is worth flagging, since it's a trap for the next person: a macro substitutes arguments as text, so a regex passed in as an argument gets unescaped twice — "\\." arrived as ".", which made the zlib pattern ^(-l|.*lib)z(.|$) match -lzstd and silently swallow it. The macro now takes the library stem and builds the regex itself; there's a comment saying why.
Verified the same way, with the macro and its four call sites extracted verbatim against a fake Boost::iostreams and stub find modules:
| interface before | available | result |
|---|---|---|
-lz;-lbz2;-lzstd;-llzma |
all | ZLIB::ZLIB;BZip2::BZip2;zstd::libzstd_shared;LibLZMA::LibLZMA |
-lz;-lzstd |
zstd static only | ZLIB::ZLIB;zstd::libzstd_static |
-lz;-lbz2 |
all | ZLIB::ZLIB;BZip2::BZip2 — no invented zstd/lzma (the old code named both) |
-lz;-lzstd |
zstd absent | -lzstd;ZLIB::ZLIB + one warning naming zstd |
/usr/local/lib/libz.dylib;/usr/local/lib/libzstd.dylib;-lpthread |
all | -lpthread;ZLIB::ZLIB;zstd::libzstd_shared |
-lpthread |
all | untouched |
I've re-requested your review since the push may have dismissed the approval.
Generated by Claude Code
There was a problem hiding this comment.
Correction to what I told you above, please don't merge on the strength of that table: the per-component behaviour I claimed for 074e3ee did not actually happen, and a review pass caught it. Fixed in dbfda9e.
find_package(ICU COMPONENTS ...) marks every listed component required even without REQUIRED, and FindICU creates all its imported targets inside if(ICU_FOUND). So one missing component meant no ICU:: target at all — the exact case the change existed for (boost listing i18n/uc/data with only two installed) substituted nothing, warned three times and left every raw flag in place. My verification missed it because the stub FindICU I tested against created each component independently, which the real module does not. Reproduced against /usr/share/cmake-3.28/Modules/FindICU.cmake with a root holding libicudata+libicuuc but not libicui18n:
COMPONENTS -> ICU_FOUND=FALSE, ICU::data, ICU::uc, ICU::i18n ALL missing
OPTIONAL_COMPONENTS -> ICU_FOUND=TRUE, ICU::data and ICU::uc present, ICU::i18n missing
Re-verified the block itself against the real module, no stub:
| interface before | ICU root | result |
|---|---|---|
-licui18n;-licuuc;-licudata;-lpthread |
all three | -lpthread;ICU::data;ICU::i18n;ICU::uc |
-licui18n;-licuuc;-licudata;-lpthread |
i18n absent | -licui18n;-lpthread;ICU::data;ICU::uc + one warning naming icui18n |
-licuuc;-licudata;-lpthread |
all three | -lpthread;ICU::data;ICU::uc |
-lpthread;-lm |
all three | untouched, find_package not called |
-licuuc;-licudata |
ICU absent | flags kept, one warning |
Four smaller findings from the same pass, all in this branch's code, also in dbfda9e:
- ICU entries were matched by bare substring while the iostreams macro anchors its pattern, so
-licuucd(a debug ICU) would have been detected as componentucand swapped for the releaseICU::uc. Both paths use the anchored form now, and the ICU loop reuses the macro instead of repeating its logic. find_packageinside the macro is nowQUIET— a config-mode miss printed CMake's generic "setzstd_DIR" warning right before ours, with different advice. (The opentims block already passesQUIET.)brew install icu4cwas useless advice: icu4c is keg-only, so installing it changes nothing. That case now names-DICU_ROOT="$(brew --prefix icu4c)".- The macro's
-DBOOST_USE_STATIC=OFFhint is wrong for the zlib and bzip2 call sites, since ZLIB and BZip2 are foundREQUIREDlater in this file regardless of boost's linkage. The remedy is stated in terms ofCMAKE_PREFIX_PATH/_ROOTnow.
One thing I have not touched, since it is pre-existing and changes which builds enter this code: the whole fallback is gated on location MATCHES "^/usr/local/", which never matches Apple Silicon Homebrew under /opt/homebrew. On arm64 macs with a static brew boost, neither block runs and even the "not fully supported" warning is skipped, so the raw -lzstd/-licuuc entries reach the linker, which does not search /opt/homebrew/lib. Want that guard widened here, or separately?
Generated by Claude Code
The previous guard still assumed the whole set: it triggered on an
icui18n entry and then required and substituted data, uc and i18n
together. Which ICU libraries boost::regex links depends on how boost
was built, so that both requests components boost may not use and, when
one of them is missing, drops the rewrite for the ones that are present.
Detect each FindICU component in the existing link interface, request
exactly those, and substitute each one only if its imported target
exists -- otherwise leave boost's plain link flag for that component in
place and warn about that component alone.
Verified with the block extracted verbatim into a scratch project,
driving a fake Boost::regex through a stub FindICU:
no icu entries -> find_package not called, interface untouched
-licuuc -licudata -> requests "data;uc", yields ICU::data;ICU::uc
and no invented ICU::i18n
all three, i18n missing -> ICU::data;ICU::uc substituted, -licui18n
kept, one warning naming i18n
all three available -> all three targets, non-ICU entries preserved
brew absolute paths -> matched and substituted
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0172Te4jm5uUVnb42TADzMe2
The iostreams block had the defect the regex block just lost: zstd and LibLZMA were looked for only when boost's link interface mentioned them, but the interface was then overwritten with "BZip2::BZip2;ZLIB::ZLIB;zstd::libzstd_shared;LibLZMA::LibLZMA" unconditionally. ZLIB::ZLIB and BZip2::BZip2 survive that because they are found unconditionally further down this file, but an interface listing zstd without lzma names LibLZMA::LibLZMA with no find_package behind it, and zstd's config package exports zstd::libzstd_shared only when zstd was built shared -- either way a generate-time error. It also discarded every entry boost listed that is not one of those four. Swap each backend boost actually listed for the first candidate target that exists, taking zstd::libzstd_static when the shared one is absent as the opentims block further down already does, and leave boost's plain flag in place with a warning when nothing matches. The shared helper is a macro rather than a function so that the imported targets its find_package creates stay visible to the caller. That makes the regex worth a note: a macro substitutes arguments as text, so a backslash escape passed in is unescaped twice -- "\\." arriving as "." made the zlib stem match -lzstd and silently swallow it. The macro now takes the library stem and builds the regex itself. Verified with the macro and its four call sites extracted verbatim into a scratch project, against a fake Boost::iostreams and stub find modules that can withhold packages: -lz -lbz2 -lzstd -llzma, all found -> all four targets, shared zstd zstd only static -> zstd::libzstd_static only -lz -lbz2 listed -> those two, no invented zstd/lzma -lzstd listed, zstd not findable -> -lzstd kept, one warning brew paths + -lpthread -> paths swapped, -lpthread kept nothing listed -> interface untouched The Boost::regex block is unchanged and still behaves as reviewed. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0172Te4jm5uUVnb42TADzMe2
…titutes The per-component translation added in 074e3ee did not do what its commit message claimed. find_package(ICU COMPONENTS ...) marks every listed component required even without REQUIRED, and FindICU creates all its imported targets inside "if(ICU_FOUND)", so one missing component left no ICU:: target at all. The case the change existed for -- boost listing icui18n, icuuc and icudata where only two are installed -- therefore substituted nothing, warned three times and left every raw flag in place. It passed review because the test stubbed FindICU, and the stub created each component independently; against the real module it fails. Reproduced with /usr/share/cmake-3.28/Modules/FindICU.cmake and an ICU root holding libicudata and libicuuc but not libicui18n: COMPONENTS -> ICU_FOUND=FALSE, all three targets missing OPTIONAL_COMPONENTS -> ICU_FOUND=TRUE, ICU::data and ICU::uc present Re-verified the block itself the same way, no stub in sight: all three listed and present -> all three substituted i18n missing -> ICU::data;ICU::uc, -licui18n kept, one warning naming icui18n only uc+data listed -> only those two requested no icu entries -> untouched, find_package not called ICU absent entirely -> flags kept, one warning Four smaller review findings, all in this branch's own code: - The ICU entries were matched by bare substring while the iostreams macro anchors its pattern, so "-licuucd" would have been detected as component uc and swapped for the release ICU::uc. Both now use the anchored form, and the ICU loop reuses the macro for the substitution instead of repeating it. - find_package inside the macro is QUIET: a config-mode miss printed CMake's generic "set zstd_DIR" warning immediately before our own, with different advice. The opentims block already passes QUIET. - "install ICU (e.g. 'brew install icu4c')" cannot fix an ICU miss -- icu4c is keg-only, so installing it changes nothing. That case now names -DICU_ROOT="$(brew --prefix icu4c)". - The macro's "or use -DBOOST_USE_STATIC=OFF" hint is wrong for the zlib and bzip2 call sites, where ZLIB and BZip2 are found REQUIRED later in this file regardless of the boost linkage. The remedy is now stated in terms of CMAKE_PREFIX_PATH and _ROOT variables. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0172Te4jm5uUVnb42TADzMe2
|
yesh should be fine. remember that since we use vcpkg, CI is not testing the changes. |
|
Agreed, and that cuts both ways here: CI can't reach this code at all — vcpkg aside, the branch needs a static brew Boost under One thing so it doesn't get lost: was "should be fine" also a yes to widening the Generated by Claude Code |
|
yes, add it obviously. we dont even support intel anymore officially. |
…sr/local Both blocks were gated on the boost library's location matching "^/usr/local/", Homebrew's prefix on Intel only. On Apple Silicon brew installs to /opt/homebrew, so with a static brew boost neither block ran -- no link-interface rewrite and not even the "not fully supported" warning -- and boost's plain -lzstd/-licuuc entries reached a linker that does not search /opt/homebrew/lib. Intel is no longer officially supported, so this covered the platform we do not ship and skipped the one we do. Match any Homebrew prefix instead: /opt/homebrew, /usr/local, and $HOMEBREW_PREFIX when the environment sets it for a relocated install. The comparison is cmake_path(IS_PREFIX), which works on whole path components -- /usr/locale is not inside /usr/local -- rather than a string regex. Verified against a fake imported Boost::regex: /opt/homebrew/lib/libboost_regex.a -> enters (was skipped) /usr/local/lib/libboost_regex.a -> enters /usr/locale/lib/libboost_regex.a -> skips <build>/vcpkg_installed/x64-linux/lib/libboost_regex.a -> skips /opt/custombrew/... without HOMEBREW_PREFIX -> skips /opt/custombrew/... with HOMEBREW_PREFIX set -> enters The vcpkg case is the one CI takes, so CI behaviour is unchanged. The two blocks themselves are untouched and re-checked against the real FindICU after the move. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0172Te4jm5uUVnb42TADzMe2
|
Added in Verified against a fake imported
The vcpkg row is the one CI takes, so CI behaviour is unchanged — which, per your point, is also why CI passing says nothing about the rest of this. The two blocks themselves are untouched, and I re-ran the ICU one against the real Re-requested your review, since the push will have dismissed the approval again. Generated by Claude Code |
|
CI is red on Failing: The installed export's Why it isn't this PR:
Why Where to look: either the installed export should not carry a No re-run: the failure is deterministic and reproduced identically on three independent jobs, so a re-run would only burn another CI cycle. I'll keep watching this PR; it cannot go green until Generated by Claude Code |
…) (#10208) PR #10187 fixed several bugs in the Homebrew static-Boost fallback (malformed ICU:uc target name, a possible hard configure-time error, and a missing Apple Silicon prefix match) but never got a changelog entry, unlike its neighboring build/packaging PRs. Claude-Session: https://claude.ai/code/session_01WykfWw53WFsjoZV4FFHS19 Co-authored-by: Claude <[email protected]>
Description
Fixes to the brew-Boost fallback in
cmake/cmake_findExternalLibs.cmake, which rewritesBoost::iostreams' andBoost::regex's link interfaces from boost's raw-l…flags to imported targets, because boost's CMake config does not expose those transitive dependencies as targets (boost_install#64).1.
ICU:uc→ICU::uc(fb0fb78). The middle entry had a single colon. CMake only treats a name as a target when it contains::, so it was passed through as a plain library name and lands on the link line verbatim:/usr/bin/ld: cannot find -lICU:uc.2. Both blocks: substitute only what boost listed, and only what was found (
909f8fc,074e3ee,5e5e3e3). In each block thefind_packagecalls were conditional on what boost's interface mentioned, but theset_target_propertiesthat depends on them was not:Boost::regexnamedICU::data;ICU::uc;ICU::i18nfor every static brew Boost. This is the onlyfind_package(ICU)in the project, so a boost whose regex was not built against ICU — or any build where ICU is missing — stopped the configure withThe link interface of target "Boost::regex" contains: ICU::data but the target was not found.Boost::iostreamsnamedBZip2::BZip2;ZLIB::ZLIB;zstd::libzstd_shared;LibLZMA::LibLZMAunconditionally.ZLIB::ZLIBandBZip2::BZip2survive only because they are found unconditionally further down the file; an interface listing zstd without lzma namesLibLZMA::LibLZMAwith nofind_packagebehind it, andzstd::libzstd_shareddoes not exist when zstd was built static — the same error either way.Both blocks now translate entry by entry through one helper: detect what boost actually listed, look for exactly that, and substitute each entry only if a target for it exists — otherwise boost's own flag stays and a warning names that one dependency. zstd falls back to
zstd::libzstd_static, as the opentims block already does. Neither block discards the rest of the interface any more.3.
OPTIONAL_COMPONENTSfor ICU (dbfda9e). The per-component step above did not work as074e3eeclaimed, and a review pass caught it:find_package(ICU COMPONENTS ...)marks every listed component required even withoutREQUIRED, andFindICUcreates all its imported targets insideif(ICU_FOUND). One missing component therefore left noICU::target at all, so the very case the change existed for substituted nothing. Verified against the real module with a root holdinglibicudata+libicuucbut notlibicui18n:The same commit carries four smaller review findings: ICU entries are matched with the macro's anchored pattern instead of a bare substring (so a debug
-licuucdis no longer swapped for the releaseICU::uc) and reuse the macro rather than repeating its logic;find_packageinside the macro isQUIET, so a config-mode miss no longer prints CMake's generic "setzstd_DIR" warning right before ours; the ICU-missing case names-DICU_ROOT="$(brew --prefix icu4c)"instead ofbrew install icu4c, which cannot help because icu4c is keg-only; and the macro's remedy no longer suggests-DBOOST_USE_STATIC=OFFfor zlib/bzip2, which are foundREQUIREDlater regardless of boost's linkage.4. Apple Silicon (
6511e14). Both blocks were gated on the boost library living under/usr/local/, Homebrew's prefix on Intel only. On Apple Silicon brew installs to/opt/homebrew, so with a static brew boost neither block ran — no rewrite, not even the "not fully supported" warning — and the raw flags reached a linker that does not search/opt/homebrew/lib. The gate now matches any Homebrew prefix (/opt/homebrew,/usr/local,$HOMEBREW_PREFIX) usingcmake_path(IS_PREFIX), which compares whole path components, so/usr/localeis not inside/usr/local.The flag-to-target helper is a macro, not a function, so the imported targets its
find_packagecreates stay visible to the caller. That makes the regex worth a note in the code: a macro substitutes arguments as text, so a backslash escape passed in is unescaped twice —"\\."arriving as"."made the zlib stem match-lzstdand silently swallow it. The macro takes the library stem and builds the regex itself.Verification. None of this is reachable by CI: the gate needs a static brew Boost, and CI builds with vcpkg. Each piece was verified by extracting it verbatim into a scratch project — the ICU block against the real
FindICUwith fake ICU roots (the stub I used earlier is what hid finding 3), the iostreams block against stub find modules that can withhold packages, the gate against a fake imported target.Boost::regex, realFindICU:-licui18n;-licuuc;-licudata;-lpthread-lpthread;ICU::data;ICU::i18n;ICU::uc-licui18n;-licuuc;-licudata;-lpthread-licui18n;-lpthread;ICU::data;ICU::uc+ one warning naming icui18n-licuuc;-licudata;-lpthread-lpthread;ICU::data;ICU::uc-lpthread;-lmfind_packagenot called-licuuc;-licudataICU_ROOTBoost::iostreams:-lz;-lbz2;-lzstd;-llzmaZLIB::ZLIB;BZip2::BZip2;zstd::libzstd_shared;LibLZMA::LibLZMA-lz;-lzstdZLIB::ZLIB;zstd::libzstd_static-lz;-lbz2ZLIB::ZLIB;BZip2::BZip2— no invented zstd/lzma-lz;-lzstd-lzstd;ZLIB::ZLIB+ exactly one warning/usr/local/lib/libz.dylib;/usr/local/lib/libzstd.dylib;-lpthread-lpthread;ZLIB::ZLIB;zstd::libzstd_shared-lpthreadThe gate:
IMPORTED_LOCATION/opt/homebrew/lib/libboost_regex.a6511e14)/usr/local/lib/libboost_regex.a/usr/locale/lib/libboost_regex.a<build>/vcpkg_installed/x64-linux/lib/libboost_regex.a/opt/custombrew/...with / withoutHOMEBREW_PREFIXAll configure cleanly, and the complete file still parses (
cmake -Preaches execution and stops only at the missing XercesC).Noticed while checking whether #5436 (libicu RPATH) still applies — unrelated to that issue, which is now closed as obsolete.
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_0172Te4jm5uUVnb42TADzMe2
Summary by CodeRabbit