lfortran / lfortran

Official main repository for LFortran
https://lfortran.org/
Other
937 stars 147 forks source link

Can't compile on Void Linux: `p::llvm` has invalid `INTERFACE_INCLUDE_DIRECTORIES` #886

Open rjzak opened 1 year ago

rjzak commented 1 year ago
$ cat version
0.16.0-1050-g7916ec07a
$ cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_LLVM=yes -DCMAKE_INSTALL_PREFIX=`pwd`/inst .
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /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: /bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /usr/lib/libz.a (found version "1.2.12") 
-- Found LibXml2: /usr/lib64/libxml2.so (found version "2.9.13") 
-- Found LLVM 12.0.1
-- Using LLVMConfig.cmake in: /lib64/cmake/llvm

Configuration results
---------------------
LFORTRAN_VERSION: 0.16.0-1050-g7916ec07a
CPACK_PACKAGE_FILE_NAME: lfortran-0.16.0-1050-g7916ec07a-Linux
C compiler      : /bin/cc
C++ compiler    : /bin/c++
Build type: Debug
C compiler flags      : -g
C++ compiler flags    : -Wall -Wextra -g -ggdb
Installation prefix: /home/rjzak/Downloads/lfortran/inst
WITH_LFORTRAN_ASSERT: yes
LFORTRAN_STATIC_BIN: no
LFORTRAN_BUILD_TO_WASM: no
WITH_STACKTRACE: no
WITH_UNWIND: no
WITH_BFD: no
WITH_DWARFDUMP: no
WITH_LINKH: no
WITH_MACHO: no
HAVE_LFORTRAN_DEMANGLE: yes
WITH_LLVM: yes
WITH_XEUS: no
WITH_JSON: no
WITH_FMT: no
WITH_LFORTRAN_BINARY_MODFILES: YES
WITH_RUNTIME_LIBRARY: YES
WITH_WHEREAMI: yes
WITH_ZLIB: yes
WITH_TARGET_AARCH64: no
WITH_TARGET_X86: no
WITH_TARGET_WASM: no
-- Configuring done
CMake Error in src/libasr/CMakeLists.txt:
  Imported target "p::llvm" includes non-existent path

    "//include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

$ uname -a
Linux behemoth 5.18.19_1 #1 SMP Fri Aug 26 14:37:39 UTC 2022 ppc64le GNU/Linux

$ lsb_release -a
LSB Version:    1.0
Distributor ID: VoidLinux
Description:    Void Linux
Release:    rolling
Codename:   void

$ clang --version
clang version 12.0.1
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
InstalledDir: /bin

CMake seems to grab GNU compilers despite being able to locate LLVM. Is LLVM 12.0 not new enough?

certik commented 1 year ago

We test LLVM 11 and LLVM 14 at the CI, so LLVM 12 should also work.

It seems the problem is somewhere in here on your system:

The LLVM_INCLUDE_DIRS is incorrect; this variable is set by this line I think: https://github.com/lfortran/lfortran/blob/107de5718008ae05deb1da173e54efdde9316d79/CMakeLists.txt#L124, so possibly your LLVM installation has broken CMake files.

How did you install LLVM?

rjzak commented 1 year ago

LLVM was installed via the package manager, and LLVM does have a bunch of cmake files, and it does seem that LLVM is found. Just a bad variable is set.

certik commented 1 year ago

Ok. Did you manage to resolve it? If so, then you can close the issue. If not, then let's figure it out.

rjzak commented 1 year ago

Haven't figured it out, and I made sure I have all the LLVM 12 & CMake packages available installed.

$ sudo xbps-query -s "Low Level Virtual"
[*] clang-12.0.1_3                Low Level Virtual Machine - C language family frontend
[*] clang-analyzer-12.0.1_3       Low Level Virtual Machine - A source code analysis framework
[*] clang-tools-extra-12.0.1_3    Low Level Virtual Machine - Extra Clang tools
[*] libclang-12.0.1_3             Low Level Virtual Machine - C frontend runtime library
[*] libclang-cpp-12.0.1_3         Low Level Virtual Machine - C frontend runtime library (C++ interface)
[*] libcxx-12.0.1_3               Low Level Virtual Machine - C++ standard library
[*] libcxx-devel-12.0.1_3         Low Level Virtual Machine - C++ standard library - development files
[*] libcxxabi-12.0.1_3            Low Level Virtual Machine - low level support for libc++
[*] libcxxabi-devel-12.0.1_3      Low Level Virtual Machine - low level support for libc++ - development files
[*] libllvm12-12.0.1_3            Low Level Virtual Machine - runtime library
[*] libomp-12.0.1_3               Low Level Virtual Machine - Clang OpenMP support library
[*] libomp-devel-12.0.1_3         Low Level Virtual Machine - Clang OpenMP support library - development files
[*] lld-12.0.1_3                  Low Level Virtual Machine - linker
[*] lld-devel-12.0.1_3            Low Level Virtual Machine - linker - development files
[*] lldb-12.0.1_3                 Low Level Virtual Machine - LLDB debugger
[*] llvm-libunwind-12.0.1_3       Low Level Virtual Machine - libunwind
[*] llvm-libunwind-devel-12.0.1_3 Low Level Virtual Machine - libunwind - development files
[*] llvm12-12.0.1_3               Low Level Virtual Machine

$ sudo xbps-query -s cmake
[*] cmake-3.24.2_1               Cross-platform, open-source build system
[*] extra-cmake-modules-5.98.0_1 Extra modules and scripts for CMake
certik commented 1 year ago

Keep the issue open until we figure it out. Are you using Void Linux? I would need to install it and debug it to see what the problem could be.

rjzak commented 1 year ago

I am using Void Linux, but for PowerPC64LE, which complicates things since it's an unofficial port, and Void for x86_64 may behave differently. I can investigate as well, but I'm not sure where the p variable in p::llvm comes from.

certik commented 1 year ago

The p variable is defined here: https://github.com/lfortran/lfortran/blob/107de5718008ae05deb1da173e54efdde9316d79/CMakeLists.txt#L167, it's just p::llvm as the cmake name of the target.