Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate a wrong platform protoc.exe when cross compile #126

Open
xiedeacc opened this issue Jun 24, 2022 · 9 comments
Open

generate a wrong platform protoc.exe when cross compile #126

xiedeacc opened this issue Jun 24, 2022 · 9 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee)

Comments

@xiedeacc
Copy link

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: grpc/grpc#30103

@xiedeacc
Copy link
Author

@Yannic can U see see?

@xiedeacc
Copy link
Author

@thii can u cc?

@xiedeacc
Copy link
Author

xiedeacc commented Jul 1, 2022

can anybody take a look please?

@Yannic
Copy link
Collaborator

Yannic commented Jul 7, 2022

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?

@xiedeacc
Copy link
Author

xiedeacc commented Jul 7, 2022

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?

clear && bazel build --incompatible_enable_cc_toolchain_resolution --platforms=@bazel_build_file//platforms:linux_gcc11_aarch64_none_musleabi -s --copt=-g3 --strip=never //...

@xiedeacc
Copy link
Author

xiedeacc commented Jul 7, 2022

@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

@xiedeacc
Copy link
Author

xiedeacc commented Jul 9, 2022

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

@xiedeacc
Copy link
Author

xiedeacc commented Jul 9, 2022

maybe it's not rules_proto problem, I think may need bazel make select more flexible

@xiedeacc
Copy link
Author

xiedeacc commented Jul 9, 2022

rules_proto need choose protoc platform by detect bazel excution platform(host), not by select, use select cannot support cross compile

@comius comius added the P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) label Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee)
Projects
None yet
Development

No branches or pull requests

3 participants