4 ms·
If you're using a decent build system[1], it's trivial to test your code with Clang, GCC, and more: export CC_LD=lld CC=clang meson setup -Dbuildtype=d
by senknvd 4y ago
If you're using a decent build system[1], it's trivial to test your code with Clang, GCC, and more:
export CC_LD=lld
CC=clang meson setup -Dbuildtype=debug -Dwarning_level=3 build-debug-clang
CC=gcc meson setup -Dbuildtype=debug -Dwarning_level=3 build-debug-gcc
CC=clang meson setup -Dbuildtype=debugoptimized -Dwarning_level=3 -Db_lundef=false -Db_sanitize=address build-asan
Now you can just
ninja -C <name of build folder>
to build any and all of these without affecting your source directory. I usually wrap all the useful configurations in a Makefile-like shell script.
[1]: https://mesonbuild.com/ https://mesonbuild.com/
- jeffbee 4y agoWow that's not trivial by any definition of the word. With bazel and the standard bazel toolchain config, you just do: CC=<whatever> bazel build
- senknvd 4y agoYou can do the same with Meson. I just added the warning, debugging, and sanitizer options in-line for clarity. The benefit (I'm not sure if Bazel has this too) is you only have to run the commands once to set up the build directories. After that, you can just use the ultra-fast ninja and almost ignore Meson completely.
- pjmlp 4y agoTrivial, assuming that one codes in the subset that is understood by all compilers. Good luck trying C++20 with clang.