ruby-numo / numo-linalg

Linear Algebra Library for Ruby/Numo::NArray
BSD 3-Clause "New" or "Revised" License
38 stars 9 forks source link

Build fails on Mac M1 / Ventura 13.3.1 #48

Closed petercip closed 1 year ago

petercip commented 1 year ago

My apologies for posting this. My knowledge of build flags is extremely out-of-date. I assume there are some environment variables missing when I run gem install numo-linalg. Any help is much appreciated.

I did try prefixing the command with MACOSX_DEPLOYMENT_TARGET=13.0 and MACOSX_DEPLOYMENT_TARGET=12.0

System information

$ uname -a
Darwin peterc-air 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:41 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8103 arm64
$ sw_vers 
ProductName:        macOS
ProductVersion:     13.3.1
BuildVersion:       22E261
$ clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Warnings

During build there are 121 warnings nearly all like below. I'm not sure those matter:

warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'blasint' (aka 'int') [-Wshorten-64-to-32]

Errors

linking shared-object numo/linalg/blas.bundle
Undefined symbols for architecture arm64:
  "_na_data_type", referenced from:
      _blas_s_sdot in blas_s.o
      _blas_s_snrm2 in blas_s.o
      _blas_s_sasum in blas_s.o
      _blas_s_dsdot in blas_s.o
      _blas_s_sdsdot in blas_s.o
      _blas_s_sswap in blas_s.o
      _blas_s_scopy in blas_s.o
      ...
  "_na_ndloop", referenced from:
      _blas_s_sdot in blas_s.o
      _blas_s_snrm2 in blas_s.o
      _blas_s_sasum in blas_s.o
      _blas_s_dsdot in blas_s.o
      _blas_s_sswap in blas_s.o
      _blas_s_scopy in blas_s.o
      _blas_s_ddot in blas_d.o
      ...
  "_na_ndloop3", referenced from:
      _blas_s_sdsdot in blas_s.o
      _blas_s_saxpy in blas_s.o
      _blas_s_srot in blas_s.o
      _blas_s_srotm in blas_s.o
      _blas_s_sscal in blas_s.o
      _blas_s_sgemv in blas_s.o
      _blas_s_strmv in blas_s.o
      ...
  "_nary_dup", referenced from:
      _blas_s_saxpy in blas_s.o
      _blas_s_srot in blas_s.o
      _blas_s_srotm in blas_s.o
      _blas_s_sscal in blas_s.o
      _blas_s_sgemv in blas_s.o
      _blas_s_strmv in blas_s.o
      _blas_s_ssymv in blas_s.o
      ...
  "_nary_eShapeError", referenced from:
      _blas_s_sdot in blas_s.o
      _blas_s_snrm2 in blas_s.o
      _blas_s_sasum in blas_s.o
      _blas_s_dsdot in blas_s.o
      _blas_s_sdsdot in blas_s.o
      _blas_s_sswap in blas_s.o
      _blas_s_scopy in blas_s.o
      ...
  "_nary_get_pointer_for_read", referenced from:
      _blas_s_srotm in blas_s.o
      _blas_s_drotm in blas_d.o
  "_numo_cDComplex", referenced from:
      _blas_s_zdotc in blas_z.o
      _blas_s_zdotu in blas_z.o
      _blas_s_dznrm2 in blas_z.o
      _blas_s_dzasum in blas_z.o
      _blas_s_zswap in blas_z.o
      _blas_s_zcopy in blas_z.o
      _blas_s_zaxpy in blas_z.o
      ...
  "_numo_cDFloat", referenced from:
      _blas_s_dsdot in blas_s.o
      _blas_s_ddot in blas_d.o
      _blas_s_dnrm2 in blas_d.o
      _blas_s_dasum in blas_d.o
      _blas_s_dswap in blas_d.o
      _blas_s_dcopy in blas_d.o
      _blas_s_daxpy in blas_d.o
      ...
  "_numo_cSComplex", referenced from:
      _blas_s_cdotc in blas_c.o
      _blas_s_cdotu in blas_c.o
      _blas_s_scnrm2 in blas_c.o
      _blas_s_scasum in blas_c.o
      _blas_s_cswap in blas_c.o
      _blas_s_ccopy in blas_c.o
      _blas_s_caxpy in blas_c.o
      ...
  "_numo_cSFloat", referenced from:
      _blas_s_sdot in blas_s.o
      _blas_s_snrm2 in blas_s.o
      _blas_s_sasum in blas_s.o
      _blas_s_dsdot in blas_s.o
      _blas_s_sdsdot in blas_s.o
      _blas_s_sswap in blas_s.o
      _blas_s_scopy in blas_s.o
      ...
  "_sym_init", referenced from:
      _blas_s_sgemv in blas_s.o
      _blas_s_strmv in blas_s.o
      _blas_s_ssymv in blas_s.o
      _blas_s_ssyr in blas_s.o
      _blas_s_sger in blas_s.o
      _blas_s_ssyr2 in blas_s.o
      _blas_s_sgemm in blas_s.o
      ...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [blas.bundle] Error 
petercip commented 1 year ago

Resolved this by installing openblas with homebrew, then:

gem install numo-linalg -- --with-ldflags="-Wl,-undefined,dynamic_lookup" --with-openblas-dir=/opt/homebrew/opt/openblas