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

Any plan to support macbooks with M1? #37

Closed
hellohj opened this issue May 2, 2022 · 5 comments
Closed

Any plan to support macbooks with M1? #37

hellohj opened this issue May 2, 2022 · 5 comments

Comments

@hellohj
Copy link

hellohj commented May 2, 2022

I tried to load one of extensions and got this error. Do you have a plan to support M1? Thanks.

sqlite> .load ./re
Error: dlopen(./re.dylib, 0x000A): tried: './re.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/xx/Downloads/re.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
@nalgeon
Copy link
Owner

nalgeon commented May 3, 2022

I use GitHub Actions to build the binaries for each platform. Currently GitHub does not support M1 and has no ETA for such support. So the answer is no, unfortunately — not until GitHub supports it.

@nalgeon nalgeon closed this as completed May 3, 2022
@abarisain
Copy link

abarisain commented May 3, 2022

Hi,

Clang supports cross compilation for m1 macs using -target

lipo can then be used to make a "fat" framework, which contains both architectures : https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary

Here is a quick and dirty patch for the makefile that works from both an intel mac and a m1 mac, both producing the same files:

compile-macos:
	gcc -fPIC -dynamiclib -I src src/sqlite3-crypto.c src/crypto/*.c -o dist/crypto.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-fileio.c -o dist/fileio.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-fuzzy.c src/fuzzy/*.c -o dist/fuzzy.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-ipaddr.c -o dist/ipaddr.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-json1.c -o dist/json1.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-math.c -o dist/math.dylib -lm -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-re.c src/re.c -o dist/re.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-stats.c -o dist/stats.dylib -lm -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-text.c -o dist/text.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-unicode.c -o dist/unicode.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-uuid.c -o dist/uuid.dylib -target x86_64-apple-macos10.12
	gcc -fPIC -dynamiclib -I src src/sqlite3-vsv.c -o dist/vsv.dylib -lm -target x86_64-apple-macos10.12

compile-macos-arm:
	gcc -fPIC -dynamiclib -I src src/sqlite3-crypto.c src/crypto/*.c -o dist/crypto.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-fileio.c -o dist/fileio.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-fuzzy.c src/fuzzy/*.c -o dist/fuzzy.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-ipaddr.c -o dist/ipaddr.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-json1.c -o dist/json1.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-math.c -o dist/math.dylib -lm -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-re.c src/re.c -o dist/re.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-stats.c -o dist/stats.dylib -lm -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-text.c -o dist/text.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-unicode.c -o dist/unicode.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-uuid.c -o dist/uuid.dylib -target arm64-apple-macos11
	gcc -fPIC -dynamiclib -I src src/sqlite3-vsv.c -o dist/vsv.dylib -lm -target arm64-apple-macos11

compile-macos-fat:
	rm -rf dist-intel/
	rm -rf dist-arm/
	make prepare-dist
	make compile-macos-arm
	mv dist dist-arm
	make prepare-dist
	make compile-macos
	mv dist dist-intel
	make prepare-dist
	lipo -create -output dist/crypto.dylib dist-intel/crypto.dylib dist-arm/crypto.dylib
	lipo -create -output dist/fileio.dylib dist-intel/fileio.dylib dist-arm/fileio.dylib
	lipo -create -output dist/fuzzy.dylib dist-intel/fuzzy.dylib dist-arm/fuzzy.dylib
	lipo -create -output dist/ipaddr.dylib dist-intel/ipaddr.dylib dist-arm/ipaddr.dylib
	lipo -create -output dist/json1.dylib dist-intel/json1.dylib dist-arm/json1.dylib
	lipo -create -output dist/math.dylib dist-intel/math.dylib dist-arm/math.dylib
	lipo -create -output dist/re.dylib dist-intel/re.dylib dist-arm/re.dylib
	lipo -create -output dist/stats.dylib dist-intel/stats.dylib dist-arm/stats.dylib
	lipo -create -output dist/text.dylib dist-intel/text.dylib dist-arm/text.dylib
	lipo -create -output dist/unicode.dylib dist-intel/unicode.dylib dist-arm/unicode.dylib
	lipo -create -output dist/uuid.dylib dist-intel/uuid.dylib dist-arm/uuid.dylib
	lipo -create -output dist/vsv.dylib dist-intel/vsv.dylib dist-arm/vsv.dylib

output of compile-macos-fat:

% lipo -info dist/uuid.dylib 
Architectures in the fat file: dist/uuid.dylib are: x86_64 arm64 

The only issue being that you can't run the tests, so M1 users will run untested binaries.

@nalgeon
Copy link
Owner

nalgeon commented May 4, 2022

Thanks @abarisain, I'll look into it!

@tcb678
Copy link

tcb678 commented May 19, 2022

@abarisain On my M1, with your Makefile:

…/sqlean λ  make compile-macos-arm                                                                             tim@buachaille 
gcc -fPIC -dynamiclib -I src src/sqlite3-crypto.c src/crypto/*.c -o dist/crypto.dylib -target arm64-apple-macos11
Undefined symbols for architecture arm64:
  "_sqlite3_create_function", referenced from:
      _sqlite3_crypto_init in sqlite3-crypto-dfbbc7.o
  "_sqlite3_result_blob", referenced from:
      _sqlite3_hash in sqlite3-crypto-dfbbc7.o
  "_sqlite3_result_error", referenced from:
      _sqlite3_hash in sqlite3-crypto-dfbbc7.o
  "_sqlite3_result_null", referenced from:
      _sqlite3_hash in sqlite3-crypto-dfbbc7.o
  "_sqlite3_user_data", referenced from:
      _sqlite3_hash in sqlite3-crypto-dfbbc7.o
  "_sqlite3_value_blob", referenced from:
      _sqlite3_hash in sqlite3-crypto-dfbbc7.o
  "_sqlite3_value_bytes", referenced from:
      _sqlite3_hash in sqlite3-crypto-dfbbc7.o
  "_sqlite3_value_text", referenced from:
      _sqlite3_hash in sqlite3-crypto-dfbbc7.o
  "_sqlite3_value_type", referenced from:
      _sqlite3_hash in sqlite3-crypto-dfbbc7.o
ld: symbol(s) not found for architecture arm64

@nalgeon
Copy link
Owner

nalgeon commented Aug 31, 2022

Added M1 (arm64) binaries in 0.15.4.

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