I’m getting this error when running cc
:
$ cc crystal.o -o .build/crystal -rdynamic src/llvm/ext/llvm_ext.o `llvm-config --libs --system-libs --ldflags 2> /dev/null` -lstdc++ -lpcre -lm -lgc -lpthread -levent -lrt -ldl
ld.lld: error: undefined symbol: ffi_type_pointer
>>> referenced by type.cr:60 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:60)
>>> crystal.o:(*Crystal::FFI::Type::pointer:Crystal::FFI::Type)
>>> referenced by type.cr:60 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:60)
>>> crystal.o:(*Crystal::FFI::Type::pointer:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_void
>>> referenced by type.cr:16 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:16)
>>> crystal.o:(*Crystal::FFI::Type::void:Crystal::FFI::Type)
>>> referenced by type.cr:16 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:16)
>>> crystal.o:(*Crystal::FFI::Type::void:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_sint8
>>> referenced by type.cr:24 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:24)
>>> crystal.o:(*Crystal::FFI::Type::sint8:Crystal::FFI::Type)
>>> referenced by type.cr:24 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:24)
>>> crystal.o:(*Crystal::FFI::Type::sint8:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_uint8
>>> referenced by type.cr:20 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:20)
>>> crystal.o:(*Crystal::FFI::Type::uint8:Crystal::FFI::Type)
>>> referenced by type.cr:20 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:20)
>>> crystal.o:(*Crystal::FFI::Type::uint8:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_sint16
>>> referenced by type.cr:32 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:32)
>>> crystal.o:(*Crystal::FFI::Type::sint16:Crystal::FFI::Type)
>>> referenced by type.cr:32 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:32)
>>> crystal.o:(*Crystal::FFI::Type::sint16:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_uint16
>>> referenced by type.cr:28 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:28)
>>> crystal.o:(*Crystal::FFI::Type::uint16:Crystal::FFI::Type)
>>> referenced by type.cr:28 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:28)
>>> crystal.o:(*Crystal::FFI::Type::uint16:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_sint32
>>> referenced by type.cr:40 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:40)
>>> crystal.o:(*Crystal::FFI::Type::sint32:Crystal::FFI::Type)
>>> referenced by type.cr:40 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:40)
>>> crystal.o:(*Crystal::FFI::Type::sint32:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_uint32
>>> referenced by type.cr:36 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:36)
>>> crystal.o:(*Crystal::FFI::Type::uint32:Crystal::FFI::Type)
>>> referenced by type.cr:36 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:36)
>>> crystal.o:(*Crystal::FFI::Type::uint32:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_sint64
>>> referenced by type.cr:48 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:48)
>>> crystal.o:(*Crystal::FFI::Type::sint64:Crystal::FFI::Type)
>>> referenced by type.cr:48 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:48)
>>> crystal.o:(*Crystal::FFI::Type::sint64:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_uint64
>>> referenced by type.cr:44 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:44)
>>> crystal.o:(*Crystal::FFI::Type::uint64:Crystal::FFI::Type)
>>> referenced by type.cr:44 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:44)
>>> crystal.o:(*Crystal::FFI::Type::uint64:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_float
>>> referenced by type.cr:52 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:52)
>>> crystal.o:(*Crystal::FFI::Type::float:Crystal::FFI::Type)
>>> referenced by type.cr:52 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:52)
>>> crystal.o:(*Crystal::FFI::Type::float:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_type_double
>>> referenced by type.cr:56 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:56)
>>> crystal.o:(*Crystal::FFI::Type::double:Crystal::FFI::Type)
>>> referenced by type.cr:56 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/type.cr:56)
>>> crystal.o:(*Crystal::FFI::Type::double:Crystal::FFI::Type)
ld.lld: error: undefined symbol: ffi_prep_cif
>>> referenced by call_interface.cr:13 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/call_interface.cr:13)
>>> crystal.o:(*Crystal::FFI::CallInterface::new<Crystal::FFI::Type, Array(Crystal::FFI::Type)>:Crystal::FFI::CallInterface)
ld.lld: error: undefined symbol: ffi_prep_cif_var
>>> referenced by call_interface.cr:36 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/call_interface.cr:36)
>>> crystal.o:(*Crystal::FFI::CallInterface::variadic:fixed_args<Crystal::FFI::Type, Array(Crystal::FFI::Type), Int32>:Crystal::FFI::CallInterface)
ld.lld: error: undefined symbol: ffi_call
>>> referenced by call_interface.cr:59 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/call_interface.cr:59)
>>> crystal.o:(*Crystal::FFI::CallInterface#call<Pointer(Void), Pointer(Pointer(Void)), Pointer(Void)>:Nil)
ld.lld: error: undefined symbol: ffi_closure_alloc
>>> referenced by closure.cr:6 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/closure.cr:6)
>>> crystal.o:(*Crystal::FFI::Closure#initialize<Crystal::FFI::CallInterface, Proc(Pointer(Crystal::LibFFI::Cif), Pointer(Void), Pointer(Pointer(Void)), Pointer(Void), Nil), Pointer(Void)>:Nil)
ld.lld: error: undefined symbol: ffi_prep_closure_loc
>>> referenced by closure.cr:11 (/mnt/c/Users/REDACTED/Desktop/crystal/src/compiler/crystal/ffi/closure.cr:11)
>>> crystal.o:(*Crystal::FFI::Closure#initialize<Crystal::FFI::CallInterface, Proc(Pointer(Crystal::LibFFI::Cif), Pointer(Void), Pointer(Pointer(Void)), Pointer(Void), Nil), Pointer(Void)>:Nil)
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
I have no idea why. I haven’t modified the source code at all, and AFAIK those type definitions are already in lib_ffi.cr
Does anyone know what could be causing this?
Also, to get to this stage, I had to run:
chmod +x -R src/llvm/ext/
Because I was getting an “access denied” error when running make deps
And the .build folder didn’t exist for me, so I had to create it manually:
mkdir .build
EDIT: Running with -v gives me this extra output:
clang version 14.0.6
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
"/data/data/com.termux/files/usr/bin/ld.lld" --sysroot=/data/data/com.termux/files -pie -export-dynamic -EL --fix-cortex-a53-843419 --warn-shared-textrel -z now -z relro -z max-page-size=4096 --hash-style=gnu --enable-new-dtags -rpath=/data/data/com.termux/files/usr/lib --eh-frame-hdr -m aarch64linux -export-dynamic -dynamic-linker /system/bin/linker64 -o .build/crystal /data/data/com.termux/files/usr/lib/crtbegin_dynamic.o -L/data/data/com.termux/files/usr/lib -L/data/data/com.termux/files/usr/lib -L/system/lib64 crystal.o src/llvm/ext/llvm_ext.o -lLLVM-14 -lc++_shared -lpcre -lm -lgc -lpthread -levent -lrt -ldl /data/data/com.termux/files/usr/lib/clang/14.0.6/lib/linux/libclang_rt.builtins-aarch64-android.a -l:libunwind.a -ldl -lc /data/data/com.termux/files/usr/lib/clang/14.0.6/lib/linux/libclang_rt.builtins-aarch64-android.a -l:libunwind.a -ldl /data/data/com.termux/files/usr/lib/crtend_android.o