From The Document Foundation Wiki
Jump to navigation Jump to search

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:
    • Install MSVC 12.0 or 14.0
    • Install cmake 3.5.0-rc3 from here
    • Install python 3.5.1 from here
    • Install Ninja 1.6 from here
    • Add all of the above to your path
  • Set up clang tree (note the patch instructions below):

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.

Future Work

Investigate whether clang-cl works on Windows Subsystem for Linux, aka "Windows Bash".

See also