kiss-llvm icon indicating copy to clipboard operation
kiss-llvm copied to clipboard

A kiss-repo structure to build standalone LLVM

|/ |\ISS LINUX (unofficial repository) https://kisslinux.org


This is a kiss-compliant repository structure to build LLVM without any traces of GCC libraries. It also provides any alternatives for official KISS packages that cannot be built in an LLVM-only environment as is.

This repository is to be used in conjunction with KISS Linux repositories and NOT as a total replacement for KISS Linux.

DISCLAIMER


While since 11 July KISS does support an LLVM/Clang toolchain as a first class citizen along with GCC [1] (some of our changes to accommodate systems built with kiss-llvm toolchain are also accepted), some packages (namely, eiwd) will not work with Clang at all at present (version 1.15, at the time I'm writing this). Those packages will explicitly depend on gcc (and any attempts to build gcc with this repo will automatically fail unless user manually overrides that by using their own repo, or directly building it, CRUX-style, note that I won't be supporting the use case though since I don't think it is possible without significant headache).

When submitting reports about failure to build LLVM/Clang from this repo, report it here, not kisslinux/repo. Otherwise, you probably can open an issue there, but please state your toolchain.

Building kiss-llvm


To build LLVM compiler infrastructure from scratch (and without any traces of GCC), you'll need to build and install the llvm bootstrap packaged as @llvm before building the main llvm package.

See the build file for @llvm for more information. It builds llvm proper first, clang (pass 1), compiler-rt, libunwind, libc++abi, libc++, and finally, clang again (pass 2).

NOTE: This is what I could do, however, if you can find a better way that doesn't require 2 passes to clang, patches welcome! Also, some required packages may be missing.

Recommended: Since downloading files repeatedly is a waste of bandwidth (especially if you have a slow Internet), you can use this command to symlink thesource cache (usually located in $HOME/.cache/kiss/sources):

$ ln -s llvm @llvm

And make sure to download the main LLVM package sources first and NOT the bootstrap packages (by using kiss c in the llvm directory, or by using kiss c llvm after adding the kiss-llvm directory to $PATH, make sure the checksums are NOT changed, git should be able to track these).

Using LLVM from kiss-llvm


After installing llvm from kiss-llvm (and uninstalling the temporary bootstrap packages), you can use the alternatives system to switch to LLVM-provided binutils (except as).

Because programs might still detect GCC and use it, you can force Clang by applying environment variables CC=cc and CXX=c++ after applying the alternatives. (For some packages like Busybox, you may need to explicitly use CC=clang, as they explicitly detect Clang through the name of the binary)

Also, you will need to rebuild every single package that links to /lib/libstdc++.so, a small way to check if a library or a program links to libstdc++ using the shell as follows:

$ for file in /usr/bin/* /usr/lib/*; do echo FILE: "$file" # This is as an identifier of which file ldd "$file" | grep libstdc++ done

You may also need to check if any packages link to libatomic.so and libgcc_s.so.

You can use kiss-owns to check which file belongs to which package, and rebuild that.


If you think replacing just the compiler and the binutils is not enough, head on over to Wyverkiss [2] since the distribution also removes the need for GNU bison and many others (GNU make cannot be removed though). Please note that Wyverkiss will NOT be supported by Dylan though.

[1] https://kisslinux.org/blog/20210711a [2] https://github.com/wyvertux/wyverkiss