clad icon indicating copy to clipboard operation
clad copied to clipboard

Installation error while building LLVM, Clang & Clad from source

Open u-rox23 opened this issue 1 year ago • 5 comments

Followed the installation guide in the README for building Clang and Clad from source using the following commands:

sudo -H pip install lit
git clone https://github.com/llvm/llvm-project.git src
cd src; git chekout llvmorg-13.0.0
cd llvm/tools
git clone https://github.com/vgvassilev/clad.git clad
cd ../../../
mkdir obj inst
cd obj
cmake -S ../src/llvm -DLLVM_ENABLE_PROJECTS="clang" -DCMAKE_BUILD_TYPE="Debug" -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_INSTALL_PREFIX=../inst
make -j8 clang
make -j8 clad

Failure log:

[100%] Building IntrinsicsXCore.h...
[100%] Building IntrinsicsVE.h...
[100%] Built target intrinsics_gen
[100%] Building CXX object tools/clad/lib/Differentiator/CMakeFiles/cladDifferentiator.dir/BaseForwardModeVisitor.cpp.o
In file included from /home/rox/Desktop/clad-dev/src/llvm/tools/clad/include/clad/Differentiator/BaseForwardModeVisitor.h:4,
                 from /home/rox/Desktop/clad-dev/src/llvm/tools/clad/lib/Differentiator/BaseForwardModeVisitor.cpp:7:
/home/rox/Desktop/clad-dev/src/llvm/tools/clad/include/clad/Differentiator/Compatibility.h:11:10: fatal error: clang/AST/ASTContext.h: No such file or directory
   11 | #include "clang/AST/ASTContext.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [tools/clad/lib/Differentiator/CMakeFiles/cladDifferentiator.dir/build.make:80: tools/clad/lib/Differentiator/CMakeFiles/cladDifferentiator.dir/BaseForwardModeVisitor.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:64310: tools/clad/lib/Differentiator/CMakeFiles/cladDifferentiator.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:64476: tools/clad/tools/CMakeFiles/clad.dir/rule] Error 2
make: *** [Makefile:14645: clad] Error 2

Checking the install directory inst contains these header files in the include directory. Below is the log from CMakeError.log although couldn't find anything dubious other than some regular non-linux flag errors. CMakeError.log CMakeOutput.log

Could anyone help me in figuring the issue as to why the cmake build isn't able to resolve the header paths?

u-rox23 avatar Dec 23 '23 17:12 u-rox23

@u-rox23 apologies for the delay. This approach of building is not often used and has changed in when LLVM moved to the "LLVM monorepo". Alternatively, you can build it by cloning clad in a separate folder and pass -DLLVM_DIR=path/to/llvm/inst

vgvassilev avatar Jan 03 '24 19:01 vgvassilev

Thanks @vgvassilev, building it separately fixed the issue for me. Resolving, thanks again for the help!

u-rox23 avatar Jan 06 '24 13:01 u-rox23

Reopening the issue due to another failure I'm facing. The cmake build and install was successful, however the tests failed following the below command:

make check-clad

Below is one of the failure reason:

Script:
--
: 'RUN: at line 1';   /home/rox/Desktop/clad-dev/inst/bin/clang++ -DCLAD_NO_NUM_DIFF  -std=c++11 -Xclang -add-plugin -Xclang clad -Xclang         -plugin-arg-clad -Xclang -fdump-derived-fn -Xclang         -load -Xclang /home/rox/Desktop/clad-dev/clad_obj/./lib/clad.so /home/rox/Desktop/clad-dev/clad/test/ROOT/Interface.C -I/home/rox/Desktop/clad-dev/clad/test/ROOT/../../include -oInterface.out 2>&1 | /home/rox/Desktop/clad-dev/inst/bin/FileCheck /home/rox/Desktop/clad-dev/clad/test/ROOT/Interface.C
: 'RUN: at line 2';   ./Interface.out | /home/rox/Desktop/clad-dev/inst/bin/FileCheck -check-prefix=CHECK-EXEC /home/rox/Desktop/clad-dev/clad/test/ROOT/Interface.C
: 'RUN: at line 3';   /home/rox/Desktop/clad-dev/inst/bin/clang++ -DCLAD_NO_NUM_DIFF  -std=c++11 -Xclang -add-plugin -Xclang clad -Xclang         -plugin-arg-clad -Xclang -fdump-derived-fn -Xclang         -load -Xclang /home/rox/Desktop/clad-dev/clad_obj/./lib/clad.so -Xclang -plugin-arg-clad -Xclang -enable-tbr /home/rox/Desktop/clad-dev/clad/test/ROOT/Interface.C -I/home/rox/Desktop/clad-dev/clad/test/ROOT/../../include -oInterface.out
: 'RUN: at line 4';   ./Interface.out | /home/rox/Desktop/clad-dev/inst/bin/FileCheck -check-prefix=CHECK-EXEC /home/rox/Desktop/clad-dev/clad/test/ROOT/Interface.C
--
Exit Code: 127

Command Output (stderr):
--
/home/rox/Desktop/clad-dev/clad_obj/test/ROOT/Output/Interface.C.script: line 1: /home/rox/Desktop/clad-dev/inst/bin/FileCheck: No such file or directory

--

Could anyone please provide any help here?

u-rox23 avatar Jan 06 '24 17:01 u-rox23

@u-rox23 - It seems like the LLVM FileCheck utility is missing. You can do the following to get your tests working:

  1. Ensure that your source has the FileCheck utility present for your LLVM version (in /llvm/utils/), ideally if you are using anything above 3.x it should be present in that specified path. If it doesn't exist, consider upgrading your LLVM version to a latest release.
  2. If it exists, check if you had the -DLLVM_INSTALL_UTILS=ON flag in you cmake command. (As of March 08, 2016 auxiliary utilities are not built by default.)

sauravUppoor avatar Jan 06 '24 17:01 sauravUppoor

We should update our documentation to capture the suggested build process for developer builds.

vgvassilev avatar Jan 18 '24 10:01 vgvassilev