rules_proto
rules_proto copied to clipboard
generate a wrong platform protoc.exe when cross compile
my project import rules_proto and grpc, when I cross compile for arm with with --incompatible_enable_cc_toolchain_resolution and --platforms, it generated protoc.exe for arm, so protoc.exe cannot executed on build host( x86_64 linux), so build grpc will fail, I'm not sure it's grpc problem or rules_proto problem. here it's a demo: https://github.com/xiedeacc/tbox
I also open an issue at grpc: https://github.com/grpc/grpc/issues/30103
@Yannic can U see see?
@thii can u cc?
can anybody take a look please?
protoc is built for the execution platform (since we need to run it as part of the build), so it seems to me that the execution platform is somehow misconfigured. Can you share the exact command you're running?
protocis built for the execution platform (since we need to run it as part of the build), so it seems to me that the execution platform is somehow misconfigured. Can you share the exact command you're running?
clear && bazel build --incompatible_enable_cc_toolchain_resolution --platforms=@bazel_build_file//platforms:linux_gcc11_aarch64_none_musleabi -s --copt=-g3 --strip=never //...
@Yannic demo may have toolchain download problem, but I have checked, it's fine, if demo has any problem, tell me, I'll fix it
after I check rules_proto source code, I found my platforms value passby was
platform(
name = "linux_gcc11_aarch64_none_musleabi",
constraint_values = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
":gcc_11",
":musleabi",
],
)
and I defined a toolchain
toolchain(
name = "gcc11_arm_aarch64_none_gnueabi_xcompile_toolchain",
exec_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
target_compatible_with = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
"//platforms:gcc_11",
"//platforms:gnueabi",
],
toolchain = "@gcc11_arm_aarch64_none_gnueabi//:cc_toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
exec_compatible_with indicate it's for cross compiling, but rules_proto use target_compatible_with values I guess,
so cpu:aarch64 and os:linux will be recognised by rule_proto in BUILD.release, so :linux-aarch64": "@com_google_protobuf_protoc_linux_aarch64//:protoc" be selected.
as a conclusion: rules_proto not support cross compile? can update rules_proto support cross compile?
@Yannic
maybe it's not rules_proto problem, I think may need bazel make select more flexible
rules_proto need choose protoc platform by detect bazel excution platform(host), not by select, use select cannot support cross compile