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

Build failure on Ubuntu 20 LTS. #90

Closed
kgfly opened this issue Mar 13, 2022 · 13 comments
Closed

Build failure on Ubuntu 20 LTS. #90

kgfly opened this issue Mar 13, 2022 · 13 comments

Comments

@kgfly
Copy link

kgfly commented Mar 13, 2022

Repro

  1. Following https://apt.llvm.org/, I installed latest llvm "sudo ./llvm.sh all" , which installed clang14
  2. cmake .

Observed:

Performing C SOURCE FILE Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW failed with the following output:
Change Dir: /home/k/src1/lldb-mi/CMakeFiles/CMakeTmp

Run Build Command(s):/bin/make cmTC_a9240/fast && /bin/make -f CMakeFiles/cmTC_a9240.dir/build.make CMakeFiles/cmTC_a9240.dir/build
make[1]: Entering directory '/home/k/src1/lldb-mi/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_a9240.dir/src.c.o
/bin/cc -fPIC -Werror=date-time -DC_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW -Werror -Werror=unguarded-availability-new -o CMakeFiles/cmTC_a9240.dir/src.c.o -c /home/k/src1/lldb-mi/CMakeFiles/CMakeTmp/src.c
cc1: error: '-Werror=unguarded-availability-new': no option -Wunguarded-availability-new
make[1]: *** [CMakeFiles/cmTC_a9240.dir/build.make:66: CMakeFiles/cmTC_a9240.dir/src.c.o] Error 1
make[1]: Leaving directory '/home/k/src1/lldb-mi/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_a9240/fast] Error 2

Source file was:
int main(void) { return 0; }
Performing C++ SOURCE FILE Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW failed with the following output:
Change Dir: /home/k/src1/lldb-mi/CMakeFiles/CMakeTmp

Run Build Command(s):/bin/make cmTC_1db1f/fast && /bin/make -f CMakeFiles/cmTC_1db1f.dir/build.make CMakeFiles/cmTC_1db1f.dir/build
make[1]: Entering directory '/home/k/src1/lldb-mi/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_1db1f.dir/src.cxx.o
/bin/c++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -DCXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW -Werror -Werror=unguarded-availability-new -o CMakeFiles/cmTC_1db1f.dir/src.cxx.o -c /home/k/src1/lldb-mi/CMakeFiles/CMakeTmp/src.cxx
cc1plus: error: '-Werror=unguarded-availability-new': no option -Wunguarded-availability-new
make[1]: *** [CMakeFiles/cmTC_1db1f.dir/build.make:66: CMakeFiles/cmTC_1db1f.dir/src.cxx.o] Error 1
make[1]: Leaving directory '/home/k/src1/lldb-mi/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_1db1f/fast] Error 2

Source file was:
int main() { return 0; }
Determining if the os_signpost_interval_begin exist failed with the following output:
Change Dir: /home/k/src1/lldb-mi/CMakeFiles/CMakeTmp

Run Build Command(s):/bin/make cmTC_e4556/fast && /bin/make -f CMakeFiles/cmTC_e4556.dir/build.make CMakeFiles/cmTC_e4556.dir/build
make[1]: Entering directory '/home/k/src1/lldb-mi/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_e4556.dir/CheckSymbolExists.c.o
/bin/cc -fPIC -Werror=date-time -w -ffunction-sections -fdata-sections -o CMakeFiles/cmTC_e4556.dir/CheckSymbolExists.c.o -c /home/k/src1/lldb-mi/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/k/src1/lldb-mi/CMakeFiles/CMakeTmp/CheckSymbolExists.c:2:10: fatal error: os/signpost.h: No such file or directory
2 | #include <os/signpost.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_e4556.dir/build.make:66: CMakeFiles/cmTC_e4556.dir/CheckSymbolExists.c.o] Error 1
make[1]: Leaving directory '/home/k/src1/lldb-mi/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_e4556/fast] Error 2

File /home/k/src1/lldb-mi/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <os/signpost.h>

int main(int argc, char** argv)
{
(void)argv;
#ifndef os_signpost_interval_begin
return ((int*)(&os_signpost_interval_begin))[argc];
#else
(void)argc;
return 0;
#endif
}

@tkrasnukha
Copy link
Member

As far as I know, test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW should fail on Ubuntu since the option -Wunguarded-availability-new is available only on Apple's operating systems, as well as the header file os/signpost.h in the second test. I guess that you asked this because cmake failed, but what is the real error?

@kgfly
Copy link
Author

kgfly commented Mar 14, 2022

Yes. cmake failed.

Above is from CMakeError.log. It's easy to repro.

To me, the issue is: cmakefile has bugs. So currently it only supports mac build, not linux build.

@tkrasnukha
Copy link
Member

Please, provide the error cmake fails with or attach your CMakeError.log. The errors in tests above are not the reason of the failure.

@kgfly
Copy link
Author

kgfly commented Mar 15, 2022

CMakeError.log
CMakeOutput.log
CMakeCache.txt
Please see the attached.

@tkrasnukha
Copy link
Member

I don't see any failures in the provided logs, only tests that are expected to fail on Ubuntu/with default compiler. What does "cmake ." print to console?

@kgfly
Copy link
Author

kgfly commented Mar 19, 2022

-- Found LLVM 14.0.0
-- Using LLVMConfig.cmake in: /usr/lib/llvm-14/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 /mnt/n/wsl/src1/lldb-mi/src

-- Configuring incomplete, errors occurred!
See also "/mnt/n/wsl/src1/lldb-mi/CMakeFiles/CMakeOutput.log".
See also "/mnt/n/wsl/src1/lldb-mi/CMakeFiles/CMakeError.log".

@tkrasnukha
Copy link
Member

The script llvm.sh doesn't install a required dependency on Ubuntu - liblldb-dev (or liblldb-$LLVM_VERSION-dev). You can add it manually to the PKG variable in the script

if [[ $ALL -eq 1 ]]; then
    # same as in test-install.sh
    # No worries if we have dups
    PKG="$PKG clang-tidy-$LLVM_VERSION clang-format-$LLVM_VERSION clang-tools-$LLVM_VERSION llvm-$LLVM_VERSION-dev lld-$LLVM_VERSION lldb-$LLVM_VERSION liblldb-$LLVM_VERSION-dev llvm-$LLVM_VERSION-tools libomp-$LLVM_VERSION-dev libc++-$LLVM_VERSION-dev libc++abi-$LLVM_VERSION-dev libclang-common-$LLVM_VERSION-dev libclang-$LLVM_VERSION-dev libclang-cpp$LLVM_VERSION-dev libunwind-$LLVM_VERSION-dev"
fi

or request authors to add it.

@tkrasnukha
Copy link
Member

As Readme says,

You need both the LLDB/Clang/LLVM headers and their compiled libraries for the build to work, but not the respective source files.

lldb package provides only executables on Ubuntu, whereas liblldb-dev provides headers and libraries.

@kgfly
Copy link
Author

kgfly commented Mar 22, 2022

Thanks . I am not sure which script you're referring to.

May you please do a fix?

@tkrasnukha
Copy link
Member

I mean this script:

Following https://apt.llvm.org/, I installed latest llvm "sudo ./llvm.sh all" , which installed clang14

It is not a part of this project.

@tkrasnukha
Copy link
Member

Please, follow this issue: opencollab/llvm-jenkins.debian.net#16

@aeris170
Copy link

aeris170 commented Mar 2, 2023

The script llvm.sh doesn't install a required dependency on Ubuntu - liblldb-dev (or liblldb-$LLVM_VERSION-dev). You can add it manually to the PKG variable in the script

if [[ $ALL -eq 1 ]]; then
    # same as in test-install.sh
    # No worries if we have dups
    PKG="$PKG clang-tidy-$LLVM_VERSION clang-format-$LLVM_VERSION clang-tools-$LLVM_VERSION llvm-$LLVM_VERSION-dev lld-$LLVM_VERSION lldb-$LLVM_VERSION liblldb-$LLVM_VERSION-dev llvm-$LLVM_VERSION-tools libomp-$LLVM_VERSION-dev libc++-$LLVM_VERSION-dev libc++abi-$LLVM_VERSION-dev libclang-common-$LLVM_VERSION-dev libclang-$LLVM_VERSION-dev libclang-cpp$LLVM_VERSION-dev libunwind-$LLVM_VERSION-dev"
fi

or request authors to add it.

Installing liblldb-15-dev via the script alongside the usual does not resolve the problem. I'm still getting the same error message on my Ubuntu 22.04.

However, executing sudo apt-get install liblldb-15-dev solved the issue.

@KonanTheLibrarian
Copy link

Full C/C++ Clang lldb or lldb-mi LLVM 17 VSCODE Debugging for Debian and Ubuntu

I have been able to build lldb-mi and use lldb or lldb-mi with clang++ in Debian and Ubuntu or WSL2 with full power clang++ built debugging including remote debugging into embedded Linux all using VSCODE despite the spaghetti designs of .vscode/xyz.json files going wrong for weeks! Hell who's idea was it to create .vscode/warped.json files?

The lldb and lldb-mi Clang++ debug solution relies on the CodeLLDB VS CODE Extension

You are especially exposed to the bugs with Default LLVM 14 or 15 already installed and you install the latest LLVM 17 with:
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" # llvm.sh BUG in the last if statement Debian or Ubuntu

  • BUG1: To patch it you need a LOT of apt-get calls. lldb-mi (machine interface) builders need MORE than others have stated above. So fix it by hand. BUT it means you have 2 LLVMs and can't remove the older because it's libs are used by the OS. (Debian / Ubuntu). Hence BUG2.
    Install basics ...
mkdir -p ~/projects/clang/ ; cd ~/projects/clang/
sudo apt update && sudo apt upgrade	
sudo apt install build-essential git python3 g++ gdb make cmake
sudo apt install rsync curl wget zip python3-pip
sudo apt autoremove
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
wget https://apt.llvm.org/llvm.sh    

lldb-mi source and advanced install again on the command line ...

cd ~/projects/clang/  &&  git clone https://github.com/lldb-tools/lldb-mi.git
cd ~/projects/clang/lldb-mi/ ; git fetch --all ; git pull ; cat README.md
cat ../lldb.sh
sudo apt install cmake libedit-dev libcurl4-openssl-dev  
LLVM_VERSION=17  # or the versin of LLVM 
PKG="clang-$LLVM_VERSION lldb-$LLVM_VERSION lld-$LLVM_VERSION clangd-$LLVM_VERSION"
sudo apt install $PKG
PKG="clang-tidy-$LLVM_VERSION clang-format-$LLVM_VERSION clang-tools-$LLVM_VERSION llvm-$LLVM_VERSION-dev lld-$LLVM_VERSION lldb-$LLVM_VERSION llvm-$LLVM_VERSION-tools libomp-$LLVM_VERSION-dev libc++-$LLVM_VERSION-dev libc++abi-$LLVM_VERSION-dev libclang-common-$LLVM_VERSION-dev libclang-$LLVM_VERSION-dev libclang-cpp$LLVM_VERSION-dev libunwind-$LLVM_VERSION-dev"
sudo apt install $PKG
PKG="libclang-rt-$LLVM_VERSION-dev libpolly-$LLVM_VERSION-dev"
sudo apt install $PKG
sudo apt install liblldb-$LLVM_VERSION-dev
  • BUG2: in lldb-mi github.com/lldb-tools the cmake build file [in my case] ~/projects/clang/lldb-mi/CMakeLists.txt finds the wrong LLVM 14 on WSL2-Debian for example. The following command shows 2 and I wanted version 17:
find /usr -iname "LLVMConfig.cmake" 2>&-  # finds 2 (below). 
   /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake AND /usr/lib/llvm-17/lib/cmake/llvm/LLVMConfig.cmake
# That means for bugfix PATH_TO_LLVM becomes 17 in my case.

Edit ~/projects/clang/lldb-mi/CMakeLists.txt find the bug line

find_package(LLVM REQUIRED CONFIG)

Change that one line to these (Version 17? or the most up-to-date version from the find command above):-

SET(PATH_TO_LLVM "/usr/lib/llvm-17" CACHE STRING "")
SET(search_paths 
 ${PATH_TO_LLVM}
 ${PATH_TO_LLVM}/lib/cmake 
 ${PATH_TO_LLVM}/lib/cmake/llvm 
 ${PATH_TO_LLVM}/lib/cmake/clang 
 ${PATH_TO_LLVM}/share/clang/cmake/ 
 ${PATH_TO_LLVM}/share/llvm/cmake/ 
) 
find_package(LLVM REQUIRED CONFIG PATHS ${search_paths} NO_DEFAULT_PATH)

The above bugfix technique is found in THIS PDF tutorial for cmake for LLVM
Only then with those changes will lldb-mi build as follows (modified instructions from README.md):

cd ~/projects/clang/lldb-mi/  ;  rm -rf myBuild ; mkdir myBuild ; cd myBuild  # a safer way of building cmake TWO DOTS
cmake ..   # two dots
cmake ..   # again  YES DOT DOT.
cmake --build .   #  ONE dot in this command not two
sudo cp ~/projects/clang/lldb-mi/BuIlD/src/lldb-mi /usr/bin/  # obviously only if it builds
Trouble?  cmake debug Tip:
cd ~/projects/clang/lldb-mi/BuIlD/CMakeFiles/
cat CMakeError.log   CMakeOutput.log   CMakeCache.txt 

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

No branches or pull requests

4 participants