tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

cmake error #224

Closed bentxt closed 1 year ago

bentxt commented 1 year ago

Hi

I get this error, with no further explenations ...

cmake ../dale
CMake Error at CMakeLists.txt:17 (message):
  Unable to execute '/usr/local/opt/llvm/bin/llvm-config': 0
The mentioned executable exists totheger with a bunch of of other installs.
-- Configuring incomplete, errors occurred!
ls /usr/local/opt/ | grep llvm
llvm
llvm@11
llvm@14
llvm@15
llvm@16
tomhrr commented 1 year ago

Thanks for this. It looks like the llvm-config check in the CMake file is not correct for macOS at least, so it's been disabled. It should be possible to build it now.

bentxt commented 1 year ago

thanks I've tried it again, here is what I get

cmake ../dale -- The C compiler identification is AppleClang 14.0.3.14030022 -- The CXX compiler identification is AppleClang 14.0.3.14030022 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:17 (message): Unable to execute '/usr/local/opt/llvm/bin/llvm-config': 0

-- Configuring incomplete, errors occurred!

bentxt commented 1 year ago
/usr/local/opt/llvm/bin/llvm-config --version
16.0.2
tomhrr commented 1 year ago

It looks like it's still using the old CMakeLists.txt file. Could you try removing the existing checkout, re-cloning the repository, and building again?

bentxt commented 1 year ago

albeit installed, cmake doesn't seem to find the proper llvm installation

...
-- System processor: x86_64
-- System version: 22.4.0
CMake Error at CMakeLists.txt:93 (message):
  LLVM <= 14.0 is required.

So when given the path manually it is continuing

 5 #find_program(LLVM_CONFIG llvm-config DOC "path to llvm-config")
  6 set(LLVM_CONFIG "/usr/local/opt/llvm@14/bin/llvm-config")
  7 set(CLANG "/usr/local/opt/llvm@14/bin/clang")
  8 #find_program(CLANG clang DOC "path to clang")

but then fails again not finding lib-ffi which resides in ' /usr/local/opt/libffi/'

...
[ 71%] Linking CXX shared library libdale.dylib
ld: warning: directory not found for option '-L/usr/lib-lffi'
ld: warning: directory not found for option '-L/usr/lib-lffi'
ld: file too small (length=0) file 'CMakeFiles/dale.dir/src/dale/Module/Writer/Writer.cpp.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libdale.0.3.dylib] Error 1
make[1]: *** [CMakeFiles/dale.dir/all] Error 2
make: *** [all] Error 2
bentxt commented 1 year ago

I think it worked now after doing this 2 things

set the path to find the pc files export PKG_CONFIG_PATH="/usr/local/opt/libffi/:/usr/local/opt/libffi/lib/pkgconfig/:$PKG_CONFIG_PATH"

still failed with this

 0%] Linking CXX shared library libdale.dylib
ld: warning: directory not found for option '-L/usr/local/Cellar/libffi/3.4.4/lib-lffi'
ld: warning: directory not found for option '-L/usr/local/Cellar/libffi/3.4.4/lib-lffi'
ld: file too small (length=0) file 'CMakeFiles/dale.dir/src/dale/BasicTypes/BasicTypes.cpp.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libdale.0.3.dylib] Error 1
make[1]: *** [CMakeFiles/dale.dir/all] Error 2
make: *** [all] Error 2

finally symbolic linking seems to solve it ln -s /usr/local/Cellar/libffi/3.4.4/lib /usr/local/Cellar/libffi/3.4.4/lib-lffi

tomhrr commented 1 year ago

5 #find_program(LLVM_CONFIG llvm-config DOC "path to llvm-config") 6 set(LLVM_CONFIG "/usr/local/opt/llvm@14/bin/llvm-config") 7 set(CLANG "/usr/local/opt/llvm@14/bin/clang") 8 #find_program(CLANG clang DOC "path to clang")

For both of these, -D can be used to set the value without modifying the CMakeLists.txt file. For example:

cmake . -DLLVM_CONFIG=/usr/local/bin/llvm-config -DCC=/usr/local/bin/clang

See also https://github.com/tomhrr/dale/blob/master/doc/all.md#c-compiler. I'll see about updating the documentation for the FFI problem.

bentxt commented 1 year ago

This is my cmake command that works (but I think the lib-ffi stuff has to be configure like described above in order to work)

cmake ../dale -DLLVM_CONFIG=/usr/local/opt/llvm@14/bin/llvm-config -DCC=/usr/local/opt/llvm@14/bin/clang