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

Error when compiling Rust on Aarch64 MacOS #2611

Open
tyb0807 opened this issue Apr 10, 2024 · 3 comments
Open

Error when compiling Rust on Aarch64 MacOS #2611

tyb0807 opened this issue Apr 10, 2024 · 3 comments

Comments

@tyb0807
Copy link

tyb0807 commented Apr 10, 2024

Hi,

I'm very new to the field, so please let me know if the information I communicate here is useful enough for debugging.

I have the following dependency in MODULE.bazel

bazel_dep(name = "rules_rust", version = "0.41.1")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
    edition = "2024",
    versions = ["1.77.2"],
)
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")

When running a simple blaze test command, I get the following error (I've omitted the more verbose parts):

ERROR: .../external/rules_rust~/util/process_wrapper/BUILD.bazel:31:36: Compiling Rust (without process_wrapper) bin process_wrapper (6 files) [for tool] failed: (Exit 1): sandbox-exec failed: error executing Rustc command 
  ...
error: linking with `external/zig_sdk/tools/aarch64-macos-none/c++` failed: exit status: 1
  |
  = note: env -u ...
  = note: error: unable to find dynamic system library 'resolv' using strategy 'paths_first'. searched paths: ...

Does anybody know what's happening here, and how to fix this please?

@illicitonion
Copy link
Collaborator

Welcome, and thanks for the issue! If you can post a full git repo we can clone and run, that'd help to be able to debug. It looks like you're wiring up a zig C++ toolchain?

@DhashS
Copy link

DhashS commented Jun 14, 2024

I'm also seeing this (albeit with a WORKSPACE based config) when trying to use zig to make a hermetic cc toolchain work. The core of the issue seems to be the fact that a hermetic cc_toolchain kinda by definition needs to not depend on the host -- generally where one receives the host SDK from.

The relevant issue are these ones:

This really only crops up if you try and go full hermetic with BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 since otherwise the host sysroot is picked up via probably some xcrun shenanigans.

Until then (or until the rules_rust team drops

"darwin": ["-lSystem", "-lresolv"],
this line) it'll be impossible to compile with a no-host hermetic CC toolchain since the don't detect host toolchain thing is an --action_env thing, which makes it global in a way that i'm unable to see how to specifically exclude rules_rust from.

@marvin-hansen
Copy link
Contributor

@DhashS consider trying a LLVM toolchain setup with sysroot as it usually creates less fuzz.

See this example: https://github.com/marvin-hansen/examples/tree/main/rust-tutorial/01-hello-clang

For a LLVM with sysroot, see the cross compile example:
https://github.com/marvin-hansen/examples/tree/main/rust-tutorial/02-hello-cross

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

No branches or pull requests

4 participants