Skip to content

Comments

Split toolchain into exec/target toolchain types#99

Open
lamcw wants to merge 2 commits intobazel-contrib:mainfrom
lamcw:split-toolchain-type
Open

Split toolchain into exec/target toolchain types#99
lamcw wants to merge 2 commits intobazel-contrib:mainfrom
lamcw:split-toolchain-type

Conversation

@lamcw
Copy link

@lamcw lamcw commented Feb 20, 2026

rules_perl only defined a single toolchain_type with exec_compatible_with constraints. This meant toolchain resolution always followed the execution platform, causing cross-compilation scenarios (e.g., exec=linux_amd64, target=linux_arm64) to bundle the wrong Perl interpreter into the final binary.

The solution here would be to introduce a separate toolchain_type as the target-platform toolchain resolved via target_compatible_with, for build-time tools (perl_xs, genrule via current_toolchain) continue to use toolchain_type. This ensures perl_binary and perl_test bundle the interpreter matching the target platform.

Previously, rules_perl only defined a single toolchain_type with
exec_compatible_with constraints. This meant toolchain resolution always
followed the execution platform, causing cross-compilation scenarios
(e.g., exec=linux_amd64, target=linux_arm64) to bundle the wrong Perl
interpreter into the final binary.

Introduce a separate target_toolchain_type as the target-platform toolchain
resolved via target_compatible_with, for build-time tools (perl_xs, genrule via
current_toolchain) use toolchain_type. This ensures perl_binary and perl_test
bundle the interpreter matching the target platform.

Signed-off-by: Thomas Lam <thomaslam@canva.com>
@lamcw lamcw requested a review from skeletonkey as a code owner February 20, 2026 08:14
Signed-off-by: Thomas Lam <thomaslam@canva.com>
@skeletonkey
Copy link
Collaborator

@lamcw, thank you for the addition and the helpful comments in the code.

Could you please add a section to the README with an example of how to use the target toolchain (maybe at the bottom of the Getting Started section: Getting Started -> Target Toolchain)?

Also, it appears your formatter/linter is set to a line length of 80 chars. You may want to increase that to 100, as you will own several comments that have only been reformatted to 80 chars.

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.

2 participants