aya-rs / aya-template

A cargo-generate template for Rust eBPF Projects using Aya
80 stars 41 forks source link

error[E0463]: can't find crate for `core` when cross-compiling on Apple Silicon Macs #129

Closed harry-xm closed 2 weeks ago

harry-xm commented 2 weeks ago

See build log below. Project was generated from commit 20ce988ecf604c09351d6f54587f3f639df9f402.

%  cargo generate https://github.com/aya-rs/aya-template
⚠️   Favorite `https://github.com/aya-rs/aya-template` not found in config, using it as a git repository: https://github.com/aya-rs/aya-template
🤷   Project Name: aya-demo
🔧   Destination: /Users/li/aya-demo ...
🔧   project-name: aya-demo ...
🔧   Generating template ...
✔ 🤷   Which type of eBPF program? · sock_ops
🔧   Moving generated files into: `/Users/li/aya-demo`...
🔧   Initializing a fresh Git repository
✨   Done! New project created /Users/li/aya-demo
% cd aya-demo
% ARCH=x86_64
% rustup toolchain install stable
info: syncing channel updates for 'stable-aarch64-apple-darwin'

  stable-aarch64-apple-darwin unchanged - rustc 1.81.0 (eeb90cda1 2024-09-04)

info: checking for self-update
% rustup toolchain install nightly --component rust-src
info: syncing channel updates for 'nightly-aarch64-apple-darwin'
info: latest update on 2024-10-17, rust version 1.84.0-nightly (798fb83f7 2024-10-16)
info: component 'rust-src' is up to date

  nightly-aarch64-apple-darwin unchanged - rustc 1.84.0-nightly (798fb83f7 2024-10-16)

info: checking for self-update
% rustup target add ${ARCH}-unknown-linux-musl
info: component 'rust-std' for target 'x86_64-unknown-linux-musl' is up to date
% brew install llvm
==> Downloading https://formulae.brew.sh/api/formula.jws.json
############################################################################################################################################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############################################################################################################################################################################################### 100.0%
Warning: llvm 19.1.1 is already installed and up-to-date.
To reinstall 19.1.1, run:
  brew reinstall llvm
% brew install filosottile/musl-cross/musl-cross
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Warning: filosottile/musl-cross/musl-cross 0.9.9_2 is already installed and up-to-date.
To reinstall 0.9.9_2, run:
  brew reinstall musl-cross
% cargo install bpf-linker --no-default-features
    Updating crates.io index
     Ignored package `bpf-linker v0.9.13` is already installed, use --force to override
% AYA_BUILD_EBPF=true \
CC=${ARCH}-linux-musl-gcc \
RUSTFLAGS="-C linker=${ARCH}-linux-musl-gcc" \
  cargo build --package aya-demo --release --target=${ARCH}-unknown-linux-musl
    Updating crates.io index
     Locking 100 packages to latest compatible versions
      Adding hermit-abi v0.3.9 (latest: v0.4.0)
      Adding linux-raw-sys v0.4.14 (latest: v0.6.5)
      Adding wasi v0.11.0+wasi-snapshot-preview1 (latest: v0.13.3+wasi-0.2.2)
      Adding windows-sys v0.52.0 (latest: v0.59.0)
      Adding winsafe v0.0.19 (latest: v0.0.22)
   Compiling proc-macro2 v1.0.88
   Compiling unicode-ident v1.0.13
   Compiling version_check v0.9.5
   Compiling thiserror v1.0.64
   Compiling utf8parse v0.2.2
   Compiling anyhow v1.0.89
   Compiling libc v0.2.159
   Compiling anstyle-parse v0.2.5
   Compiling rustversion v1.0.18
   Compiling is_terminal_polyfill v1.70.1
   Compiling proc-macro-error-attr v1.0.4
   Compiling heck v0.5.0
   Compiling serde v1.0.210
   Compiling anstyle v1.0.8
   Compiling colorchoice v1.0.2
   Compiling anstyle-query v1.1.1
   Compiling proc-macro-error v1.0.4
   Compiling anstream v0.6.15
   Compiling strsim v0.11.1
   Compiling rustix v0.38.37
   Compiling aya-ebpf-cty v0.2.2
   Compiling quote v1.0.37
   Compiling clap_lex v0.7.2
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `libc` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
%
harry-xm commented 2 weeks ago

Sorry, this seems to be a PATH environment variable configuration error on my side. Closing the issue.