Repository navigation
Conversation
build.rs emits a rustc-link-search path for every prefix on AMENT_PREFIX_PATH, but declares only ROS_DISTRO and build.rs as rerun triggers. Once a build script emits any rerun-if line, Cargo reruns it only for the listed triggers, so the search paths stay whatever they were on the first build. Reproduced with a crate that depends on rclrs 0.8.0 and ros-env 0.3.0: build it, source a workspace that adds an interface package, and rebuild without `cargo clean`. ros-env declares rerun-if-env-changed=AMENT_PREFIX_PATH, so it reruns and compiles the new package in, with a #[link] to its typesupport library. rclrs and rosidl_runtime_rs, which emit the per-prefix link search paths, do not rerun, so the final link fails with "library not found for -l<pkg>__rosidl_typesupport_c" although the library is on the new prefix. With this change the rebuild links. Assisted-by: Claude Code:claude-opus-5-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
build.rsemits arustc-link-searchpath for every prefix onAMENT_PREFIX_PATH, but declares onlyROS_DISTROandbuild.rsas reruntriggers. Once a build script emits any
rerun-ifline, Cargo reruns itonly for the listed triggers. So the search paths stay whatever they were
on the first build.
ros-env does declare
rerun-if-env-changed=AMENT_PREFIX_PATH. So aftersourcing a workspace that adds an interface package, ros-env reruns and
compiles that package in, with a
#[link]to its typesupport library, but nobuild script offers the new prefix's
lib/to the linker:The library is on the new prefix.
cargo clean -p rclrs -p rosidl_runtime_rsfixes it, which is how it has been worked around.
Reproduction
A crate depending on rclrs 0.8.0 and ros-env 0.3.0, in a fresh target
directory:
library not found)Either change alone is enough, because Cargo collects link search paths from
every build script. Both are proposed because each crate reads the variable
and should say so; a crate using rosidl_runtime_rs without rclrs would
otherwise keep stale paths.
Change
One
println!("cargo:rerun-if-env-changed={AMENT_PREFIX_PATH}"), inside thenot(use_ros_shim)block where the variable is actually read.Testing
cargo test --workspaceand-F=serde,cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --check: all pass.