This is a Bash script (macOS, Linux, ...) for building Flang-f18 and LLVM from source. It is adapted from Jeff Hammond
Ninja: recommended for best build efficiency and speed.
In general, a recent GCC would work. On macOS, system AppleClang compiler can be used as well.
bash build-flang-f18.shTo specify the source URL, for example to build the latest LLVM 20.x release:
bash build-flang-f18.sh https://github.com/llvm/llvm-project/archive/refs/heads/release/20.x.zipFor a specific version of LLVM:
bash build-flang-f18.sh https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-20.1.3.zipThe source download is about 300 MB. LLVM takes about a half-hour to build on a powerful laptop or workstation.
To use the compiler after install:
source clang-latest.shlldLLVM linkermlirintermediate representationpstlParallel STL (optional)pollyLoop optimization (optional)
See ulimit settings if link failures occur.
The installed binaries take a few gigabytes of disk space.
du -sh ~/llvm-latest # the install prefix3.5G
About 3.5 Gigabytes are used for the installed LLVM binaries.
The source directory can be deleted after the build / install is complete.
du -sh $TMPDIR/llvm-src1.8G
The build directory can be deleted after the build / install is complete.
du -sh $TMPDIR/llvm-build5.0G
Interesting. A linux system I used also had
1024and macOS has256. I will note it in the Readme.