cullmann.io/content/post/cmake-meson-compcert.md

2.3 KiB

title date draft categories tags url author
CMake & Meson & CompCert 2020-06-07T16:13:00+02:00 false
c
development
c
/posts/cmake-meson-compcert/ Christoph Cullmann

I tried to compile the Picolibc that uses the Meson build system with CompCert.

The CompCert install I tried uses the GNU/GCC toolchain for preprocessing and linking. That makes the compiler relatively compatible to a GCC, beside that not all command line options are supported.

I was used to CMake projects and there it is normally enough to just set CC=ccomp and you are ready and set (at least if you use the GNU/GCC toolchain). As long as you don't use special flags in your project, that will just work.

The Picolibc was the first Meson based project I encountered.

There setting CC to ccomp just leads to

{{< highlight bash >}} meson.build:1:0: ERROR: Unknown compiler(s): 'ccomp' {{< / highlight >}}

I did assume that the project won't compile & link without adjustments, as CompCert doesn't support the full range of command line options like GCC as mentioned above nor the full GNU extensions for C. But that it directly ends at the compiler initialization in the build system itself was astonishing.

I searched a bit in the internet and it seems, if I really want to get this working, I actually need to patch Meson itself :/ (see how to add a new compiler here)

At least I found no other solution, actually, I found no real solution for the above error message at all and the code looks like you need to manually add compilers anyways.

Given I want to spend work on getting the C library to compile and not fix a build system, it seems easier to go with the newlib that uses the old autotools, at least for them the compile starts at all with my CC environment variable and you get to places of interest to fix.

This means for my use case, with a non-standard compiler, I can not see how Meson is an improvement over other existing stuff like CMake or even autotools. But perhaps this area will improve in the future.