Clang MSYS2 environment
Clang, LLVM Flang Fortran compiler, GCC, Boost and many more packages are easily available on Windows via MSYS2. Clang is also available via direct download.
it’s often useful to have separate development environments for each compiler. The Powershell script “clang.ps1” creates a Clang LLVM environment. We don’t permanently put Clang on the user or system PATH to avoid DLL conflicts. Running “clang.ps1” in Powershell enables Clang until that Powershell window is closed.
For MSYS2 Clang and LLVM Flang Fortran compiler, create “clang.ps1” like:
$r="$Env:SystemDrive/msys64/ucrt64"
$b="$r/bin"
$Env:CC="$b/clang"
$Env:CXX="$b/clang++"
$Env:FC="$b/flang"
# important to put UCRT first to avoid "collect2.exe: error: ld returned 116 exit status"
$Env:Path = "$b;$Env:Path"
$Env:CMAKE_PREFIX_PATH="$r"
For standalone (non-MSYS2) Clang make “clang.ps1” like:
$Env:CC="clang"
$Env:CXX="clang++"
$Env:Path = "$Env:ProgramFiles/LLVM/bin;$Env:Path"
If you need to use the MSVC CL-like clang driver clang-cl, create “clang-cl.ps1” and run it when desired.
$Env:CC="clang-cl"
$Env:CXX="clang-cl"
$Env:Path = "$Env:ProgramFiles/LLVM/bin;$Env:Path"