LibreOffice is currently built on Windows using the MSVC compiler, but it's possible to also build it using the Clang clang-cl wrapper.
Clang should be already installed together with MS Visual Studio, and so it should be possible to build by adding something like the following to the end of autogen.input:
CC=C:/PROGRA~2/MICROS~3/2019/COMMUN~1/VC/Tools/Llvm/bin/clang-cl.exe -m64 CXX=C:/PROGRA~2/MICROS~3/2019/COMMUN~1/VC/Tools/Llvm/bin/clang-cl.exe -m64 CXX_X86_BINARY=C:/PROGRA~2/MICROS~3/2019/COMMUN~1/VC/Tools/Llvm/bin/clang-cl.exe -m32
The path is the location of the clang-cl.exe binary (located e.g. at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/clang-cl.exe for MSVC 2019) converted using cygpath -m -s <path>. It is also usually necessary to specify -m32/-m64 for 32bit or 64bit compilers, for building on a 64bit platform the way as described, for building on a 32bit platform all should use -m32.
For building with precompiled headers (PCH), at least Clang 13.0 is necessary, otherwise build will later fail. As of December 2021, the Clang shipped with MSVC is too old, so it's necessary to either use --disable-pch, or to download and install LLVM/Clang and use that instead.
Currently neither Clang provided by MS Visual Studio nor Clang provided by LLVM allow building Clang plugins. This and the warning about it can be ignored (possibly explicitly by using --disable-compiler-plugins), otherwise Clang needs to be built from source.
Building Clang from source
Unless also Clang compiler plugins are wanted, this is not necessary. If unsure, use Clang binaries.
- Install needed tools to build clang:
- Set up clang tree (note the patch instructions below):
- Start MSVC shell ("VS2015 x64 Native Tools Command Prompt")
- cd <directory-of-your-choice>
- mkdir clang
- git clone https://git.llvm.org/git/llvm.git
- cd llvm
- cd tools
- git clone https://git.llvm.org/git/clang.git
- cd ..\projects
- git clone https://git.llvm.org/git/compiler-rt.git
- cd ..\..
- mkdir llvm-objdir
- cd llvm-objdir
- cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 ..\llvm
- find the fresh built clang-cl executable in
Set up LibreOffice build
This section is(?) obsolete. Current master version of LibreOffice should build using only setting flags as described above. This section may be perhaps useful if building older versions.
- Recent LibreOffice master repo (known working: “Work around -Werror,-Wunused-macros with clang-cl”)
- Patches that were needed in the past:
- (“TODO: work around clang-cl ABI bug PR25641” to work around ”clang-cl: vtordisp thunks not emitted for functions with class template specializations in their signatures” until there is a fix for that bug; merged for now as core commit 81ce629c9e8a4fc26ded9d49157e3f3263991e03)
- In autogen.input (using whatever
-fmsc-version=nnnnmatches your installed compiler version, see documentation of
CC=.../clang-cl.exe -FIIntrin.h -fmsc-version=1915 -Qunused-arguments --target=x86_64-pc-windows-msvc
CXX=.../clang-cl.exe -D_CRT_RAND_S= -FIIntrin.h -fmsc-version=1915 -Qunused-arguments --target=x86_64-pc-windows-msvc
- Only tested with
- There is an issue with
safeint.hat least from Windows SDK 10.0.10240, see core commit 2685678cd0221f4522e8502183baeaecb5ddd0a4, which is known to be solved at least with Windows SDK 10.0.15063.137 available from .
- “Finally Building on Windows” has presentation slides about earlier progress towards the above.