marcboeker / go-duckdb

go-duckdb provides a database/sql driver for the DuckDB database engine.
MIT License
583 stars 96 forks source link

found architecture 'arm64', required architecture 'x86_64' on mac os #215

Closed mariusgrigoriu closed 1 month ago

mariusgrigoriu commented 2 months ago

A build using tag 1.6.4 on mac os results in link errors like the following:

/usr/local/Cellar/go/1.22.2/libexec/pkg/tool/darwin_amd64/link: running cc failed: exit status 1
ld: warning: ignoring file '/Users/marius/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.4/deps/darwin_amd64/libduckdb.a[265](zstd_opt.cpp.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/Users/marius/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.4/deps/darwin_amd64/libduckdb.a[264](zstd_ldm.cpp.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/Users/marius/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.4/deps/darwin_amd64/libduckdb.a[263](zstd_lazy.cpp.o)': found architecture 'arm64', required architecture 'x86_64'
Undefined symbols for architecture x86_64:
  "_duckdb_append_data_chunk", referenced from:
      __cgo_c16f5b1d2715_Cfunc_duckdb_append_data_chunk in 000014.o
  "_duckdb_appender_column_count", referenced from:
      __cgo_c16f5b1d2715_Cfunc_duckdb_appender_column_count in 000014.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've been using commit 9b833d5fb6c2dc6db546767e2e2b7b6c07c07b0c without problem, so it must have been one of the May commits that broke things.

begelundmuller commented 1 month ago

I'm observing the same – it appears that since upgrading to DuckDB 0.10.2, the .a file for x86 is actually an arm64 file:

Observed on main:

lipo -info deps/darwin_amd64/libduckdb.a    
Non-fat file: deps/darwin_amd64/libduckdb.a is architecture: arm64

Observed on v1.6.3:

lipo -info deps/darwin_amd64/libduckdb.a    
Non-fat file: deps/darwin_amd64/libduckdb.a is architecture: x86_64
begelundmuller commented 1 month ago

The issue appears to be that make deps.darwin.amd64 produces an arm64 binary when running on an arm64 machine:

> make deps.darwin.amd64
> lipo -info deps/darwin_amd64/libduckdb.a
Non-fat file: deps/darwin_amd64/libduckdb.a is architecture: arm64

As a short-term workaround, I was able to solve this issue by changing runs-on: macos-latest to runs-on: macos-13 (which still uses amd64 arch) for the darwin_amd64 job in .github/workflows/deps.yaml. But that is likely not a sustainable long-term solution.

marcboeker commented 1 month ago

@begelundmuller Thanks! It seems that macos-13 is the latest running on amd64 and macos-latest now points to macOS 14 running on an M1. See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-private-repositories A fix has been pushed to v1.6.5.