Is installing the project necessary to modify and extend it?

Hi all!

I need to explore/modify/build LLVM and Clang. In the Getting Started documentation, it is said to build it with the usual magical recipe (configure → make → make install). However, I noticed that for Debug builds all the libraries are statically linked: this inflates the binaries size, and thus sudo ninja -C ./build install ends up copying a lot of data, moreover in the root partition (on Linux).

My question is: what advantages does installing provide, apart from having the binaries in PATH?
Because this can be equally fized by putting in your .bashrc (or equivalent)

export PATH=/home/<your-user>/tesi/llvm-project/build/bin:$PATH

Should I always install the project after compiling it? Or is the PATH export enough? Why? Can’t the IDE still access all the relevant headers for auto-completion and similar? Are the libraries affected?

The install command is useful when you want to create something shareable since the builddir is mixed with build objects and the final binaries.

But for just development, you don’t need to install it.

1 Like

Ah, I see, thanks. I guess I’m going to delete everything that has been just installed :sweat_smile:

As a side note, I’ve got two curiosities:

  1. How can you create a shareable package by installing? Setting the install prefix?
  2. If I wanted to install in a portable way, IIUC it would be beneficial to use CMake, much like cmake --build ./build is better than cd build; make if you ever happen to change generator. To install, I read CMake accepts cmake install <dir>, where <dir> is (IIRC) the binaries dir. But LLVM builds also other artifacts, like libraries: if I issued
cmake install ./build/bin

would CMake understand everything it needs, much like make install/ninja install? Maybe using a script (cmake -P), which, IIUC, is also what make and ninja actually do?

  1. Yes -DCMAKE_INSTALL_PREFIX=<path_to_dir>
  2. Not sure about this - but to install just the toolchain and not the libraries there is a CMake switch for this -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON - in my project, I just do cmake --build ./build --target=install-distribution - see more information about distributions here Building a Distribution of LLVM — LLVM 16.0.0git documentation
1 Like

Many thanks!

With respect to 2: Note that CMake really does not like you moving cmake’d build directories, as the CMake config is very full of absolute paths.

I see, thanks. Do this mean it would lead to a series of recompilations?