lldb-tools / lldb-mi

LLDB's machine interface driver
https://lldb.llvm.org
Other
162 stars 53 forks source link

Build issue on Linux (Ubuntu 20) #107

Open buchs opened 1 year ago

buchs commented 1 year ago
# cmake .
-- Found LLVM 16.0.4
-- Using LLVMConfig.cmake in: /usr/lib/llvm-16/cmake
-- Building with -fPIC
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
lib_lldb
    linked by target "lldb-mi" in directory /root/lldb-mi/src

-- Configuring incomplete, errors occurred!
See also "/root/lldb-mi/CMakeFiles/CMakeOutput.log".
See also "/root/lldb-mi/CMakeFiles/CMakeError.log".

Note, for my system I have Clang 15 installed along side Clang 16. The former is linked through commands like clang, clang++, cc and c++. So I define these environment variables:

export CMAKE_C_COMPILER_ID='Clang'
export CMAKE_C_COMPILER='/usr/bin/clang-16'
export CMAKE_CXX_COMPILER_ID='Clang'
export CMAKE_CXX_COMPILER='/usr/bin/clang++-16'
export LLDB_DEBUGSERVER_PATH='/usr/lib/llvm-16/lib/liblldb'
sunshaoce commented 1 year ago

When building LLVM, did you build lldb?

 -DLLVM_ENABLE_PROJECTS="clang;lldb"
buchs commented 1 year ago

Yes, lldb was built for the LLVM-16 toolchain. It was not for -15. But, to be clear, I am just using the apt package:

llvm_version='16'
curl -sS https://apt.llvm.org/llvm.sh -o llvm_sh
chmod +x llvm_sh
./llvm_sh $llvm_version all  &> /dev/null  # too much noise
rm llvm_sh
apt-get -qq install clang-format-$llvm_version
sunshaoce commented 1 year ago

I have tested it, and indeed it cannot be done this way. You can only build LLVM manually and then build lldb-mi.

llvm_path='~/llvm'

git clone https://github.com/llvm/llvm-project.git --depth=1 -b release/16.x
cd llvm-project
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$llvm_path  -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lldb" -DCMAKE_CXX_COMPILER=clang++-15 -G Ninja ../llvm
ninja install

cd ../..

git clone https://github.com/lldb-tools/lldb-mi.git --depth=1
cd lldb-mi
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=$llvm_path -DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_INSTALL_PREFIX=$llvm_path -GNinja ..
ninja install
buchs commented 1 year ago

OK, thanks for looking into it.

mikebeaton commented 9 months ago

@buchs - On Ubuntu avoiding this error just requires sudo apt install -y liblldb-15-dev, or whatever your correct version is. This avoids needing to build llvm yourself. apt list --installed | grep liblldb to see what version of lldb you have installed.

vibrys commented 2 weeks ago

I've just compiled lldb-mi on ubuntu.20.04. I happened to use llvm-18.1.8 that was installed through https://apt.llvm.org/llvm.sh script.

I did following steps to compile/install lldb-mi:

  prompt# apt install libcurl4-openssl-dev libedit-dev libzstd-dev
  prompt# apt install liblldb-18-dev
  prompt# mkdir Build-18-a6c8c66 && cd Build-18-a6c8c66
  prompt# /opt/cmake-3.29.3/bin/cmake -DLLVM_DIR=/lib/llvm-18/cmake -DCMAKE_INSTALL_PREFIX=/opt/lldb-18-mi-a6c8c66 ../ 2>&1 | tee cmake.log

unfortunatelly, lldb-mi crashes. Here are the details

As mentioned, although lldb-mi compilation succeeded, the cmake command's log keeps one quite strange line:

  -- Looking for os_signpost_interval_begin - not found
  -- Can't find LLVM shared library, falling back to static linking LLVMSupport    <--- this one
  -- Configuring done (4.4s)
  -- Generating done (0.0s)
  -- Build files have been written to: /usr/src/lldb-mi/Build

I have 2 questions:

  1. if you happen to use lldb-mi on ubuntu (preferably 20.04) did you notice such line your configs?
  2. which llvm version did you succeed lldb-mi to run against?
vibrys commented 2 weeks ago

maybe one more technicality:

ldd `which lldb-mi`
    linux-vdso.so.1 (0x00007ffc0a59c000)
    liblldb-18.so.1 => /usr/lib/llvm-18/lib/liblldb-18.so.1 (0x00007f1670039000)
    libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f166ffee000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f166ffcb000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f166ffc5000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f166fde3000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f166fc94000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f166fc77000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f166fa85000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f167129c000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f166fa69000)
    libpython3.8.so.1.0 => /lib/x86_64-linux-gnu/libpython3.8.so.1.0 (0x00007f166f513000)
    libcurl.so.4 => /lib/x86_64-linux-gnu/libcurl.so.4 (0x00007f166f480000)
    libpanel.so.6 => /lib/x86_64-linux-gnu/libpanel.so.6 (0x00007f166f479000)
    libncurses.so.6 => /lib/x86_64-linux-gnu/libncurses.so.6 (0x00007f166f44e000)
    libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f166f294000)
    libedit.so.2 => /lib/x86_64-linux-gnu/libedit.so.2 (0x00007f166f25c000)
    libclang-cpp.so.18.1 => /usr/lib/llvm-18/lib/../lib/libclang-cpp.so.18.1 (0x00007f166b35d000)
    libLLVM-18.so.18.1 => /lib/x86_64-linux-gnu/libLLVM-18.so.18.1 (0x00007f1663d65000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f1663d35000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f1663d30000)
    libnghttp2.so.14 => /lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f1663d06000)
    libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f1663ce5000)
    librtmp.so.1 => /lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f1663cc5000)
    libssh.so.4 => /lib/x86_64-linux-gnu/libssh.so.4 (0x00007f1663c56000)
    libpsl.so.5 => /lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f1663c41000)
    libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f1663bae000)
    libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f16638d7000)
    libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f166388a000)
    libldap_r-2.4.so.2 => /lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f1663834000)
    liblber-2.4.so.2 => /lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f1663823000)
    libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f1663813000)
    libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f166362d000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f1663604000)
    libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f16635ea000)
    libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007f16635de000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f16635d2000)
    libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f1663529000)
    libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f16633a7000)
    libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f16631d1000)
    libhogweed.so.5 => /lib/x86_64-linux-gnu/libhogweed.so.5 (0x00007f166319a000)
    libnettle.so.7 => /lib/x86_64-linux-gnu/libnettle.so.7 (0x00007f166315e000)
    libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f16630da000)
    libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f1662ffd000)
    libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f1662fcc000)
    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f1662fc5000)
    libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f1662fb6000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f1662f98000)
    libsasl2.so.2 => /lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f1662f7b000)
    libgssapi.so.3 => /lib/x86_64-linux-gnu/libgssapi.so.3 (0x00007f1662f36000)
    libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f1662f13000)
    libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f1661452000)
    libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f166131a000)
    libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f1661304000)
    libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f16612fd000)
    libheimntlm.so.0 => /lib/x86_64-linux-gnu/libheimntlm.so.0 (0x00007f16612f1000)
    libkrb5.so.26 => /lib/x86_64-linux-gnu/libkrb5.so.26 (0x00007f166125e000)
    libasn1.so.8 => /lib/x86_64-linux-gnu/libasn1.so.8 (0x00007f16611b6000)
    libhcrypto.so.4 => /lib/x86_64-linux-gnu/libhcrypto.so.4 (0x00007f166117e000)
    libroken.so.18 => /lib/x86_64-linux-gnu/libroken.so.18 (0x00007f1661165000)
    libwind.so.0 => /lib/x86_64-linux-gnu/libwind.so.0 (0x00007f166113b000)
    libheimbase.so.1 => /lib/x86_64-linux-gnu/libheimbase.so.1 (0x00007f1661129000)
    libhx509.so.5 => /lib/x86_64-linux-gnu/libhx509.so.5 (0x00007f16610d9000)
    libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f1660fb0000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f1660f75000)
vibrys commented 2 weeks ago

using @KonanTheLibrarian 's script from #90 (here), didn't help here unfortunately. Then I've used the same script to compile lldb-mi against llvm-17 and .... it works correct! Also I DO NOT observe following line from cmake tool this time (please see above):

-- Can't find LLVM shared library, falling back to static linking LLVMSupport