-
Notifications
You must be signed in to change notification settings - Fork 402
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
Confusion on the use of 'extra_target_triples' in rust_repository_set
#109
Comments
Two parts: First, regd:
This is a normal bug that I need to fix. Will investigate soon Second, more generally around the cross compilation story: This is a very new feature that isn't completely implemented and I apologize for the confusion. Currently the I'll keep this issue updated with the implementation progress. |
No need to apologize. Thanks for explaining. Please let me know if I can be of any assistance. |
Howdy again! So after having added my aarch64 toolchain I no longer get this error. I still have to mess around with this now and attempt to get cross-compilation working. |
Any update on this? I am trying to compile some rust for a Raspberry Pi and I'm running into similar issues:
None of these targets appear to export a PlatformInfo, when I try to use @rust_linux_arm//:toolchain_for_arm-unknown-linux-gnueabihf_impl I get a different error however.
Am I missing something? How am I supposed to invoke this? I get basically the same error when using --extra_toolchains. Could you post an example of how you expect this to be done? |
I don't have an update on this feature. The cross compilation functionality itself is still soft-blocked on adding a toolchain configuration option for specifying a per target crosslinker[*], though if you're willing to wait long enough that problem will eliminate itself when lld becomes the default linker (which ostensibly can crosslink to any supported target). Crosslink-aside, I don't understand the circular dependency you're seeing there. I can't promise that it'll be enlightening, but can you add the result of:
[*] This isn't actually "hard" to do, its just something I was supposed to do and haven't done. Don't worry, this isn't the only feature I've been neglecting. |
That's just the hello world I'm compiling, noting exciting in there:
|
Out of curiosity, what is the command for crosscompiling to arm meant to look like. Also out of curiosity, why is armv7 not supported when it's apparently supported by rustc? Just wondering if I'm missing something |
The couple of blog posts on the topic make it look like cargo passes rules_rust/rust/private/rustc.bzl Line 224 in 23ab9d5
@acmcarther can you qualify "not hard to do" with an outline of what needs to be done? Is lld usable, or should we do something else? |
Sorry for the lack of responsiveness. I'm actually working to implement this now, but I didn't want to say anything and then not actually do it. I've basically garbage collected my knowledge of build configuration attributes, so I'm reacquiring the knowledge. After some brief exploration with my last working state, I can tell you that the semantics of That aside, I can give you a general update on what needs to happen w.r.t. the linker configuration and On providing a crosslinker rust_repository_set(
name = "rust_linux_x86_64"
exec_triple = "x86_64-unknown-linux-gnu",
extra_target_triples = [
"arm-unknown_linux-gnueabi",
],
version = RUST_VERSION,
) What this actually means is: "Get me a compiler that runs on Here's what they actually look like. Now take that knowledge and store it somewhere, and lets talk about how the linker is selected right now. Currently, # Link!
rpaths = _compute_rpaths(toolchain, output_dir, dep_info)
ld, link_args = _get_linker_and_args(ctx, rpaths)
args.add("--codegen=linker=" + ld)
args.add_joined("--codegen", link_args, join_with = " ", format_joined = "link-args=%s") (might be helpful to see def _get_linker_and_args(ctx, rpaths):
if (len(BAZEL_VERSION) == 0 or
versions.is_at_least("0.18.0", BAZEL_VERSION)):
user_link_flags = ctx.fragments.cpp.linkopts
else:
user_link_flags = depset(ctx.fragments.cpp.linkopts)
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)
link_variables = cc_common.create_link_variables(
feature_configuration = feature_configuration,
cc_toolchain = cc_toolchain,
is_linking_dynamic_library = False,
runtime_library_search_directories = rpaths,
user_link_flags = user_link_flags,
)
link_args = cc_common.get_memory_inefficient_command_line(
feature_configuration = feature_configuration,
action_name = CPP_LINK_EXECUTABLE_ACTION_NAME,
variables = link_variables,
)
ld = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,
action_name = CPP_LINK_EXECUTABLE_ACTION_NAME,
)
return ld, link_args ^^^ All that stuff up there is stuff I basically know nothing about. However, I can tell you that one avenue of potential crosslinking goodness is updating the cc linker to Now, back to "what needs to happen to get a crosslinker" For lack of any specialized knowledge in this, but having a general familiarity with installing a crosslinker from the japaric/rust-cross repo, I figured we could just add a new optional attr to Moving backward now to the On Rust-LLD Now, finding a custom crosslinker for the host to each target and including it into the workspace, is a hassle. Luckily, LLD solves this by just automatically supporting linking to every supported target on every host. Unfortunately, I wasn't able to find an authoritative source on exactly which targets are supported, though I know Cargo prefers LLD for some obscure targets and we could conceivably do so as well. The LLD linker is provided in the |
I've had success currently setting up the cross-linker using typical Bazel cc toolchain setup, so I'm not sure it needs to be exposed through rules_rust specifically since it's arguably a cc link step, or more fairly it's on the onus of upstream (or more rules?) to set up some "LLVM" link step since even in our case it isn't a "rust specific" link since the cc deps would be linked in at that point. Actually, I ran into an issue with rules_go where they weren't properly respecting the existing cc toolchain, so I imagine going out of the way to let existing structures exist might be ideal. |
I encounter similar problem when setting |
Howdy!
I'm not sure if this is related to #101 or not but I had expected this to work:
The error I get:
What "extra_target_triples" seemed to be was the ability to have this pull down appropriate versions of the stdlib for alternate targets in the style of
rustup target add aarch64-unknown-linux-gnu
.The text was updated successfully, but these errors were encountered: