fixing build when ENABLE_CLANG_JIT is disabled (#3201)
attempting a cmake build with `ENABLE_CLANG_JIT` disabled and not `PYTHON_ONLY` fails with the following output: root@4ec15b1c6d03:~/src/bcc/tmp# cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD:STRING=20 -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_INSTALL_PREFIX:PATH=/root/opt -DENABLE_CPP_API=ON -DENABLE_LLVM_NATIVECODEGEN=ON -DENABLE_LLVM_SHARED=OFF -DENABLE_MAN=OFF -DENABLE_RTTI=OFF -DINSTALL_CPP_EXAMPLES=OFF -DENABLE_CLANG_JIT=OFF ../src -- Latest recognized Git tag is v0.17.0 -- Git HEAD is ad5b82a5 -- Revision is 0.17.0-ad5b82a5 CMake Error at src/cc/CMakeLists.txt:31 (string): string sub-command REGEX, mode MATCH needs at least 5 arguments total to command. CMake Error at src/cc/CMakeLists.txt:61 (if): if given arguments: "VERSION_EQUAL" "6" "OR" "VERSION_GREATER" "6" Unknown arguments specified -- Configuring incomplete, errors occurred! See also "/root/src/bcc/tmp/CMakeFiles/CMakeOutput.log". ``` The reason for the failure is that `LLVM` is required by [`src/cc/CMakeLists.txt`](https://github.com/iovisor/bcc/blob/297512a31ecc9ceebf79bda169350dace0f36757/src/cc/CMakeLists.txt#L61), which is included for non `PYTHON_ONLY` builds by [`src/CMakeLists.txt`](https://github.com/iovisor/bcc/blob/297512a31ecc9ceebf79bda169350dace0f36757/src/CMakeLists.txt#L16). Yet, `LLVM` is only looked up by [`/CMakeLists.txt`](https://github.com/iovisor/bcc/blob/297512a31ecc9ceebf79bda169350dace0f36757/CMakeLists.txt#L54) whenever `ENABLE_CLANG_JIT` is enabled. The proposed fix looks up `LLVM` whenever `PYTHON_ONLY` is disabled, even if `ENABLE_CLANG_JIT` is disabled. This is the output after the fix is applied: ``` root@4ec15b1c6d03:~/src/bcc/tmp# cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD:STRING=20 -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_INSTALL_PREFIX:PATH=/root/opt -DENABLE_CPP_API=ON -DENABLE_LLVM_NATIVECODEGEN=ON -DENABLE_LLVM_SHARED=OFF -DENABLE_MAN=OFF -DENABLE_RTTI=OFF -DINSTALL_CPP_EXAMPLES=OFF -DENABLE_CLANG_JIT=OFF ../src -- The C compiler identification is GNU 10.2.1 ... -- Build files have been written to: /root/src/bcc/tmp root@4ec15b1c6d03:~/src/bcc/tmp# make -j`nproc --all` Scanning dependencies of target bpf-static Scanning dependencies of target bpf-shared [ 2%] Building C object src/cc/CMakeFiles/bpf-static.dir/libbpf.c.o ... [100%] Built target bps root@4ec15b1c6d03:~/src/bcc/tmp#
Loading
Please register or sign in to comment