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

Can't get ameba to compile on macOS 12.6 #285

Closed
tjbarber opened this issue Oct 29, 2022 · 6 comments · Fixed by #286
Closed

Can't get ameba to compile on macOS 12.6 #285

tjbarber opened this issue Oct 29, 2022 · 6 comments · Fixed by #286
Milestone

Comments

@tjbarber
Copy link

Hey y'all, I'm struggling to get ameba to compile on an M1 Mac. I've installed crystal through brew. This is my output when I run make.

➜  ameba git:(master) make
shards build -Dpreview_mt
Dependencies are satisfied
Building: ameba
Error target ameba failed to compile:
Undefined symbols for architecture arm64:
  "_EVP_MD_size", referenced from:
      _*Digest::SHA1@OpenSSL::Digest#digest_size:Int32 in D-igest5858S-H-A-1.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc "${@}" -o /Users/tjbarber/Projects/ameba/bin/ameba  -rdynamic -L/opt/homebrew/lib -L/usr/lib `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -L/opt/homebrew/Cellar/libyaml/0.2.5/lib -lyaml -lpcre -lgc -L/opt/homebrew/Cellar/libevent/2.1.12/lib -levent_pthreads -levent -L/opt/homebrew/Cellar/libevent/2.1.12/lib -levent -liconv`

make: *** [bin/ameba] Error 1

This is my crystal env:

CRYSTAL_CACHE_DIR=/Users/tjbarber/.cache/crystal
CRYSTAL_PATH=lib:/opt/homebrew/Cellar/crystal/1.6.1/libexec/../share/crystal/src
CRYSTAL_VERSION=1.6.1
CRYSTAL_LIBRARY_PATH=/opt/homebrew/lib:/usr/lib
CRYSTAL_OPTS=''

Here is my brew list, just in case I'm missing a dependency (I don't think I am, this seems like a linking issue with openssl?):

➜  ameba git:(master) brew list
==> Formulae
apr			ctags			gradle@6		libpthread-stubs	libyaml			openjdk			readline		xorgproto
apr-util		elasticsearch-full	graphite2		libtiff			little-cms2		openjdk@11		redis			xz
autoconf		fontconfig		harfbuzz		libtool			llvm@11			openssl@1.1		ruby-build		z3
automake		freetype		heroku			libx11			llvm@14			openssl@3		screenresolution	zstd
bat			fzf			heroku-node		libxau			lolcat			pcre			six
bdw-gc			gdbm			icu4c			libxcb			lz4			pcre2			sqlite
ca-certificates		gettext			jpeg-turbo		libxdmcp		lzo			pixman			subversion
cairo			giflib			libevent		libxext			m4			pkg-config		the_silver_searcher
coreutils		glib			libiconv		libxml2			mpdecimal		python@3.10		unixodbc
crystal			gmp			libpng			libxrender		neofetch		rbenv			utf8proc

==> Casks
brave-browser	discord		firefox		iterm2		macvim		ngrok		postico		vlc		vscodium
@tjbarber tjbarber changed the title Can't get ameba to compile on M1 Mac Can't get ameba to compile on M1 Mac running macOS 12.6 Oct 29, 2022
@Sija
Copy link
Member

Sija commented Oct 29, 2022

That's a problem with your crystal installation, there's nothing to do here from the ameba's side.

@Sija Sija closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2022
@Sija Sija added the invalid label Oct 29, 2022
@veelenga
Copy link
Member

@tjbarber i don't think it is related to M1 / macOS 12.6. I have the same setup and it compiles successfully on my end.

@straight-shoota
Copy link
Contributor

@tjbarber It looks like you're either missing libcrypto or the version you have installed is incompatible. You can get assistance for this problem at https://forum.crystal-lang.org/ or in one of the community chats (https://crystal-lang.org/community/#chat).

@straight-shoota
Copy link
Contributor

@veelenga @Sija The problem is likely caused by a missing lib dependency.
But there's actually no mention in the installation instructions that ameba requires libcrypto. It does so by using Digest::SHA1 which is based on OpenSSL. So it's not a direct dependency, but through stdlib. Still, libcrypto is an optional dependency for stdlib and applications that use it should better mention that for complete installation instructions.

@straight-shoota
Copy link
Contributor

straight-shoota commented Oct 29, 2022

Ideally, ameba shouldn't depend on libcrypto. A native Crystal implementation would be much easier and avoid an unnecessary dependency. Stdlib currently has no crypographic hash algorithm implemented in native Crystal, though.

But the only use of Digest in ameba is this:

checksum = Digest::SHA1.hexdigest(source.code)

I'm pretty sure an internal checksum for recognizing duplicates does not need a cryptographic hash. String#hash should suffice for that.

@Sija
Copy link
Member

Sija commented Oct 29, 2022

@straight-shoota Good catch, thanks! We definitely shouldn't depend on libcrypto, I can prepare a PR fixing that.

ftr, this dependency was silently introduced in #248.

@Sija Sija reopened this Oct 29, 2022
@Sija Sija changed the title Can't get ameba to compile on M1 Mac running macOS 12.6 Can't get ameba to compile on macOS 12.6 Oct 29, 2022
@Sija Sija closed this as completed in #286 Oct 30, 2022
@Sija Sija removed the invalid label Oct 30, 2022
@Sija Sija added this to the 1.3.0 milestone Oct 30, 2022
rjnienaber added a commit to rjnienaber/amazonite that referenced this issue Feb 17, 2023
fixes mac build issue because of a dependency on libcrypto (crystal-ameba/ameba#285)
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

Successfully merging a pull request may close this issue.

4 participants