Upgrading clang on CI

Hossein Nourikhah hossein at libreoffice.org
Thu Mar 20 14:58:40 UTC 2025


Hello,

I worked on this for a while. There were issues that I discuss here:

Bumping the clang version itself on Jenkins is straightforward, and is 
done in this patch:

Bump linux_clang_dbgutil_64 to clang 18.1.8
https://gerrit.libreoffice.org/c/lode/+/182317

On the other hand, there are issues that rises from the fact that when 
someone compiles the code with clang++ 18 or 19 on Linux, the compiler 
uses the standard C++ library from the distribution, which may not be up 
to date. Therefore, I get warnings/errors for deprecation on Ubuntu 
22.04 LTS:

$ make svl
...
In file included from 
/home/user/lode/dev/core/svl/source/items/stylepool.cxx:20:
In file included from 
/home/user/lode/dev/core/include/svl/stylepool.hxx:21:
In file included from 
/home/user/lode/dev/core/include/rtl/ustring.hxx:38:
In file included from 
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/algorithm:61:
In file included from 
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_algo.h:61:
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tempbuf.h:263:8: 
error: 'get_temporary_buffer<const SfxItemSet *>' is deprecated 
[-Werror,-Wdeprecated-declarations]
   263 |                 
std::get_temporary_buffer<value_type>(_M_original_len));
       |                      ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_algo.h:4996:15: 
note: in instantiation of member function 
'std::_Temporary_buffer<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<const 
SfxItemSet **, std::__cxx1998::vector<const SfxItemSet *>>, 
std::vector<const SfxItemSet *>>, const SfxItemSet 
*>::_Temporary_buffer' requested here
  4996 |       _TmpBuf __buf(__first, (__last - __first + 1) / 2);
       |               ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_algo.h:5070:23: 
note: in instantiation of function template specialization 
'std::__stable_sort<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<const 
SfxItemSet **, std::__cxx1998::vector<const SfxItemSet *>>, 
std::vector<const SfxItemSet *>>, 
__gnu_cxx::__ops::_Iter_comp_iter<(lambda at 
/home/user/lode/dev/core/svl/source/items/stylepool.cxx:264:27)>>' 
requested here
  5070 |       _GLIBCXX_STD_A::__stable_sort(__first, __last,
       |                       ^
/home/user/lode/dev/core/svl/source/items/stylepool.cxx:263:22: note: in 
instantiation of function template specialization 
'std::stable_sort<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<const 
SfxItemSet **, std::__cxx1998::vector<const SfxItemSet *>>, 
std::vector<const SfxItemSet *>>, (lambda at 
/home/user/lode/dev/core/svl/source/items/stylepool.cxx:264:27)>' 
requested here
   263 |                 std::stable_sort(maParents.begin(), 
maParents.end(),
       |                      ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tempbuf.h:99:5: 
note: 'get_temporary_buffer<const SfxItemSet *>' has been explicitly 
marked deprecated here
    99 |     _GLIBCXX17_DEPRECATED
       |     ^
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/c++config.h:119:34: 
note: expanded from macro '_GLIBCXX17_DEPRECATED'
   119 | # define _GLIBCXX17_DEPRECATED [[__deprecated__]]
       |                                  ^
1 error generated.
make[1]: *** [/home/user/lode/dev/core/solenv/gbuild/LinkTarget.mk:339: 
/home/user/lode/dev/core/workdir/CxxObject/svl/source/items/stylepool.o] 
Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:128: svl] Error 2


To fix these issues, we may:

1. Bundle and use standard C++ library from LLVM on Jenkins and 
elsewhere
2. Internally re-define deprecated function, stable_sort
3. Accept the deprecated implementation and avoid error with 
--disable-werror in the autogen.input, in case one face such a problem.

I suggest defining this function:

template<typename Iterator, typename Compare>
void stable_sort_custom(Iterator first, Iterator last, Compare comp) {
#if defined(__clang__) && defined(__GLIBCXX__)
     // new stable_sort implementation
}
#else
     std::stable_sort(first, last, comp);
#endif
}

It defines a new custom_stable_sort, in case clang and GNU standard C++ 
library are used. It falls back to std::stable_sort otherwise.

Regards,
Hossein

On 17.02.2025 21:15, Hossein Nourikhah wrote:
> Hello,
> 
> The baseline for LibreOffice C++ source code is now C++20. But, the 
> clang 12 installed on CI machines is quite old, and lacks some 
> important C++20 features. 
> ("/home/tdf/lode/opt_private/clang-llvmorg-12.0.1/bin/clang" is visible 
> in the build logs)
> 
> C++ ranges library is one example:
> https://en.cppreference.com/w/cpp/ranges/reverse_view
> 
> This is a related CI failure because of lacking C++ ranges library 
> support:
> https://ci.libreoffice.org/job/gerrit_master_ml/35822/
> 
> More details about C++20 support from different compilers can be seen 
> here:
> 
> C++20 library features
> https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B20_library_features
> 
> Looking into the details of clang releases, I think clang versions 
> until and including 17 are no longer supported.
> https://llvm.org/docs/HowToReleaseLLVM.html
> 
> The current stable release is 19, an the preview release is 20.
> https://releases.llvm.org/
> 
> I am not sure about 18, but it is the version available in many Linux 
> distributions, and it seems to build LibreOffice from sources smoothly.
> 
> Ubuntu LTS: 20.04, 24.04, 22.04 (via llvm apt repository), RHEL 8 and 9 
> (via Clang and LLVM Toolset) and many other distributions:
> https://packages.ubuntu.com/search?searchon=contents&keywords=clang&mode=exactfilename&suite=focal-updates&arch=any
> https://packages.ubuntu.com/search?searchon=contents&keywords=clang&mode=exactfilename&suite=noble-updates&arch=any
> 
> Is it possible upgrade clang on CI machines to version 18 (or possibly, 
> 19)?
> 
> Regards,
> Hossein

-- 
Hossein Nourikhah, Ph.D., Developer Community Architect
Tel: +49 30 5557992-65 | Email: hossein at libreoffice.org
The Document Foundation, Winterfeldtstraße 52, 10781 Berlin, DE
Gemeinnützige rechtsfähige Stiftung des bürgerlichen Rechts
Legal details: https://www.documentfoundation.org/imprint


More information about the LibreOffice mailing list