Skip to content

Add support for cross-compiled binaries#25

Merged
esteve merged 1 commit intoros2-rust:mainfrom
harrisonmg:cross_target_dir
Jul 24, 2025
Merged

Add support for cross-compiled binaries#25
esteve merged 1 commit intoros2-rust:mainfrom
harrisonmg:cross_target_dir

Conversation

@harrisonmg
Copy link
Contributor

Cargo puts cross-compiled binaries in an additional subdirectory; for example:

native: target/debug
vs
arm64: target/aarch64-unknown-linux-gnu/debug

For this reason, cargo-ament-build fails when cross compiling:

Starting >>> publ
--- stderr: publ
Error in cargo-ament-build

Caused by:
0: Failed to copy binary from '/workspace/build/publ/debug/publ'
1: No such file or directory (os error 2)
---
Failed   <<< publ [5.09s, exited with code 1]

This change introduces detection of the build target architecture via the --target argument or the CARGO_BUILD_TARGET environment variable and modifies the search path for binaries accordingly.

Copy link
Collaborator

@luca-della-vedova luca-della-vedova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Makes sense to me, I haven't tried on cargo-ament-build but I tested on a cargo build in cross compiling and I do see the folder structure you mentioned so the implementation looks correct.
I'll approve first, I'll give it a few days if any other maintainer wants to give it a look then merge it if there is no opposition.

Copy link
Contributor

@esteve esteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harrisonmg LGTM, thanks!

@esteve
Copy link
Contributor

esteve commented Jul 24, 2025

@luca-della-vedova thanks for having a look, I'll go and merge this PR

@esteve esteve merged commit 94f4cb2 into ros2-rust:main Jul 24, 2025
20 of 21 checks passed
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.

3 participants