Thank you all for your patches and the ensuing discussion. I am currently working on porting the z3 Debian package to use the CMake build scripts; I think this will simplify things for all parties involved now and in the future. In the process, I will drop the OCaml bindings; they are currently broken, anyways, have no reverse dependencies, and the upstream CMake scripts don't support building them.
There is still some work that needs to be done (e. g. setting the SONAME correctly), but you can have a look at my current progress here: https://salsa.debian.org/pkg-llvm-team/z3/tree/cmake Is it enough to add -latomic to DEB_LDFLAGS_MAINT_APPEND in debian/rules and disable the Java bindings on riscv64?