introduction

For me, Gentoo Prefix is one of the most interesting open-source projects. It helps me install a complete Gentoo-system under random folder (as long as you can write to it) on many OSes (macOS, Linux, Solaris) and many archtechtures (arm64, x86_64, etc.). The system is managed by portage, so I can leverage the already-existing gentoo repository and even enpower it with overlays to form a unique system.1

To bootstrap prefix easily, currently you need bootstrap-prefix.sh. However, it only officially supports bootstraping with gcc-stuffs on most OSes (except macOS). However (again), since it is Gentoo, you can switch to a nearly pure llvm Prefix with modifications on its profile. Why not enjoy a pure-llvm and diversed system without potentially damaging your host? Let’s try it!

Mostly importantly, because it will not to be compatible to your host-stuffs, it is potentially easily to make some Prefix-related bugs to smoke. Possibly a good chance to improve the project?

how-to

guide

to divide it into steps:

  1. you bootstrap a vanilla prefix on your system under ${EPREFIX},
  2. you emerge sys-devel/clang,
  3. you prepare a profile, which overrides the default gcc-stuff 2,
  4. you switch to the new profile,
  5. you emerge clang-runtime clang-common llvm clang lld again,
  6. you will get a pure llvm Gentoo Prefix,
  7. if you want to, re-emerge the world (or unmerge+re-emerge things when they complain about the system, for example cmake).

special notes

  • for 3. you just need to create a parent file, which points to a genuine prefix profile and the features/llvm profile (e.g. 2),
  • for 4. and 5. each time clang does not work, please feel free to switch back to the profile of gcc, and re-emerge clang,
  • you still need to keep the old gcc stuff, so that it can rescue the Prefix when clang cannot behave itself.
  • sys-libs/glibc seems not working well, please compile it with gcc

fun-stuffs you can play with llvm

compile flags

Add more stuffs like -flto=thin -O3 to your ${CFLAGS} etc.

flang

Technically, flang can replace gfortran and makes your system more unique.

future

To try musl and even llvm-libc in the future.

my system

         -/oyddmdhs+:.                       @ 
     -odNMMMMMMMMNNmhy+-`             --------- 
   -yNMMMMMMMMMMMNNNmmdhy+-           OS: 
 `omMMMMMMMMMMMMNmdmmmmddhhy/`        Host: 
 omMMMMMMMMMMMNhhyyyohmdddhhhdo`      Kernel: 6.1.19-gentoo-x86_64 
.ydMMMMMMMMMMdhs++so/smdddhhhhdm+`    Uptime: 31 days, 23 hours, 17 mins 
 oyhdmNMMMMMMMNdyooydmddddhhhhyhNd.   Packages: 265 (emerge) 
  :oyhhdNNMMMMMMMNNNmmdddhhhhhyymMh   Shell: bash 5.1.16 
    .:+sydNMMMMMNNNmmmdddhhhhhhmMmy   Resolution: 1024x768 
       /mMMMMMMNNNmmmdddhhhhhmMNhs:   Theme: Adwaita [GTK3] 
    `oNMMMMMMMNNNmmmddddhhdmMNhs+`    Icons: Adwaita [GTK3] 
  `sNMMMMMMMMNNNmmmdddddmNMmhs/.      Terminal: startprefix 
 /NMMMMMMMMNNNNmmmdddmNMNdso:`        CPU: 
+MMMMMMMNNNNNmmmmdmNMNdso/-           GPU: 
yMMNNNNNNNmmmmmNNMmhs+/-`             Memory: 
/hMMNNNNNNNNMNdhs++/-`
`/ohdmmddhys+++/:.`                                           
  `-//////:--.                                                

note the libc++{,abi}.so

# ldd /opt/lumiere/usr/bin/eix
        linux-vdso.so.1 (0x00007fffa3520000)
        libc++.so.1 => /opt/lumiere/usr/lib64/libc++.so.1 (0x00007f84205ce000)
        libc++abi.so.1 => /opt/lumiere/usr/lib64/libc++abi.so.1 (0x00007f842058d000)
        libm.so.6 => /opt/lumiere/lib64/libm.so.6 (0x00007f84204e1000)
        libunwind.so.1 => /opt/lumiere/usr/lib64/libunwind.so.1 (0x00007f84204d5000)
        libc.so.6 => /opt/lumiere/lib64/libc.so.6 (0x00007f842030d000)
        /opt/lumiere/lib64/ld-linux-x86-64.so.2 (0x00007f842084b000)

  1. https://github.com/6-6-6/triton mpv,flang,scipy etc. on macOS arm64 ↩︎

  2. https://github.com/6-6-6/lumiere the llvm profile ↩︎ ↩︎