Hacker News new | ask | show | jobs
by senknvd 1304 days 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/

2 comments

Wow 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
You 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.
Trivial, assuming that one codes in the subset that is understood by all compilers.

Good luck trying C++20 with clang.