Skip to content

ci(macos): canonicalize dep dylib install names after cvcpkg fetch - #113

Closed
transfix wants to merge 3 commits into
masterfrom
ci/fix-macos-dep-dylib-rpath
Closed

transfix wants to merge 3 commits into
masterfrom
ci/fix-macos-dep-dylib-rpath

Conversation

@transfix

Copy link
Copy Markdown
Owner

Problem

package-macos has been red on master for weeks. gtest_discover_tests runs each freshly built test binary at build time to enumerate tests, and on macOS that abort the whole build:

dyld: Library not loaded: /private/var/folders/.../T/cvcpkg-gmp-*/install/lib/libgmpxx.4.dylib
  Referenced from: build/bin/app_test
CMake Error at GoogleTestAddTests.cmake:233: Error running test executable. Result: Subprocess aborted

cvcpkg builds each dependency in an ephemeral temp prefix and bakes that absolute path into every dylib's install name (LC_ID_DYLIB) and its cross-dependency load commands. Once the temp dir is gone, anything that links these dylibs records a dangling absolute path and fails to load them.

Fix

In the shared fetch-libcvc-deps action, after cvcpkg installs the deps (macOS only), rewrite each dylib's install name to its real, stable location in the fetched prefix, repoint any stale cross-references there, and re-sign ad-hoc (install_name_tool voids the arm64 code signature). Binaries that subsequently link these deps then record a path that still exists.

  • Scoped to the shared action so ci / release / nightly all benefit.
  • macOS-only (runner.os == 'macOS'), no-op when no bundles were fetched.
  • Emits a ::warning:: if any dylib still references an ephemeral temp prefix.

Verification

Validated on this PR's package-macos jobs (the whole point is that they now build + run app_test discovery).

Not covered here

package-windows is red for an unrelated, external reason — fetch-libcvc-deps (Windows) reports "no bundles found in catalog for this platform tuple", i.e. cvcpkg has no published Windows dep bundles yet (a libcvc-deps publishing gap). That needs Windows bundles published to the cvcpkg catalog and can't be fixed from this repo.

transfix added 3 commits July 19, 2026 18:15
cvcpkg builds each dependency in an ephemeral temp prefix and bakes that
absolute path into every dylib's install name (LC_ID_DYLIB) and its
cross-dependency load commands. Once the temp dir is gone, any binary that
links these dylibs fails to load them. On macOS this fails the whole build:
gtest_discover_tests runs a freshly built test exe at build time and aborts
with e.g.

  dyld: Library not loaded: /.../T/cvcpkg-gmp-*/install/lib/libgmpxx.4.dylib
  CMake Error at GoogleTestAddTests.cmake: Error running test executable.

(package-macos has been red on master for weeks for exactly this reason.)

Rewrite each fetched dylib's install name to its real, stable location in the
deps prefix and repoint stale cross-references there, then re-sign ad-hoc
(install_name_tool voids the arm64 signature). Every binary that subsequently
links these deps then records a path that still exists.

Scoped to the shared fetch-libcvc-deps action so ci/release/nightly all
benefit; macOS-only and a no-op when no bundles were fetched.
First pass canonicalized only ephemeral cvcpkg temp-path install names, which
cleared the libgmpxx failure but exposed the next one: ImageMagick's dylibs
reference libjpeg via @rpath, and the freshly built test exes have no RPATH to
resolve it, so gtest_discover_tests still aborts.

- Broaden the fetch-step rewrite to repoint EVERY non-system dependency load
  command whose target we actually ship in the deps prefix (ephemeral path,
  @rpath, or @loader_path) to that library's real absolute location, so the
  dependency graph is fully self-resolving.
- Also pass -DCMAKE_BUILD_RPATH=<deps>/lib on macOS so any @rpath load command
  that survives in our own binaries still resolves at test-discovery time.
The imagemagick recipe declares only zlib+tiff, so cvcpkg never installs the
JPEG/PNG/WebP/FreeType delegates into the prefix. The closure is therefore
incomplete and only "works" where a matching system library happens to be
present — on macOS there is none, so test discovery aborts with
`@rpath/libjpeg.62.dylib` not found even after the install-name/RPATH fixes.

List the delegate components (all already published in the catalog) explicitly
so the prefix is self-contained on every platform. Root cause (imagemagick
recipe under-declaring its deps) tracked separately in libcvc-deps.
@transfix

Copy link
Copy Markdown
Owner Author

Superseding this in favor of the recipe-first CI rewire. The dep-dylib install-name breakage this patched is a symptom of the incomplete cvcpkg closure fetched from cvc-requirements.yaml; the fix now lives in the in-tree libcvc recipe (#116) declaring the full closure (incl. the ImageMagick delegates + libxml2 via transfix/libcvc-deps#335), and cvcpkg's own cvc_rewrite_install_paths handles install names for recipe-built bundles. A drafted CI rewire to build via cvcpkg build libcvc --recipes-dir recipes follows.

@transfix transfix closed this Jul 20, 2026
@transfix
transfix deleted the ci/fix-macos-dep-dylib-rpath branch July 20, 2026 22:13
transfix added a commit that referenced this pull request Sep 22, 2026
Gap-analysis cleanup over the just-landed base (#394-#397). Correctness + doc-accuracy
+ test coverage in one module; no behavior change to the drive.

- Sentinel leak (major): min_clearance_m and min_sep_m sit at the 1e30 "unmeasured"
  sentinel until a sampler / second vehicle lowers them; num() only nulls non-finite, so
  the base JSON record emitted "min_clearance_m":1e+30 — read by a trainer as *enormous*
  clearance, the inverse of "missing". Add a num_sentinel() helper that nulls >=1e29 and
  apply it to both fields in episode_nav_stats::to_json() (aggregate_nav already guarded
  min_sep_m; the per-episode record now matches).
- Unit contract (major, root of the cvcdbg #113 bug): document nav_samplers.min_clearance_m
  as METRES and that sim_world::min_clearance() is NORMALIZED, so the caller must convert
  (/cfg.scale) before pointing it here.
- Stale comments (minor): drive.h still said the CUDA twin ignores the per-agent columns;
  #396 wired rr/body_rr/vmax/a_max/L into the batch CUDA entry points. Correct both blocks
  (only the persistent sim_world_cuda path still scalars; mass stays CPU/downstream-only).
- Mirror comment (minor): the header claimed field-parity with grl_snam.metrics.NavStats
  "pinned in cross-language parity tests" — neither true (veh_nav_stats is a superset; the
  match is grl_snam.scorecard, and parity is held by independent hand-computed corpora, not
  a gate). Correct it.
- Tests: SentinelFieldsSerializeAsNull (the sentinel->null fix); BudgetEtaAndFuelBounds
  (the eta_multiple + fuel_budget bounds, previously only time_budget_s was exercised); and
  ScriptedTrajectoryAccumulators now calls e.to_json() to pin the base record shape +
  goals_reached. 5/5 pass locally.
transfix added a commit that referenced this pull request Oct 12, 2026
…rollout (#596)

CVC-Lab/GRL-SNAM#113 made multi_start_penalty draw frac ~ U(frac_range)
per start and per sample; the old fixed frac = 0.9 made its ms_count
rollouts one rollout repeated. The native port mirrored that single
start. multi_start_params now carries ms_count, frac_lo/frac_hi, seed
and semi_implicit; the defaults are the old single explicit start,
byte-identical to master (checked over 400 random batches).

The draw is torch.rand's, bit for bit: std::mt19937(seed), low 24 bits,
then the Python's lo + (hi - lo) * u with the same float rounding
(multi_start_fracs). The ms_count rollouts run as one batch of
ms_count*B agents; a degenerate range is evaluated once. A fixed seed
is a fixed function, so the loss and gradient score the same starts and
the finite-difference checks stay deterministic; the pycvc trainer's
step k draws with seed + k and _loss scores the base seed.

semi_implicit (forward + adjoint) selects GRL-SNAM's integrator, which
has updated the velocity first since f5a015f; the default explicit order
is the material fork's, which train_material.py imports. Without it,
frac_range=(0.9, 0.9) matched native's start but not its rollout.

Also fixes NaN coefficient grads for a padded agent with no valid
obstacle: its start was o0 - frac * inf * 0, and the adjoint's 0 * NaN
reached g_beta/g_gamma. It now contributes 0, like the Python's 1e6
sentinel.

pycvc: nav_material_trainer_create takes trailing ms_count, frac_lo,
frac_hi, seed and ms_semi_implicit, validated before any GIL-free step.

Tests: rollout and multi-start FD gradchecks for both integrators and
sampled starts at a fixed seed; determinism, degenerate-range, bad-range
and no-obstacle cases; NavGeomRolloutParity pins the draw bit for bit
and L/grads to ~3e-7 against torch autograd on GRL-SNAM #113
(gen_nav_geom_multistart_golden.py regenerates the goldens); full-chain
trainer gradchecks with sampled starts; pycvc trainer arg coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant