Skip to content

Accelerate Linkage Failure -- without explicit linkage in build.rs #22

@dream-dasher

Description

@dream-dasher

General Description:

The accelerate libary fails to link, despite correct dependency and feature specification. Clonable minmial repo example below.
For a simple crate, addition of a build.rs script explicitely linking the library seems to fix this ("cargo:rustc-link-lib=framework=Accelerate").

Exception:

However, not show below, I was not able to fix this problem with a build-script for a Workspace based repo.

Minimal Repo Example:

  • accelerate-test
  • you can clone and just disable/enable the build-rs script. (Or I can, I don't know if this is universal.)

Error on build:

error: linking with `cc` failed: exit status: 1
  |
  = note: env -u IPHONEOS_DEPLOYMENT_TARGET -u TVOS_DEPLOYMENT_TARGET LC_ALL="C" PATH="
...
"
  = note: ld: Undefined symbols:
            _cblas_cgemm, referenced from:
                ndarray::linalg::impl_linalg::mat_mul_impl::ha5aa880a642f660e in accelerate_test-df9792214fc029cd.4wf4kx2jc5a77go6.rcgu.o
            _cblas_dgemm, referenced from:
                ndarray::linalg::impl_linalg::mat_mul_impl::ha5aa880a642f660e in accelerate_test-df9792214fc029cd.4wf4kx2jc5a77go6.rcgu.o
            _cblas_sgemm, referenced from:
                ndarray::linalg::impl_linalg::mat_mul_impl::ha5aa880a642f660e in accelerate_test-df9792214fc029cd.4wf4kx2jc5a77go6.rcgu.o
            _cblas_zgemm, referenced from:
                ndarray::linalg::impl_linalg::mat_mul_impl::ha5aa880a642f660e in accelerate_test-df9792214fc029cd.4wf4kx2jc5a77go6.rcgu.o
          clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `accelerate-test` (bin "accelerate-test") due to previous error

Caused by:
  process didn't exit successfully: `/Users/username/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name accelerate_test --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=181 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C metadata=df9792214fc029cd -C extra-filename=-df9792214fc029cd --out-dir /Users/username/Documents/Programming_Dirs/Rust/accelerate-test/target/debug/deps -C incremental=/Users/username/Documents/Programming_Dirs/Rust/accelerate-test/target/debug/incremental -L dependency=/Users/username/Documents/Programming_Dirs/Rust/accelerate-test/target/debug/deps --extern blas_src=/Users/username/Documents/Programming_Dirs/Rust/accelerate-test/target/debug/deps/libblas_src-8261a14688e7d167.rlib --extern ndarray=/Users/username/Documents/Programming_Dirs/Rust/accelerate-test/target/debug/deps/libndarray-cebad4e9c98c9d7b.rlib --extern ndarray_linalg=/Users/username/Documents/Programming_Dirs/Rust/accelerate-test/target/debug/deps/libndarray_linalg-435cbc831f01e25f.rlib` (exit status: 1)

System & Cargo information:

  • cargo 1.74.1 (ecb9851af 2023-10-18)
  • Apple M2 Max
  • macOS Sonoma (14.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions