I am trying to build release/16.x
of llvm-project
; but hitting a snafu:
First things first, the system I am on is as follows
Inside my Oracle VirtualBox 7.0, I have
RAM: 5 GiB
CPU: 3 x Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
OS: Ubuntu 22.04.2 LTS
Clang: Ubuntu clang version 14.0.0-1ubuntu1
CMake: cmake version 3.22.1
Ninja: 1.10.1
Gold: GNU gold (GNU Binutils for Ubuntu 2.38) 1.16
Python: Python 3.10
After cloning the release/16.x
branch, I am using the following configuration:
mkdir -p build; mkdir -p installed; cd build; \
cmake -G "Ninja" \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DLLVM_TARGETS_TO_BUILD="X86;RISCV" \
-DCMAKE_BUILD_TYPE="Debug" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_PARALLEL_COMPILE_JOBS=2 \
-DCMAKE_INSTALL_PREFIX=$(pwd)/../installed \
-DLLVM_PARALLEL_LINK_JOBS=2 \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DBUILD_SHARED_LIBS=OFF \
-DLLVM_USE_SPLIT_DWARF=ON \
-DLLVM_USE_LINKER=gold \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DCMAKE_EXE_LINKER_FLAGS='-Wl,-no-keep-memory,-fuse-ld=gold' \
../llvm
The cmake
configuration completes successfully, and build files are written:
...
...
-- Configuring done
-- Generating done
-- Build files have been written to: /media/sf_shared_folder/myProject/llvm-project/build
Subsequently, when I am trying to build the project using ninja
, I am facing the following problem:
ninja -j2 all
[243/3771] Building native llvm-tblgen...
[236/236] Linking CXX executable bin/llvm-tblgen
[326/3771] Building Attributes.inc...
FAILED: include/llvm/IR/Attributes.inc /media/sf_shared_folder/myProject/llvm-project/build/include/llvm/IR/Attributes.inc
cd /media/sf_shared_folder/myProject/llvm-project/build && /media/sf_shared_folder/myProject/llvm-project/build/NATIVE/bin/llvm-tblgen -gen-attrs -I /media/sf_shared_folder/myProject/llvm-project/llvm/include/llvm/IR -I/media/sf_shared_folder/myProject/llvm-project/build/include -I/media/sf_shared_folder/myProject/llvm-project/llvm/include /media/sf_shared_folder/myProject/llvm-project/llvm/include/llvm/IR/Attributes.td --write-if-changed -o include/llvm/IR/Attributes.inc -d include/llvm/IR/Attributes.inc.d
/bin/sh: 1: /media/sf_shared_folder/myProject/llvm-project/build/NATIVE/bin/llvm-tblgen: Exec format error
[327/3771] Building CXX object tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o
ninja: build stopped: subcommand failed.
Now, what is this llvm-tblgen: Exec format error and how do I fix this for a successful build?
I have also raised the issue over at the github repo for llvm-project, issue 62429